diff --git a/qa/rpc-tests/p2p_txexpiringsoon.py b/qa/rpc-tests/p2p_txexpiringsoon.py index 6472b6fba..4cc4a38c7 100755 --- a/qa/rpc-tests/p2p_txexpiringsoon.py +++ b/qa/rpc-tests/p2p_txexpiringsoon.py @@ -51,7 +51,7 @@ class TxExpiringSoonTest(BitcoinTestFramework): testnode.send_message(msg_mempool()) # Sync up with node after p2p messages delivered - testnode.sync_with_ping() + testnode.sync_with_ping(waiting_for=lambda x: x.last_inv) with mininode_lock: msg = testnode.last_inv diff --git a/qa/rpc-tests/tx_expiry_helper.py b/qa/rpc-tests/tx_expiry_helper.py index 94a6cc2c5..5b6594add 100755 --- a/qa/rpc-tests/tx_expiry_helper.py +++ b/qa/rpc-tests/tx_expiry_helper.py @@ -66,12 +66,13 @@ class TestNode(NodeConnCB): # The following function is mostly copied from p2p-acceptblock.py # Sync up with the node after delivery of a message - def sync_with_ping(self, timeout=30): + def sync_with_ping(self, timeout=30, waiting_for=None): self.connection.send_message(msg_ping(nonce=self.ping_counter)) sleep_time = 0.05 while timeout > 0: with mininode_lock: - if self.last_pong.nonce == self.ping_counter: + ready = True if waiting_for is None else waiting_for(self) is not None + if ready and self.last_pong.nonce == self.ping_counter: self.ping_counter += 1 return time.sleep(sleep_time)