From 2fe18b9b1d54d130fc9cd2c36448be0d6dee7c3d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 7 Apr 2023 18:08:37 +0300 Subject: [PATCH] fix(tests): Bumps in wait_for_tx/instantlock (#5301) ## Issue being fixed or feature implemented 1. we need to move time forward to let invs being relayed 2. nNextInvSend in SendMessages can be bumped up to 30+ seconds into the future in rare cases make sure timeouts in tests are high enough to relay tx inv/wait for corresponding islock ## What was done? tl;dr: bump mocktime while waiting, wait longer extracted fixes from https://github.com/dashpay/dash/pull/5288 but I expect this to fix other sporadic test failures too ## How Has This Been Tested? tests are ok locally and in https://github.com/dashpay/dash/pull/5288 ## Breaking Changes n/a ## Checklist: - [x] 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 **For repository code-owners and collaborators only** - [ ] I have assigned this pull request to a milestone --- test/functional/test_framework/test_framework.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 799142a619..31fc897fbe 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1427,13 +1427,14 @@ class DashTestFramework(BitcoinTestFramework): ret = {**decoded, **ret} return ret - def wait_for_tx(self, txid, node, expected=True, timeout=15): + def wait_for_tx(self, txid, node, expected=True, timeout=60): def check_tx(): try: + self.bump_mocktime(1) return node.getrawtransaction(txid) except: return False - if wait_until(check_tx, timeout=timeout, sleep=0.5, do_assert=expected) and not expected: + if wait_until(check_tx, timeout=timeout, sleep=1, do_assert=expected) and not expected: raise AssertionError("waiting unexpectedly succeeded") def create_islock(self, hextx, deterministic=False): @@ -1466,13 +1467,14 @@ class DashTestFramework(BitcoinTestFramework): return islock - def wait_for_instantlock(self, txid, node, expected=True, timeout=15): + def wait_for_instantlock(self, txid, node, expected=True, timeout=60): def check_instantlock(): + self.bump_mocktime(1) try: return node.getrawtransaction(txid, True)["instantlock"] except: return False - if wait_until(check_instantlock, timeout=timeout, sleep=0.5, do_assert=expected) and not expected: + if 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):