diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2021-04-16 17:53:15 +0200 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2021-04-21 22:34:03 +0200 |
commit | a6694eaed8f86a6ad79689bbcbfdbed4d73327c9 (patch) | |
tree | 82c97c708431f1e1d9b54347d6c1961f41e79bca | |
parent | 8188b77c17d78bf608cb41978db4d0f46e91f7d8 (diff) |
[test] Add address relay tests involving outbound peers
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
-rwxr-xr-x | test/functional/p2p_addr_relay.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 96f4ff8c2d..46c804e728 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -94,6 +94,7 @@ class AddrTest(BitcoinTestFramework): self.nodes[0].disconnect_p2ps() def relay_tests(self): + self.log.info('Test address relay') self.log.info('Check that addr message content is relayed and added to addrman') addr_source = self.nodes[0].add_p2p_connection(P2PInterface()) num_receivers = 7 @@ -122,6 +123,35 @@ class AddrTest(BitcoinTestFramework): self.nodes[0].disconnect_p2ps() + self.log.info('Check relay of addresses received from outbound peers') + inbound_peer = self.nodes[0].add_p2p_connection(AddrReceiver()) + full_outbound_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=0, connection_type="outbound-full-relay") + msg = self.setup_addr_msg(2) + self.send_addr_msg(full_outbound_peer, msg, [inbound_peer]) + self.log.info('Check that the first addr message received from an outbound peer is not relayed') + # Currently, there is a flag that prevents the first addr message received + # from a new outbound peer to be relayed to others. Originally meant to prevent + # large GETADDR responses from being relayed, it now typically affects the self-announcement + # of the outbound peer which is often sent before the GETADDR response. + assert_equal(inbound_peer.num_ipv4_received, 0) + + self.log.info('Check that subsequent addr messages sent from an outbound peer are relayed') + msg2 = self.setup_addr_msg(2) + self.send_addr_msg(full_outbound_peer, msg2, [inbound_peer]) + assert_equal(inbound_peer.num_ipv4_received, 2) + + self.log.info('Check address relay to outbound peers') + block_relay_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=1, connection_type="block-relay-only") + msg3 = self.setup_addr_msg(2) + self.send_addr_msg(inbound_peer, msg3, [full_outbound_peer, block_relay_peer]) + + self.log.info('Check that addresses are relayed to full outbound peers') + assert_equal(full_outbound_peer.num_ipv4_received, 2) + self.log.info('Check that addresses are not relayed to block-relay-only outbound peers') + assert_equal(block_relay_peer.num_ipv4_received, 0) + + self.nodes[0].disconnect_p2ps() + def getaddr_tests(self): self.log.info('Test getaddr behavior') self.log.info('Check that we send a getaddr message upon connecting to an outbound-full-relay peer') |