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
This commit is contained in:
UdjinM6 2023-04-07 18:08:37 +03:00 committed by GitHub
parent cc7be07fb9
commit 2fe18b9b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1427,13 +1427,14 @@ class DashTestFramework(BitcoinTestFramework):
ret = {**decoded, **ret} ret = {**decoded, **ret}
return 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(): def check_tx():
try: try:
self.bump_mocktime(1)
return node.getrawtransaction(txid) return node.getrawtransaction(txid)
except: except:
return False 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") raise AssertionError("waiting unexpectedly succeeded")
def create_islock(self, hextx, deterministic=False): def create_islock(self, hextx, deterministic=False):
@ -1466,13 +1467,14 @@ class DashTestFramework(BitcoinTestFramework):
return islock 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(): def check_instantlock():
self.bump_mocktime(1)
try: try:
return node.getrawtransaction(txid, True)["instantlock"] return node.getrawtransaction(txid, True)["instantlock"]
except: except:
return False 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") raise AssertionError("waiting unexpectedly succeeded")
def wait_for_chainlocked_block(self, node, block_hash, expected=True, timeout=15): def wait_for_chainlocked_block(self, node, block_hash, expected=True, timeout=15):