21
21
22
22
23
23
class P2PAddrFetch (BitcoinTestFramework ):
24
-
25
24
def set_test_params (self ):
26
25
self .setup_clean_chain = True
27
26
self .num_nodes = 1
28
27
28
+ def assert_getpeerinfo (self , * , peer_ids ):
29
+ num_peers = len (peer_ids )
30
+ info = self .nodes [0 ].getpeerinfo ()
31
+ assert_equal (len (info ), num_peers )
32
+ for n in range (0 , num_peers ):
33
+ assert_equal (info [n ]['id' ], peer_ids [n ])
34
+ assert_equal (info [n ]['connection_type' ], 'addr-fetch' )
35
+
29
36
def run_test (self ):
30
37
node = self .nodes [0 ]
31
38
self .log .info ("Connect to an addr-fetch peer" )
32
- peer = node .add_outbound_p2p_connection (P2PInterface (), p2p_idx = 0 , connection_type = "addr-fetch" )
33
- info = node .getpeerinfo ()
34
- assert_equal (len (info ), 1 )
35
- assert_equal (info [0 ]['connection_type' ], 'addr-fetch' )
39
+ peer_id = 0
40
+ peer = node .add_outbound_p2p_connection (P2PInterface (), p2p_idx = peer_id , connection_type = "addr-fetch" )
41
+ self .assert_getpeerinfo (peer_ids = [peer_id ])
36
42
37
43
self .log .info ("Check that we send getaddr but don't try to sync headers with the addr-fetch peer" )
38
44
peer .sync_send_with_ping ()
@@ -45,7 +51,7 @@ def run_test(self):
45
51
msg = msg_addr ()
46
52
msg .addrs = [ADDR ]
47
53
peer .send_and_ping (msg )
48
- assert_equal ( len ( node . getpeerinfo ()), 1 )
54
+ self . assert_getpeerinfo ( peer_ids = [ peer_id ] )
49
55
50
56
self .log .info ("Check that answering with larger addr messages leads to disconnect" )
51
57
msg .addrs = [ADDR ] * 2
0 commit comments