aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-07-19 08:39:15 +0200
committerJon Atack <jon@atack.com>2020-07-19 13:37:54 +0200
commit12410b1feb80189061eb4a2b43421e53cbb758a8 (patch)
tree247b5c69a3ee31c777ad9cd9d10a1330ba06f9c2 /test
parent090d87716074434bdc6c7656ec44d049197a793a (diff)
downloadbitcoin-12410b1feb80189061eb4a2b43421e53cbb758a8.tar.xz
test: fix intermittent p2p_ibd_txrelay race, add test_framework.py#wait_until
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_ibd_txrelay.py8
-rwxr-xr-xtest/functional/test_framework/test_framework.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/test/functional/p2p_ibd_txrelay.py b/test/functional/p2p_ibd_txrelay.py
index be201e6bc3..c3e758b021 100755
--- a/test/functional/p2p_ibd_txrelay.py
+++ b/test/functional/p2p_ibd_txrelay.py
@@ -8,7 +8,6 @@ from decimal import Decimal
from test_framework.messages import COIN
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_equal
MAX_FEE_FILTER = Decimal(9170997) / COIN
NORMAL_FEE_FILTER = Decimal(100) / COIN
@@ -22,12 +21,12 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
]
+
def run_test(self):
self.log.info("Check that nodes set minfilter to MAX_MONEY while still in IBD")
for node in self.nodes:
assert node.getblockchaininfo()['initialblockdownload']
- for conn_info in node.getpeerinfo():
- assert_equal(conn_info['minfeefilter'], MAX_FEE_FILTER)
+ self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
# Come out of IBD by generating a block
self.nodes[0].generate(1)
@@ -36,8 +35,7 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):
self.log.info("Check that nodes reset minfilter after coming out of IBD")
for node in self.nodes:
assert not node.getblockchaininfo()['initialblockdownload']
- for conn_info in node.getpeerinfo():
- assert_equal(conn_info['minfeefilter'], NORMAL_FEE_FILTER)
+ self.wait_until(lambda: all(peer['minfeefilter'] == NORMAL_FEE_FILTER for peer in node.getpeerinfo()))
if __name__ == '__main__':
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 9d9e065158..8d402d4888 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -31,6 +31,7 @@ from .util import (
disconnect_nodes,
get_datadir_path,
initialize_datadir,
+ wait_until,
)
@@ -602,6 +603,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.sync_blocks(nodes)
self.sync_mempools(nodes)
+ def wait_until(self, test_function, timeout=60, lock=None):
+ return wait_until(test_function, timeout=timeout, lock=lock, timeout_factor=self.options.timeout_factor)
+
# Private helper methods. These should not be accessed by the subclass test scripts.
def _start_logging(self):