(node_factory, bitcoind)
| 2735 | @pytest.mark.openchannel('v1') |
| 2736 | @pytest.mark.openchannel('v2') |
| 2737 | def test_peerinfo(node_factory, bitcoind): |
| 2738 | l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'may_reconnect': True}) |
| 2739 | |
| 2740 | lfeatures = expected_peer_features() |
| 2741 | nfeatures = expected_node_features() |
| 2742 | |
| 2743 | # Gossiping but no node announcement yet |
| 2744 | assert l1.rpc.getpeer(l2.info['id'])['connected'] |
| 2745 | assert len(l1.rpc.listpeerchannels(l2.info['id'])['channels']) == 0 |
| 2746 | assert l1.rpc.getpeer(l2.info['id'])['features'] == lfeatures |
| 2747 | |
| 2748 | # Fund a channel to force a node announcement |
| 2749 | chan, _ = l1.fundchannel(l2, 10**6) |
| 2750 | # Now proceed to funding-depth and do a full gossip round |
| 2751 | bitcoind.generate_block(5) |
| 2752 | l1.daemon.wait_for_logs(['Received node_announcement for node ' + l2.info['id']]) |
| 2753 | l2.daemon.wait_for_logs(['Received node_announcement for node ' + l1.info['id']]) |
| 2754 | |
| 2755 | # Should have announced the same features as told to peer. |
| 2756 | nodes1 = l1.rpc.listnodes(l2.info['id'])['nodes'] |
| 2757 | nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes'] |
| 2758 | peer1 = l1.rpc.getpeer(l2.info['id']) |
| 2759 | peer2 = l2.rpc.getpeer(l1.info['id']) |
| 2760 | # peer features != to node features now because of keysend, which adds a node feature |
| 2761 | assert only_one(nodes1)['features'] == nfeatures |
| 2762 | assert only_one(nodes2)['features'] == nfeatures |
| 2763 | assert peer1['features'] == lfeatures |
| 2764 | assert peer2['features'] == lfeatures |
| 2765 | |
| 2766 | # If it reconnects after db load, it should know features. |
| 2767 | l1.restart() |
| 2768 | wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected']) |
| 2769 | wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected']) |
| 2770 | assert l1.rpc.getpeer(l2.info['id'])['features'] == lfeatures |
| 2771 | assert l2.rpc.getpeer(l1.info['id'])['features'] == lfeatures |
| 2772 | |
| 2773 | # Close the channel to forget the peer |
| 2774 | l1.rpc.close(chan) |
| 2775 | |
| 2776 | # Make sure close tx hits mempool before we mine blocks. |
| 2777 | bitcoind.generate_block(100, wait_for_mempool=1) |
| 2778 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 2779 | l2.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 2780 | assert l1.rpc.listpeerchannels(l2.info['id'])['channels'] == [] |
| 2781 | assert l2.rpc.listpeerchannels(l1.info['id'])['channels'] == [] |
| 2782 | |
| 2783 | # The only channel was closed, everybody should have forgotten the nodes |
| 2784 | assert l1.rpc.listnodes()['nodes'] == [] |
| 2785 | assert l2.rpc.listnodes()['nodes'] == [] |
| 2786 | |
| 2787 | |
| 2788 | def test_disconnectpeer(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected