diff options
author | Matthew Zipkin <pinheadmz@gmail.com> | 2023-06-23 11:02:04 -0400 |
---|---|---|
committer | Matthew Zipkin <pinheadmz@gmail.com> | 2023-07-10 10:07:45 -0400 |
commit | 5aaf988ccca210228c5a41ea0a18b0c85a85cf71 (patch) | |
tree | 6630b124f88341da91660dabee82985c38e506a9 /test/functional/p2p_addrv2_relay.py | |
parent | 80f64a3d40779d342b740fbc57474e170b102678 (diff) |
test: cover TorV3 address in p2p_addrv2_relay
Diffstat (limited to 'test/functional/p2p_addrv2_relay.py')
-rwxr-xr-x | test/functional/p2p_addrv2_relay.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/test/functional/p2p_addrv2_relay.py b/test/functional/p2p_addrv2_relay.py index 9ab190871f..f9a8c44be2 100755 --- a/test/functional/p2p_addrv2_relay.py +++ b/test/functional/p2p_addrv2_relay.py @@ -20,19 +20,24 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal I2P_ADDR = "c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p" +ONION_ADDR = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion" ADDRS = [] for i in range(10): addr = CAddress() addr.time = int(time.time()) + i + addr.port = 8333 + i addr.nServices = P2P_SERVICES - # Add one I2P address at an arbitrary position. + # Add one I2P and one onion V3 address at an arbitrary position. if i == 5: addr.net = addr.NET_I2P addr.ip = I2P_ADDR + addr.port = 0 + elif i == 8: + addr.net = addr.NET_TORV3 + addr.ip = ONION_ADDR else: addr.ip = f"123.123.123.{i % 256}" - addr.port = 8333 + i ADDRS.append(addr) @@ -52,6 +57,17 @@ class AddrReceiver(P2PInterface): self.wait_until(lambda: "addrv2" in self.last_message) +def calc_addrv2_msg_size(addrs): + size = 1 # vector length byte + for addr in addrs: + size += 4 # time + size += 1 # services, COMPACTSIZE(P2P_SERVICES) + size += 1 # network id + size += 1 # address length byte + size += addr.ADDRV2_ADDRESS_LENGTH[addr.net] # address + size += 2 # port + return size + class AddrTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True @@ -71,9 +87,10 @@ class AddrTest(BitcoinTestFramework): self.log.info('Check that addrv2 message content is relayed and added to addrman') addr_receiver = self.nodes[0].add_p2p_connection(AddrReceiver()) msg.addrs = ADDRS + msg_size = calc_addrv2_msg_size(ADDRS) with self.nodes[0].assert_debug_log([ - 'received: addrv2 (159 bytes) peer=0', - 'sending addrv2 (159 bytes) peer=1', + f'received: addrv2 ({msg_size} bytes) peer=0', + f'sending addrv2 ({msg_size} bytes) peer=1', ]): addr_source.send_and_ping(msg) self.nodes[0].setmocktime(int(time.time()) + 30 * 60) |