@@ -59,6 +59,7 @@ def run_test(self):
59
59
self .oversized_addr_test ()
60
60
self .relay_tests ()
61
61
self .getaddr_tests ()
62
+ self .blocksonly_mode_tests ()
62
63
63
64
def setup_addr_msg (self , num ):
64
65
addrs = []
@@ -167,6 +168,7 @@ def getaddr_tests(self):
167
168
self .log .info ('Check that we answer getaddr messages only from inbound peers' )
168
169
inbound_peer = self .nodes [0 ].add_p2p_connection (GetAddrStore ())
169
170
inbound_peer .sync_with_ping ()
171
+
170
172
# Add some addresses to addrman
171
173
for i in range (1000 ):
172
174
first_octet = i >> 8
@@ -188,6 +190,27 @@ def getaddr_tests(self):
188
190
189
191
self .nodes [0 ].disconnect_p2ps ()
190
192
193
+ def blocksonly_mode_tests (self ):
194
+ self .log .info ('Test addr relay in -blocksonly mode' )
195
+ self .restart_node (0 , ["-blocksonly" ])
196
+ self .mocktime = int (time .time ())
197
+
198
+ self .log .info ('Check that we send getaddr messages' )
199
+ full_outbound_peer = self .nodes [0 ].add_outbound_p2p_connection (GetAddrStore (), p2p_idx = 0 , connection_type = "outbound-full-relay" )
200
+ full_outbound_peer .sync_with_ping ()
201
+ assert full_outbound_peer .getaddr_received
202
+
203
+ self .log .info ('Check that we relay address messages' )
204
+ addr_source = self .nodes [0 ].add_p2p_connection (P2PInterface ())
205
+ msg = self .setup_addr_msg (2 )
206
+ addr_source .send_and_ping (msg )
207
+ self .mocktime += 5 * 60
208
+ self .nodes [0 ].setmocktime (self .mocktime )
209
+ full_outbound_peer .sync_with_ping ()
210
+ assert_equal (full_outbound_peer .num_ipv4_received , 2 )
211
+
212
+ self .nodes [0 ].disconnect_p2ps ()
213
+
191
214
192
215
if __name__ == '__main__' :
193
216
AddrTest ().main ()
0 commit comments