test: Introduce ensure_for helper

This commit is contained in:
Fabian Jahr
2024-09-12 14:00:08 +02:00
parent e46bebb444
commit 16c87d91fd
7 changed files with 45 additions and 29 deletions

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()