diff --git a/test/functional/feature_governance.py b/test/functional/feature_governance.py index 43c49784d2..670048735f 100755 --- a/test/functional/feature_governance.py +++ b/test/functional/feature_governance.py @@ -9,7 +9,7 @@ import json from test_framework.messages import uint256_to_string from test_framework.test_framework import DashTestFramework from test_framework.governance import have_trigger_for_height, prepare_object -from test_framework.util import assert_equal, satoshi_round, wait_until_helper +from test_framework.util import assert_equal, satoshi_round GOVERNANCE_UPDATE_MIN = 60 * 60 # src/governance/object.h @@ -195,7 +195,7 @@ class DashGovernanceTest (DashTestFramework): self.wait_until(lambda: len(isolated.gobject("list", "valid", "triggers")) == 1, timeout=5) isolated_trigger_hash = list(isolated.gobject("list", "valid", "triggers").keys())[0] self.wait_until(lambda: list(isolated.gobject("list", "valid", "triggers").values())[0]['YesCount'] == 1, timeout=5) - more_votes = wait_until_helper(lambda: list(isolated.gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False) + more_votes = self.wait_until(lambda: list(isolated.gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False) assert_equal(more_votes, False) self.log.info("Move 1 block enabling the Superblock maturity window on non-isolated nodes") @@ -206,7 +206,7 @@ class DashGovernanceTest (DashTestFramework): self.check_superblockbudget(False) self.log.info("The 'winner' should submit new trigger and vote for it, but it's isolated so no triggers should be found") - has_trigger = wait_until_helper(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) >= 1, timeout=5, do_assert=False) + has_trigger = self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) >= 1, timeout=5, do_assert=False) assert_equal(has_trigger, False) self.log.info("Move 1 block inside the Superblock maturity window on non-isolated nodes") @@ -217,7 +217,7 @@ class DashGovernanceTest (DashTestFramework): self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) == 1, timeout=5) winning_trigger_hash = list(self.nodes[0].gobject("list", "valid", "triggers").keys())[0] self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] == 1, timeout=5) - more_votes = wait_until_helper(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False) + more_votes = self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False) assert_equal(more_votes, False) self.log.info("Make sure amounts aren't trimmed") @@ -233,7 +233,7 @@ class DashGovernanceTest (DashTestFramework): self.log.info("Every non-isolated MN should vote for the same trigger now, no new triggers should be created") self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] == self.mn_count - 1, timeout=5) - more_triggers = wait_until_helper(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) > 1, timeout=5, do_assert=False) + more_triggers = self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) > 1, timeout=5, do_assert=False) assert_equal(more_triggers, False) self.reconnect_isolated_node(payee_idx, 0) @@ -260,7 +260,7 @@ class DashGovernanceTest (DashTestFramework): self.log.info("Should see two triggers now") self.wait_until(lambda: len(isolated.gobject("list", "valid", "triggers")) == 2, timeout=5) self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) == 2, timeout=5) - more_triggers = wait_until_helper(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) > 2, timeout=5, do_assert=False) + more_triggers = self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) > 2, timeout=5, do_assert=False) assert_equal(more_triggers, False) self.log.info("Move another block inside the Superblock maturity window") diff --git a/test/functional/feature_llmq_signing.py b/test/functional/feature_llmq_signing.py index 8206e7dde4..082bfe7e83 100755 --- a/test/functional/feature_llmq_signing.py +++ b/test/functional/feature_llmq_signing.py @@ -13,7 +13,7 @@ Checks LLMQs signing sessions from test_framework.messages import CSigShare, msg_qsigshare, uint256_to_string from test_framework.p2p import P2PInterface from test_framework.test_framework import DashTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, force_finish_mnsync, wait_until_helper +from test_framework.util import assert_equal, assert_raises_rpc_error, force_finish_mnsync class LLMQSigningTest(DashTestFramework): @@ -55,7 +55,7 @@ class LLMQSigningTest(DashTestFramework): self.wait_until(lambda: check_sigs(hasrecsigs, isconflicting1, isconflicting2), timeout = timeout) def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout): - assert not wait_until_helper(lambda: not check_sigs(hasrecsigs, isconflicting1, isconflicting2), timeout = timeout, do_assert = False) + assert not self.wait_until(lambda: not check_sigs(hasrecsigs, isconflicting1, isconflicting2), timeout = timeout, do_assert = False) # Initial state wait_for_sigs(False, False, False, 1) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index a9a063b593..973ab48a9e 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -768,7 +768,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): def isolate_node(self, node_num, timeout=5): self.nodes[node_num].setnetworkactive(False) - wait_until_helper(lambda: self.nodes[node_num].getconnectioncount() == 0, timeout=timeout) + self.wait_until(lambda: self.nodes[node_num].getconnectioncount() == 0, timeout=timeout) def reconnect_isolated_node(self, a, b): self.nodes[a].setnetworkactive(True) @@ -893,8 +893,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): for node in self.nodes: node.mocktime = self.mocktime - def wait_until(self, test_function, timeout=60, lock=None): - return wait_until_helper(test_function, timeout=timeout, lock=lock, timeout_factor=self.options.timeout_factor) + def wait_until(self, test_function, timeout=60, lock=None, sleep=0.5, do_assert=True): + return wait_until_helper(test_function, timeout=timeout, lock=lock, timeout_factor=self.options.timeout_factor, sleep=sleep, do_assert=do_assert) # Private helper methods. These should not be accessed by the subclass test scripts. @@ -1620,7 +1620,7 @@ class DashTestFramework(BitcoinTestFramework): return node.getrawtransaction(txid) except: return False - if wait_until_helper(check_tx, timeout=timeout, sleep=1, do_assert=expected) and not expected: + if self.wait_until(check_tx, timeout=timeout, sleep=1, do_assert=expected) and not expected: raise AssertionError("waiting unexpectedly succeeded") def create_isdlock(self, hextx): @@ -1652,7 +1652,7 @@ class DashTestFramework(BitcoinTestFramework): return node.getrawtransaction(txid, True)["instantlock"] except: return False - if wait_until_helper(check_instantlock, timeout=timeout, sleep=1, do_assert=expected) and not expected: + if self.wait_until(check_instantlock, timeout=timeout, sleep=1, do_assert=expected) and not expected: raise AssertionError("waiting unexpectedly succeeded") def wait_for_chainlocked_block(self, node, block_hash, expected=True, timeout=15): @@ -1662,7 +1662,7 @@ class DashTestFramework(BitcoinTestFramework): return block["confirmations"] > 0 and block["chainlock"] except: return False - if wait_until_helper(check_chainlocked_block, timeout=timeout, sleep=0.1, do_assert=expected) and not expected: + if self.wait_until(check_chainlocked_block, timeout=timeout, sleep=0.1, do_assert=expected) and not expected: raise AssertionError("waiting unexpectedly succeeded") def wait_for_chainlocked_block_all_nodes(self, block_hash, timeout=15, expected=True): @@ -1670,14 +1670,14 @@ class DashTestFramework(BitcoinTestFramework): self.wait_for_chainlocked_block(node, block_hash, expected=expected, timeout=timeout) def wait_for_best_chainlock(self, node, block_hash, timeout=15): - wait_until_helper(lambda: node.getbestchainlock()["blockhash"] == block_hash, timeout=timeout, sleep=0.1) + self.wait_until(lambda: node.getbestchainlock()["blockhash"] == block_hash, timeout=timeout, sleep=0.1) def wait_for_sporks_same(self, timeout=30): def check_sporks_same(): self.bump_mocktime(1) sporks = self.nodes[0].spork('show') return all(node.spork('show') == sporks for node in self.nodes[1:]) - wait_until_helper(check_sporks_same, timeout=timeout, sleep=0.5) + self.wait_until(check_sporks_same, timeout=timeout, sleep=0.5) def wait_for_quorum_connections(self, quorum_hash, expected_connections, mninfos, llmq_type_name="llmq_test", timeout = 60, wait_proc=None): def check_quorum_connections(): @@ -1716,7 +1716,7 @@ class DashTestFramework(BitcoinTestFramework): # no sessions at all - not ok return ret() - wait_until_helper(check_quorum_connections, timeout=timeout, sleep=1) + self.wait_until(check_quorum_connections, timeout=timeout, sleep=1) def wait_for_masternode_probes(self, quorum_hash, mninfos, timeout = 30, wait_proc=None, llmq_type_name="llmq_test"): def check_probes(): @@ -1754,7 +1754,7 @@ class DashTestFramework(BitcoinTestFramework): return ret() return True - wait_until_helper(check_probes, timeout=timeout, sleep=1) + self.wait_until(check_probes, timeout=timeout, sleep=1) def wait_for_quorum_phase(self, quorum_hash, phase, expected_member_count, check_received_messages, check_received_messages_count, mninfos, llmq_type_name="llmq_test", timeout=30, sleep=0.5): def check_dkg_session(): @@ -1776,7 +1776,7 @@ class DashTestFramework(BitcoinTestFramework): break return member_count >= expected_member_count - wait_until_helper(check_dkg_session, timeout=timeout, sleep=sleep) + self.wait_until(check_dkg_session, timeout=timeout, sleep=sleep) def wait_for_quorum_commitment(self, quorum_hash, nodes, llmq_type=100, timeout=15): def check_dkg_comitments(): @@ -1797,7 +1797,7 @@ class DashTestFramework(BitcoinTestFramework): return False return True - wait_until_helper(check_dkg_comitments, timeout=timeout, sleep=1) + self.wait_until(check_dkg_comitments, timeout=timeout, sleep=1) def wait_for_quorum_list(self, quorum_hash, nodes, timeout=15, sleep=2, llmq_type_name="llmq_test"): def wait_func(): @@ -1807,7 +1807,7 @@ class DashTestFramework(BitcoinTestFramework): self.bump_mocktime(sleep, nodes=nodes) self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes)) return False - wait_until_helper(wait_func, timeout=timeout, sleep=sleep) + self.wait_until(wait_func, timeout=timeout, sleep=sleep) def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test", timeout=15, sleep=2): def wait_func(): @@ -1818,7 +1818,7 @@ class DashTestFramework(BitcoinTestFramework): self.bump_mocktime(sleep, nodes=nodes) self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes)) return False - wait_until_helper(wait_func, timeout=timeout, sleep=sleep) + self.wait_until(wait_func, timeout=timeout, sleep=sleep) def move_blocks(self, nodes, num_blocks): self.bump_mocktime(1, nodes=nodes) @@ -2055,7 +2055,7 @@ class DashTestFramework(BitcoinTestFramework): if not mn.node.quorum("hasrecsig", llmq_type, rec_sig_id, rec_sig_msg_hash): return False return True - wait_until_helper(check_recovered_sig, timeout=timeout, sleep=1) + self.wait_until(check_recovered_sig, timeout=timeout, sleep=1) def get_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100, use_platformsign=False): # Note: recsigs aren't relayed to regular nodes by default, @@ -2116,7 +2116,7 @@ class DashTestFramework(BitcoinTestFramework): (valid, len(mns), quorum_type_in, quorum_hash_in)) return valid == len(mns) - wait_until_helper(test_mns, timeout=timeout, sleep=0.5) + self.wait_until(test_mns, timeout=timeout, sleep=0.5) def wait_for_mnauth(self, node, count, timeout=10): def test(): @@ -2126,4 +2126,4 @@ class DashTestFramework(BitcoinTestFramework): if "verified_proregtx_hash" in p and p["verified_proregtx_hash"] != "": c += 1 return c >= count - wait_until_helper(test, timeout=timeout) + self.wait_until(test, timeout=timeout)