18
18
from test_framework .test_framework import BitcoinTestFramework
19
19
from test_framework .util import assert_equal
20
20
21
+ I2P_ADDR = "c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p"
22
+
21
23
ADDRS = []
22
24
for i in range (10 ):
23
25
addr = CAddress ()
24
26
addr .time = int (time .time ()) + i
25
27
addr .nServices = NODE_NETWORK | NODE_WITNESS
26
- addr .ip = "123.123.123.{}" .format (i % 256 )
28
+ # Add one I2P address at an arbitrary position.
29
+ if i == 5 :
30
+ addr .net = addr .NET_I2P
31
+ addr .ip = I2P_ADDR
32
+ else :
33
+ addr .ip = f"123.123.123.{ i % 256 } "
27
34
addr .port = 8333 + i
28
35
ADDRS .append (addr )
29
36
@@ -35,11 +42,8 @@ def __init__(self):
35
42
super ().__init__ (support_addrv2 = True )
36
43
37
44
def on_addrv2 (self , message ):
38
- for addr in message .addrs :
39
- assert_equal (addr .nServices , NODE_NETWORK | NODE_WITNESS )
40
- assert addr .ip .startswith ('123.123.123.' )
41
- assert (8333 <= addr .port < 8343 )
42
- self .addrv2_received_and_checked = True
45
+ if ADDRS == message .addrs :
46
+ self .addrv2_received_and_checked = True
43
47
44
48
def wait_for_addrv2 (self ):
45
49
self .wait_until (lambda : "addrv2" in self .last_message )
@@ -64,15 +68,18 @@ def run_test(self):
64
68
addr_receiver = self .nodes [0 ].add_p2p_connection (AddrReceiver ())
65
69
msg .addrs = ADDRS
66
70
with self .nodes [0 ].assert_debug_log ([
67
- 'Added 10 addresses from 127.0.0.1: 0 tried' ,
68
- 'received: addrv2 (131 bytes) peer=0' ,
69
- 'sending addrv2 (131 bytes) peer=1' ,
71
+ # The I2P address is not added to node's own addrman because it has no
72
+ # I2P reachability (thus 10 - 1 = 9).
73
+ 'Added 9 addresses from 127.0.0.1: 0 tried' ,
74
+ 'received: addrv2 (159 bytes) peer=0' ,
75
+ 'sending addrv2 (159 bytes) peer=1' ,
70
76
]):
71
77
addr_source .send_and_ping (msg )
72
78
self .nodes [0 ].setmocktime (int (time .time ()) + 30 * 60 )
73
79
addr_receiver .wait_for_addrv2 ()
74
80
75
81
assert addr_receiver .addrv2_received_and_checked
82
+ assert_equal (len (self .nodes [0 ].getnodeaddresses (count = 0 , network = "i2p" )), 0 )
76
83
77
84
78
85
if __name__ == '__main__' :
0 commit comments