From acbbe8c9a2a28d5a01869418124a36e628f350b3 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 2 Apr 2024 17:37:37 +0300 Subject: [PATCH 1/5] fix: relayed addresses should use mocktime --- test/functional/p2p_addr_relay.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 7c5bc99387cd..7cc302cb9e09 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -16,17 +16,6 @@ from test_framework.util import ( assert_equal, ) -import time - -ADDRS = [] -for i in range(10): - addr = CAddress() - addr.time = int(time.time()) + i - addr.nServices = NODE_NETWORK - addr.ip = "123.123.123.{}".format(i % 256) - addr.port = 8333 + i - ADDRS.append(addr) - class AddrReceiver(P2PInterface): def on_addr(self, message): @@ -41,6 +30,15 @@ def set_test_params(self): self.num_nodes = 1 def run_test(self): + ADDRS = [] + for i in range(10): + addr = CAddress() + addr.time = int(self.mocktime) + i + addr.nServices = NODE_NETWORK + addr.ip = "123.123.123.{}".format(i % 256) + addr.port = 8333 + i + ADDRS.append(addr) + self.log.info('Create connection that sends addr messages') addr_source = self.nodes[0].add_p2p_connection(P2PInterface()) msg = msg_addr() From 3cd69377b6077f5375e17077923c813c769c3a26 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 2 Apr 2024 17:38:35 +0300 Subject: [PATCH 2/5] fix: test nodes should use mocktime --- test/functional/p2p_addr_relay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 7cc302cb9e09..6e47ea23dba6 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -56,7 +56,7 @@ def run_test(self): 'received: addr (301 bytes) peer=0', ]): addr_source.send_and_ping(msg) - self.nodes[0].setmocktime(int(time.time()) + 30 * 60) + self.bump_mocktime(30 * 60) addr_receiver.sync_with_ping() From 0e78555a5b10d14762ab724ab96948fab33d9201 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 2 Apr 2024 17:38:58 +0300 Subject: [PATCH 3/5] fix: add missing check for sending addrs --- test/functional/p2p_addr_relay.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 6e47ea23dba6..73767241d0a9 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -54,6 +54,7 @@ def run_test(self): with self.nodes[0].assert_debug_log([ 'Added 10 addresses from 127.0.0.1: 0 tried', 'received: addr (301 bytes) peer=0', + 'sending addr (301 bytes) peer=1', ]): addr_source.send_and_ping(msg) self.bump_mocktime(30 * 60) From a39065be88612c715b439f1b68df514ccc803683 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:39:55 +0000 Subject: [PATCH 4/5] test: fix incorrect nServices assertion, use NODE_NETWORK value The value of nServices for `NODE_NETWORK | NODE_WITNESS`, the default for p2p_addr{v2}_relay.py in Bitcoin Core, is 9. Dash doesn't implement SegWit and so the corresponding nServices value is `NODE_NETWORK`, which is 1. --- test/functional/p2p_addr_relay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 73767241d0a9..cea6100ea3ba 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -20,7 +20,7 @@ class AddrReceiver(P2PInterface): def on_addr(self, message): for addr in message.addrs: - assert_equal(addr.nServices, 9) + assert_equal(addr.nServices, 1) assert addr.ip.startswith('123.123.123.') assert (8333 <= addr.port < 8343) From c79f8b5ea2fed66200e7188b53155cda1a9b3fc6 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 2 Apr 2024 18:28:22 +0300 Subject: [PATCH 5/5] fix: keep ADDRS outside --- test/functional/p2p_addr_relay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index cea6100ea3ba..e113545ab449 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -17,6 +17,8 @@ assert_equal, ) +ADDRS = [] + class AddrReceiver(P2PInterface): def on_addr(self, message): for addr in message.addrs: @@ -30,7 +32,6 @@ def set_test_params(self): self.num_nodes = 1 def run_test(self): - ADDRS = [] for i in range(10): addr = CAddress() addr.time = int(self.mocktime) + i