aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_addrv2_relay.py
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-06-11 15:36:07 +0200
committerVasil Dimov <vd@FreeBSD.org>2021-06-11 19:17:59 +0200
commit7593b06bd1262f438bf34769ecc00e9c22328e56 (patch)
treed48be4142d8d115e6d0ee7460ca8bd44774021f8 /test/functional/p2p_addrv2_relay.py
parente7468139a1dddd4946bc70697ec38816b3fa8f9b (diff)
test: ensure I2P addresses are relayed
This test would fail if `CNetAddr::IsRelayable()` returns `false` for I2P addresses, given that this test node does not have I2P connectivity.
Diffstat (limited to 'test/functional/p2p_addrv2_relay.py')
-rwxr-xr-xtest/functional/p2p_addrv2_relay.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/test/functional/p2p_addrv2_relay.py b/test/functional/p2p_addrv2_relay.py
index 5d8101cd33..c006a6c24f 100755
--- a/test/functional/p2p_addrv2_relay.py
+++ b/test/functional/p2p_addrv2_relay.py
@@ -18,12 +18,19 @@ from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
+I2P_ADDR = "c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p"
+
ADDRS = []
for i in range(10):
addr = CAddress()
addr.time = int(time.time()) + i
addr.nServices = NODE_NETWORK | NODE_WITNESS
- addr.ip = "123.123.123.{}".format(i % 256)
+ # Add one I2P address at an arbitrary position.
+ if i == 5:
+ addr.net = addr.NET_I2P
+ addr.ip = I2P_ADDR
+ else:
+ addr.ip = f"123.123.123.{i % 256}"
addr.port = 8333 + i
ADDRS.append(addr)
@@ -35,11 +42,8 @@ class AddrReceiver(P2PInterface):
super().__init__(support_addrv2 = True)
def on_addrv2(self, message):
- for addr in message.addrs:
- assert_equal(addr.nServices, NODE_NETWORK | NODE_WITNESS)
- assert addr.ip.startswith('123.123.123.')
- assert (8333 <= addr.port < 8343)
- self.addrv2_received_and_checked = True
+ if ADDRS == message.addrs:
+ self.addrv2_received_and_checked = True
def wait_for_addrv2(self):
self.wait_until(lambda: "addrv2" in self.last_message)
@@ -64,15 +68,18 @@ class AddrTest(BitcoinTestFramework):
addr_receiver = self.nodes[0].add_p2p_connection(AddrReceiver())
msg.addrs = ADDRS
with self.nodes[0].assert_debug_log([
- 'Added 10 addresses from 127.0.0.1: 0 tried',
- 'received: addrv2 (131 bytes) peer=0',
- 'sending addrv2 (131 bytes) peer=1',
+ # The I2P address is not added to node's own addrman because it has no
+ # I2P reachability (thus 10 - 1 = 9).
+ 'Added 9 addresses from 127.0.0.1: 0 tried',
+ 'received: addrv2 (159 bytes) peer=0',
+ 'sending addrv2 (159 bytes) peer=1',
]):
addr_source.send_and_ping(msg)
self.nodes[0].setmocktime(int(time.time()) + 30 * 60)
addr_receiver.wait_for_addrv2()
assert addr_receiver.addrv2_received_and_checked
+ assert_equal(len(self.nodes[0].getnodeaddresses(count=0, network="i2p")), 0)
if __name__ == '__main__':