From fe1d7e083aa0a3e019a8bcd8a4d00e610cf8efc4 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 1971431ef7..08b3615933 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1407,13 +1407,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): @@ -1446,13 +1447,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):