aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-09-05 12:11:54 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-09-05 12:11:10 +0200
commitfae0b21e6c7a27f08ea8f8b49198c734f923b5da (patch)
tree4d94135215f530b7713cb56f133ea18ef831a0c3
parent260445bee8f003d5dd863d16e1eb2240bb130549 (diff)
downloadbitcoin-fae0b21e6c7a27f08ea8f8b49198c734f923b5da.tar.xz
test: Combine sync_send_with_ping and sync_with_ping
-rwxr-xr-xtest/functional/p2p_addr_relay.py2
-rwxr-xr-xtest/functional/p2p_addrfetch.py2
-rwxr-xr-xtest/functional/p2p_blocksonly.py2
-rwxr-xr-xtest/functional/p2p_compactblocks_blocksonly.py4
-rwxr-xr-xtest/functional/p2p_filter.py2
-rwxr-xr-xtest/functional/p2p_ibd_stalling.py2
-rwxr-xr-xtest/functional/p2p_ibd_txrelay.py2
-rwxr-xr-xtest/functional/test_framework/p2p.py12
8 files changed, 12 insertions, 16 deletions
diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py
index 9e093da051..63cd10896d 100755
--- a/test/functional/p2p_addr_relay.py
+++ b/test/functional/p2p_addr_relay.py
@@ -133,7 +133,7 @@ class AddrTest(BitcoinTestFramework):
self.mocktime += 10 * 60
self.nodes[0].setmocktime(self.mocktime)
for peer in receivers:
- peer.sync_send_with_ping()
+ peer.sync_with_ping()
def oversized_addr_test(self):
self.log.info('Send an addr message that is too large')
diff --git a/test/functional/p2p_addrfetch.py b/test/functional/p2p_addrfetch.py
index 25efd50040..3ead653ba6 100755
--- a/test/functional/p2p_addrfetch.py
+++ b/test/functional/p2p_addrfetch.py
@@ -48,7 +48,7 @@ class P2PAddrFetch(BitcoinTestFramework):
self.assert_getpeerinfo(peer_ids=[peer_id])
self.log.info("Check that we send getaddr but don't try to sync headers with the addr-fetch peer")
- peer.sync_send_with_ping()
+ peer.sync_with_ping()
with p2p_lock:
assert peer.message_count['getaddr'] == 1
assert peer.message_count['getheaders'] == 0
diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py
index 110a1bd03f..637644e6e4 100755
--- a/test/functional/p2p_blocksonly.py
+++ b/test/functional/p2p_blocksonly.py
@@ -101,7 +101,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
# Bump time forward to ensure m_next_inv_send_time timer pops
self.nodes[0].setmocktime(int(time.time()) + 60)
- conn.sync_send_with_ping()
+ conn.sync_with_ping()
assert int(txid, 16) not in conn.get_invs()
def check_p2p_inv_violation(self, peer):
diff --git a/test/functional/p2p_compactblocks_blocksonly.py b/test/functional/p2p_compactblocks_blocksonly.py
index 3d0c421a93..761cd3a218 100755
--- a/test/functional/p2p_compactblocks_blocksonly.py
+++ b/test/functional/p2p_compactblocks_blocksonly.py
@@ -94,11 +94,11 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
block1 = self.build_block_on_tip()
p2p_conn_blocksonly.send_message(msg_headers(headers=[CBlockHeader(block1)]))
- p2p_conn_blocksonly.sync_send_with_ping()
+ p2p_conn_blocksonly.sync_with_ping()
assert_equal(p2p_conn_blocksonly.last_message['getdata'].inv, [CInv(MSG_BLOCK | MSG_WITNESS_FLAG, block1.sha256)])
p2p_conn_high_bw.send_message(msg_headers(headers=[CBlockHeader(block1)]))
- p2p_conn_high_bw.sync_send_with_ping()
+ p2p_conn_high_bw.sync_with_ping()
assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
self.log.info("Test that getdata(CMPCT) is still sent on BIP152 low bandwidth connections"
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py
index 6699cc3528..665f57365f 100755
--- a/test/functional/p2p_filter.py
+++ b/test/functional/p2p_filter.py
@@ -177,7 +177,7 @@ class FilterTest(BitcoinTestFramework):
filter_peer.merkleblock_received = False
filter_peer.tx_received = False
self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=7 * COIN)
- filter_peer.sync_send_with_ping()
+ filter_peer.sync_with_ping()
assert not filter_peer.merkleblock_received
assert not filter_peer.tx_received
diff --git a/test/functional/p2p_ibd_stalling.py b/test/functional/p2p_ibd_stalling.py
index aca98ceb3f..0eb37fa92f 100755
--- a/test/functional/p2p_ibd_stalling.py
+++ b/test/functional/p2p_ibd_stalling.py
@@ -151,7 +151,7 @@ class P2PIBDStallingTest(BitcoinTestFramework):
def all_sync_send_with_ping(self, peers):
for p in peers:
if p.is_connected:
- p.sync_send_with_ping()
+ p.sync_with_ping()
def is_block_requested(self, peers, hash):
for p in peers:
diff --git a/test/functional/p2p_ibd_txrelay.py b/test/functional/p2p_ibd_txrelay.py
index 65a94ad31c..b93e39a925 100755
--- a/test/functional/p2p_ibd_txrelay.py
+++ b/test/functional/p2p_ibd_txrelay.py
@@ -53,7 +53,7 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):
peer_inver.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)]))
# The node should not send a getdata, but if it did, it would first delay 2 seconds
self.nodes[0].setmocktime(int(time.time() + NONPREF_PEER_TX_DELAY))
- peer_inver.sync_send_with_ping()
+ peer_inver.sync_with_ping()
with p2p_lock:
assert txid not in peer_inver.getdata_requests
self.nodes[0].disconnect_p2ps()
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
index d9c7f9f390..ceb4bbd7de 100755
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -558,16 +558,12 @@ class P2PInterface(P2PConnection):
self.send_message(message)
self.sync_with_ping(timeout=timeout)
- 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
+ def sync_with_ping(self, timeout=60):
+ """Ensure ProcessMessages and SendMessages is called on this connection"""
+ # Sending two pings back-to-back, 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=0))
self.send_message(msg_ping(nonce=self.ping_counter))
def test_function():