cmdtest.py regtest: deterministic testing fixes

This commit is contained in:
The MMGen Project 2026-09-15 10:51:04 +00:00
commit 5a1a36bf79
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 8 additions and 9 deletions

View file

@ -210,7 +210,7 @@ class MMGenRegtest(MMGenObject):
# BCH and LTC daemons refuse to set HD seed with empty blockchain ("in IBD" error),
# so generate a block:
await self.generate(1)
await self.generate(1 if self.bdb_wallet else 2) # add a BTC block for sufficient funds
# Unfortunately, we don’t get deterministic output with BCH and LTC even with fixed
# hdseed, as their 'sendtoaddress' calls produce non-deterministic TXIDs due to random
@ -227,7 +227,7 @@ class MMGenRegtest(MMGenObject):
# just enough blocks to fund the test suite.
await self.generate(392)
else:
for _ in range(6): # 120 blocks required for sufficient funds
for _ in range(6): # 120 + 2 blocks required for sufficient funds
await self.generate(20)
gmsg('Setup complete')

View file

@ -1006,19 +1006,19 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
expect2 = rf'[{b58a}]{{8}}' if self.proto.coin == 'BCH' else None)
def bob_txhist3(self):
n1, n2 = (399, 405) if self.rt.bdb_wallet else (127, 133)
n1, n2 = (399, 405) if self.rt.bdb_wallet else (128, 134)
return self.user_txhist('bob',
args = ['sort=blockheight', 'sinceblock=-7', 'age_fmt=block'],
expect = fr'Displaying transactions since block {n1}.*\s6\)\s+{n2}\s.*\s{rtBals[9]}\s.*:L:5.*\s7\)')
def bob_txhist4(self):
n = 406 if self.rt.bdb_wallet else 134
n = 406 if self.rt.bdb_wallet else 135
return self.user_txhist('bob',
args = ['sort=blockheight', 'age_fmt=block', 'detail=1'],
expect = fr'Block:.*{n}.*Value:.*{rtBals[10]}')
def bob_txhist5(self):
n1, n2 = (399, 406) if self.rt.bdb_wallet else (127, 134)
n1, n2 = (399, 406) if self.rt.bdb_wallet else (128, 135)
return self.user_txhist('bob',
args = ['sort=blockheight', f'sinceblock={n1}', 'age_fmt=block', 'detail=1'],
expect = fr'Displaying transactions since block {n1}.*\s7\).*Block:.*{n2}.*Value:.*{rtBals[10]}')
@ -1037,7 +1037,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
for resp in ('u', 'i', 't', 'a', 'm', 'T', 'A', 'r', 'r', 'D', 'D', 'D', 'D', 'p', 'P', 'n', 'V'):
t.expect('draw:\b', resp, regex=True)
if t.pexpect_spawn:
t.expect(r'Block:.*394', regex=True)
t.expect(r'Block:.*{}'.format(394 if self.rt.bdb_wallet else 123), regex=True)
time.sleep(1)
t.send('q')
time.sleep(0.2)
@ -1429,15 +1429,14 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
return t
def bob_rescan_blockchain_all(self):
print(self.rt.bdb_wallet)
n1, n2 = (300, 396) if self.rt.bdb_wallet else (100, 124)
n1, n2 = (300, 396) if self.rt.bdb_wallet else (100, 125)
return self._usr_rescan_blockchain('bob', [], f'{n1}-{n2}')
def bob_rescan_blockchain_gb(self):
return self._usr_rescan_blockchain('bob', ['start_block=0', 'stop_block=0'], '0-0')
def bob_rescan_blockchain_one(self):
n = 300 if self.rt.bdb_wallet else 124
n = 300 if self.rt.bdb_wallet else 125
return self._usr_rescan_blockchain('bob', [f'start_block={n}', f'stop_block={n}'], f'{n}-{n}')
def bob_rescan_blockchain_ss(self):