Skip to content

Commit

Permalink
Merge #6415: refactor: use self.wait_until in all the dash specific "…
Browse files Browse the repository at this point in the history
…wait_until_x" logic in order to actually apply the timeout scaling settings

3ba6026 refactor: use self.wait_until in all the dash specific "wait_until_x" logic in order to actually apply the timeout scaling settings (pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  Currently we use the raw helper, but that means that timeout scaling isn't applying.. I think this may be a cause of a lot of the functional test failures that we see in tsan / ubsan.

  ## What was done?

  ## How Has This Been Tested?
  hasn't; wait for CI

  ## Breaking Changes

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  knst:
    utACK 3ba6026
  UdjinM6:
    utACK 3ba6026

Tree-SHA512: 935498f4b296b1abcac8be686cce396b61b654ef62da46de9a23a0f24ad31254f4938a581a6a4e2533576db0e0120861fd690bd9019e893b30990f21d1e48168
  • Loading branch information
PastaPastaPasta committed Nov 22, 2024
2 parents 69995ee + 3ba6026 commit f526937
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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

Expand Down Expand Up @@ -195,7 +195,7 @@ def run_test(self):
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")
Expand All @@ -206,7 +206,7 @@ def run_test(self):
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")
Expand All @@ -217,7 +217,7 @@ def run_test(self):
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")
Expand All @@ -233,7 +233,7 @@ def run_test(self):

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)
Expand All @@ -260,7 +260,7 @@ def sync_gov(node):
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")
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_llmq_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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):
Expand Down Expand Up @@ -55,7 +55,7 @@ def wait_for_sigs(hasrecsigs, isconflicting1, isconflicting2, timeout):
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)
Expand Down
34 changes: 17 additions & 17 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def get_peer_ids(from_connection, node_num):

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)
Expand Down Expand Up @@ -893,8 +893,8 @@ 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):
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.

Expand Down Expand Up @@ -1606,7 +1606,7 @@ def check_tx():
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):
Expand Down Expand Up @@ -1638,7 +1638,7 @@ def check_instantlock():
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):
Expand All @@ -1648,22 +1648,22 @@ def check_chainlocked_block():
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):
for node in self.nodes:
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():
Expand Down Expand Up @@ -1702,7 +1702,7 @@ def ret():
# 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():
Expand Down Expand Up @@ -1740,7 +1740,7 @@ def ret():
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():
Expand All @@ -1762,7 +1762,7 @@ def check_dkg_session():
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():
Expand All @@ -1783,7 +1783,7 @@ def check_dkg_comitments():
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():
Expand All @@ -1793,7 +1793,7 @@ def wait_func():
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():
Expand All @@ -1804,7 +1804,7 @@ def wait_func():
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)
Expand Down Expand Up @@ -2039,7 +2039,7 @@ def check_recovered_sig():
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,
Expand Down Expand Up @@ -2100,7 +2100,7 @@ def test_mns():
(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():
Expand All @@ -2110,4 +2110,4 @@ def test():
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)

0 comments on commit f526937

Please sign in to comment.