From 5a1a36bf7960e09c2b1dd30feb00b7ee26eea93d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 15 Sep 2026 10:51:04 +0000 Subject: [PATCH] cmdtest.py regtest: deterministic testing fixes --- mmgen/proto/btc/regtest.py | 4 ++-- test/cmdtest_d/regtest.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mmgen/proto/btc/regtest.py b/mmgen/proto/btc/regtest.py index aedb2265..8c1246e2 100755 --- a/mmgen/proto/btc/regtest.py +++ b/mmgen/proto/btc/regtest.py @@ -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') diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 49901277..5bfe08bb 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -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):