Skip to content

Commit a732ee3

Browse files
[test] Add tests for addr relay in -blocksonly mode
Co-Authored-By: Martin Zumsande <[email protected]>
1 parent a6694ea commit a732ee3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/functional/p2p_addr_relay.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def run_test(self):
5959
self.oversized_addr_test()
6060
self.relay_tests()
6161
self.getaddr_tests()
62+
self.blocksonly_mode_tests()
6263

6364
def setup_addr_msg(self, num):
6465
addrs = []
@@ -167,6 +168,7 @@ def getaddr_tests(self):
167168
self.log.info('Check that we answer getaddr messages only from inbound peers')
168169
inbound_peer = self.nodes[0].add_p2p_connection(GetAddrStore())
169170
inbound_peer.sync_with_ping()
171+
170172
# Add some addresses to addrman
171173
for i in range(1000):
172174
first_octet = i >> 8
@@ -188,6 +190,27 @@ def getaddr_tests(self):
188190

189191
self.nodes[0].disconnect_p2ps()
190192

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+
191214

192215
if __name__ == '__main__':
193216
AddrTest().main()

0 commit comments

Comments
 (0)