mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-27 06:19:09 +01:00
test: Introduce ensure_for helper
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user