Skip to content

Commit 12410b1

Browse files
committed
test: fix intermittent p2p_ibd_txrelay race, add test_framework.py#wait_until
1 parent 090d877 commit 12410b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

test/functional/p2p_ibd_txrelay.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from test_framework.messages import COIN
1010
from test_framework.test_framework import BitcoinTestFramework
11-
from test_framework.util import assert_equal
1211

1312
MAX_FEE_FILTER = Decimal(9170997) / COIN
1413
NORMAL_FEE_FILTER = Decimal(100) / COIN
@@ -22,12 +21,12 @@ def set_test_params(self):
2221
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
2322
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
2423
]
24+
2525
def run_test(self):
2626
self.log.info("Check that nodes set minfilter to MAX_MONEY while still in IBD")
2727
for node in self.nodes:
2828
assert node.getblockchaininfo()['initialblockdownload']
29-
for conn_info in node.getpeerinfo():
30-
assert_equal(conn_info['minfeefilter'], MAX_FEE_FILTER)
29+
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
3130

3231
# Come out of IBD by generating a block
3332
self.nodes[0].generate(1)
@@ -36,8 +35,7 @@ def run_test(self):
3635
self.log.info("Check that nodes reset minfilter after coming out of IBD")
3736
for node in self.nodes:
3837
assert not node.getblockchaininfo()['initialblockdownload']
39-
for conn_info in node.getpeerinfo():
40-
assert_equal(conn_info['minfeefilter'], NORMAL_FEE_FILTER)
38+
self.wait_until(lambda: all(peer['minfeefilter'] == NORMAL_FEE_FILTER for peer in node.getpeerinfo()))
4139

4240

4341
if __name__ == '__main__':

test/functional/test_framework/test_framework.py

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
disconnect_nodes,
3232
get_datadir_path,
3333
initialize_datadir,
34+
wait_until,
3435
)
3536

3637

@@ -602,6 +603,9 @@ def sync_all(self, nodes=None):
602603
self.sync_blocks(nodes)
603604
self.sync_mempools(nodes)
604605

606+
def wait_until(self, test_function, timeout=60, lock=None):
607+
return wait_until(test_function, timeout=timeout, lock=lock, timeout_factor=self.options.timeout_factor)
608+
605609
# Private helper methods. These should not be accessed by the subclass test scripts.
606610

607611
def _start_logging(self):

0 commit comments

Comments
 (0)