Skip to content

test: set default delay to 0.05s for wait_until in functional tests #6631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/functional/feature_mnehf.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def check_ehf_activated(self):
self.bump_mocktime(1)
self.generate(self.nodes[1], 1)
return get_bip9_details(self.nodes[0], 'testdummy')['status'] == 'active'
self.wait_until(lambda: check_ehf_activated(self))
self.wait_until(lambda: check_ehf_activated(self), sleep=1)

if __name__ == '__main__':
MnehfTest().main()
30 changes: 11 additions & 19 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def _initialize_mocktime(self, is_genesis):
for node in self.nodes:
node.mocktime = self.mocktime

def wait_until(self, test_function, timeout=60, lock=None, sleep=0.5, do_assert=True):
def wait_until(self, test_function, timeout=60, lock=None, sleep=0.05, 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.
Expand Down Expand Up @@ -1677,7 +1677,7 @@ 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:])
self.wait_until(check_sporks_same, timeout=timeout, sleep=0.5)
self.wait_until(check_sporks_same, timeout=timeout, sleep=1)

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():
Expand Down Expand Up @@ -1799,26 +1799,18 @@ def check_dkg_comitments():

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_for_quorum_list(self, quorum_hash, nodes, timeout=15, llmq_type_name="llmq_test"):
def wait_func():
self.log.info("quorums: " + str(self.nodes[0].quorum("list")))
if quorum_hash in self.nodes[0].quorum("list")[llmq_type_name]:
return True
self.bump_mocktime(sleep, nodes=nodes)
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
return False
self.wait_until(wait_func, timeout=timeout, sleep=sleep)
return quorum_hash in self.nodes[0].quorum('list')[llmq_type_name]
self.log.info(f"quorums: {self.nodes[0].quorum('list')}")
self.wait_until(wait_func, timeout=timeout, sleep=0.05)

def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test", timeout=15, sleep=2):
def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test", timeout=15):
def wait_func():
self.log.info("h("+str(self.nodes[0].getblockcount())+") quorums: " + str(self.nodes[0].quorum("list")))
if quorum_hash_0 in self.nodes[0].quorum("list")[llmq_type_name]:
if quorum_hash_1 in self.nodes[0].quorum("list")[llmq_type_name]:
return True
self.bump_mocktime(sleep, nodes=nodes)
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
return False
self.wait_until(wait_func, timeout=timeout, sleep=sleep)
quorums = self.nodes[0].quorum("list")[llmq_type_name]
return quorum_hash_0 in quorums and quorum_hash_1 in quorums
self.log.info(f"h({self.nodes[0].getblockcount()}) quorums: {self.nodes[0].quorum('list')}")
self.wait_until(wait_func, timeout=timeout, sleep=0.05)

def move_blocks(self, nodes, num_blocks):
self.bump_mocktime(1, nodes=nodes)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def satoshi_round(amount):
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)


def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.5, timeout_factor=1.0, lock=None, do_assert=True, allow_exception=False):
def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.05, timeout_factor=1.0, lock=None, do_assert=True, allow_exception=False):
"""Sleep until the predicate resolves to be True.

Warning: Note that this method is not recommended to be used in tests as it is
Expand Down
Loading