test: Introduce ensure_for helper

This commit is contained in:
Fabian Jahr committed 2024-11-13 12:00:16 +01:00
1 parent e46bebb444
commit 16c87d91fd
7 files changed
+45 -29

No files matched your search

+6 -5
View File
@@ -5,11 +5,12 @@
"""Test that the mempool ensures transaction delivery by periodically sending
to peers until a GETDATA is received."""
import time
from test_framework.p2p import P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
ensure_for,
)
from test_framework.wallet import MiniWallet
MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
@@ -83,8 +84,8 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
conn = node.add_p2p_connection(P2PTxInvStore())
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
time.sleep(2) # allow sufficient time for possibility of broadcast
assert_equal(len(conn.get_invs()), 0)
# allow sufficient time for possibility of broadcast
ensure_for(duration=2, f=lambda: len(conn.get_invs()) == 0)
self.disconnect_nodes(0, 1)
node.disconnect_p2ps()