aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_addr_relay.py
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2021-04-15 23:09:40 +0200
committerMartin Zumsande <mzumsande@gmail.com>2021-04-21 22:34:10 +0200
commita732ee353c1922a1f9ca082775884d190893e0e9 (patch)
tree03ce73163113230e3bcd378ff78fafa319137d2b /test/functional/p2p_addr_relay.py
parenta6694eaed8f86a6ad79689bbcbfdbed4d73327c9 (diff)
downloadbitcoin-a732ee353c1922a1f9ca082775884d190893e0e9.tar.xz
[test] Add tests for addr relay in -blocksonly mode
Co-Authored-By: Martin Zumsande <mzumsande@gmail.com>
Diffstat (limited to 'test/functional/p2p_addr_relay.py')
-rwxr-xr-xtest/functional/p2p_addr_relay.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py
index 46c804e728..fdd02b7324 100755
--- a/test/functional/p2p_addr_relay.py
+++ b/test/functional/p2p_addr_relay.py
@@ -59,6 +59,7 @@ class AddrTest(BitcoinTestFramework):
self.oversized_addr_test()
self.relay_tests()
self.getaddr_tests()
+ self.blocksonly_mode_tests()
def setup_addr_msg(self, num):
addrs = []
@@ -167,6 +168,7 @@ class AddrTest(BitcoinTestFramework):
self.log.info('Check that we answer getaddr messages only from inbound peers')
inbound_peer = self.nodes[0].add_p2p_connection(GetAddrStore())
inbound_peer.sync_with_ping()
+
# Add some addresses to addrman
for i in range(1000):
first_octet = i >> 8
@@ -188,6 +190,27 @@ class AddrTest(BitcoinTestFramework):
self.nodes[0].disconnect_p2ps()
+ def blocksonly_mode_tests(self):
+ self.log.info('Test addr relay in -blocksonly mode')
+ self.restart_node(0, ["-blocksonly"])
+ self.mocktime = int(time.time())
+
+ self.log.info('Check that we send getaddr messages')
+ full_outbound_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=0, connection_type="outbound-full-relay")
+ full_outbound_peer.sync_with_ping()
+ assert full_outbound_peer.getaddr_received
+
+ self.log.info('Check that we relay address messages')
+ addr_source = self.nodes[0].add_p2p_connection(P2PInterface())
+ msg = self.setup_addr_msg(2)
+ addr_source.send_and_ping(msg)
+ self.mocktime += 5 * 60
+ self.nodes[0].setmocktime(self.mocktime)
+ full_outbound_peer.sync_with_ping()
+ assert_equal(full_outbound_peer.num_ipv4_received, 2)
+
+ self.nodes[0].disconnect_p2ps()
+
if __name__ == '__main__':
AddrTest().main()