aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-04-29 10:08:06 +0800
committerfanquake <fanquake@gmail.com>2021-04-29 10:08:27 +0800
commit7f37a1d560a86aa0a4397c3dcdaa974337594c00 (patch)
tree08b6113aa49fb19e4fa6fe82b93dbb7531c7a653 /test/functional
parent2cbb4ab7a92a281d7d7b4821654515dd59383ff3 (diff)
parentfaa51ef4d33034f8c14cfd18f1c01c90883a1bb4 (diff)
downloadbitcoin-7f37a1d560a86aa0a4397c3dcdaa974337594c00.tar.xz
Merge bitcoin/bitcoin#21785: test: Fix intermittent issue in p2p_addr_relay.py
faa51ef4d33034f8c14cfd18f1c01c90883a1bb4 test: Fix intermittent issue in p2p_addr_relay.py (MarcoFalke) fa37116c820f6a84642d57ce709a5977fd5616c4 test: Use self.send_addr_msg (MarcoFalke) Pull request description: Fixes https://github.com/bitcoin/bitcoin/pull/21707/files#r621048952 ACKs for top commit: mzumsande: ACK faa51ef4d33034f8c14cfd18f1c01c90883a1bb4 amitiuttarwar: ACK faa51ef4d33034f8c14cfd18f1c01c90883a1bb4 Tree-SHA512: b1fbc1a4a13b020890b465083a82762981de17dd710388c651353aefc28dee23d39803c2a1dadbf88287e92598901afcb01b488115b0fecd746ab6d73775415b
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/p2p_addr_relay.py7
-rwxr-xr-xtest/functional/p2p_blocksonly.py6
-rwxr-xr-xtest/functional/p2p_filter.py3
-rwxr-xr-xtest/functional/test_framework/p2p.py10
4 files changed, 13 insertions, 13 deletions
diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py
index fdd02b7324..87297989ba 100755
--- a/test/functional/p2p_addr_relay.py
+++ b/test/functional/p2p_addr_relay.py
@@ -82,7 +82,7 @@ class AddrTest(BitcoinTestFramework):
self.mocktime += 5 * 60
self.nodes[0].setmocktime(self.mocktime)
for peer in receivers:
- peer.sync_with_ping()
+ peer.sync_send_with_ping()
def oversized_addr_test(self):
self.log.info('Send an addr message that is too large')
@@ -203,10 +203,7 @@ class AddrTest(BitcoinTestFramework):
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()
+ self.send_addr_msg(addr_source, msg, [full_outbound_peer])
assert_equal(full_outbound_peer.num_ipv4_received, 2)
self.nodes[0].disconnect_p2ps()
diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py
index 6584efae79..445cea6186 100755
--- a/test/functional/p2p_blocksonly.py
+++ b/test/functional/p2p_blocksonly.py
@@ -89,11 +89,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
# Bump time forward to ensure nNextInvSend timer pops
self.nodes[0].setmocktime(int(time.time()) + 60)
- # Calling sync_with_ping twice requires that the node calls
- # `ProcessMessage` twice, and thus ensures `SendMessages` must have
- # been called at least once
- conn.sync_with_ping()
- conn.sync_with_ping()
+ conn.sync_send_with_ping()
assert(int(txid, 16) not in conn.get_invs())
def check_p2p_tx_violation(self, index=1):
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py
index 4bee33f825..359cfb9c34 100755
--- a/test/functional/p2p_filter.py
+++ b/test/functional/p2p_filter.py
@@ -174,8 +174,7 @@ class FilterTest(BitcoinTestFramework):
filter_peer.merkleblock_received = False
filter_peer.tx_received = False
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 90)
- filter_peer.sync_with_ping()
- filter_peer.sync_with_ping()
+ filter_peer.sync_send_with_ping()
assert not filter_peer.merkleblock_received
assert not filter_peer.tx_received
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
index 05099f3339..cc80b543cd 100755
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -539,8 +539,16 @@ class P2PInterface(P2PConnection):
self.send_message(message)
self.sync_with_ping(timeout=timeout)
- # Sync up with the node
+ def sync_send_with_ping(self, timeout=60):
+ """Ensure SendMessages is called on this connection"""
+ # Calling sync_with_ping twice requires that the node calls
+ # `ProcessMessage` twice, and thus ensures `SendMessages` must have
+ # been called at least once
+ self.sync_with_ping()
+ self.sync_with_ping()
+
def sync_with_ping(self, timeout=60):
+ """Ensure ProcessMessages is called on this connection"""
self.send_message(msg_ping(nonce=self.ping_counter))
def test_function():