(node_factory, bitcoind)
| 2612 | @pytest.mark.openchannel('v1') |
| 2613 | @pytest.mark.openchannel('v2') |
| 2614 | def test_peerinfo(node_factory, bitcoind): |
| 2615 | l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'may_reconnect': True}) |
| 2616 | |
| 2617 | if l1.config('experimental-dual-fund'): |
| 2618 | lfeatures = expected_peer_features(extra=[21, 29]) |
| 2619 | nfeatures = expected_node_features(extra=[21, 29]) |
| 2620 | else: |
| 2621 | lfeatures = expected_peer_features() |
| 2622 | nfeatures = expected_node_features() |
| 2623 | |
| 2624 | # Gossiping but no node announcement yet |
| 2625 | assert l1.rpc.getpeer(l2.info['id'])['connected'] |
| 2626 | assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0 |
| 2627 | assert l1.rpc.getpeer(l2.info['id'])['features'] == lfeatures |
| 2628 | |
| 2629 | # Fund a channel to force a node announcement |
| 2630 | chan, _ = l1.fundchannel(l2, 10**6) |
| 2631 | # Now proceed to funding-depth and do a full gossip round |
| 2632 | bitcoind.generate_block(5) |
| 2633 | l1.daemon.wait_for_logs(['Received node_announcement for node ' + l2.info['id']]) |
| 2634 | l2.daemon.wait_for_logs(['Received node_announcement for node ' + l1.info['id']]) |
| 2635 | |
| 2636 | # Should have announced the same features as told to peer. |
| 2637 | nodes1 = l1.rpc.listnodes(l2.info['id'])['nodes'] |
| 2638 | nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes'] |
| 2639 | peer1 = l1.rpc.getpeer(l2.info['id']) |
| 2640 | peer2 = l2.rpc.getpeer(l1.info['id']) |
| 2641 | # peer features != to node features now because of keysend, which adds a node feature |
| 2642 | assert only_one(nodes1)['features'] == nfeatures |
| 2643 | assert only_one(nodes2)['features'] == nfeatures |
| 2644 | assert peer1['features'] == lfeatures |
| 2645 | assert peer2['features'] == lfeatures |
| 2646 | |
| 2647 | # If it reconnects after db load, it should know features. |
| 2648 | l1.restart() |
| 2649 | wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected']) |
| 2650 | wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected']) |
| 2651 | assert l1.rpc.getpeer(l2.info['id'])['features'] == lfeatures |
| 2652 | assert l2.rpc.getpeer(l1.info['id'])['features'] == lfeatures |
| 2653 | |
| 2654 | # Close the channel to forget the peer |
| 2655 | l1.rpc.close(chan) |
| 2656 | |
| 2657 | # Make sure close tx hits mempool before we mine blocks. |
| 2658 | bitcoind.generate_block(100, wait_for_mempool=1) |
| 2659 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 2660 | l2.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 2661 | assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'] == [] |
| 2662 | assert only_one(l2.rpc.listpeers(l1.info['id'])['peers'])['channels'] == [] |
| 2663 | |
| 2664 | # The only channel was closed, everybody should have forgotten the nodes |
| 2665 | assert l1.rpc.listnodes()['nodes'] == [] |
| 2666 | assert l2.rpc.listnodes()['nodes'] == [] |
| 2667 | |
| 2668 | |
| 2669 | def test_disconnectpeer(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected