From 8d314c6abe55e7a6a59f369db08cb68657cbdffb Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 1 Oct 2025 15:30:56 +0000 Subject: [PATCH] cmdtest.py rune, runeswap: make txid mismatches into warnings --- mmgen/exception.py | 1 + mmgen/tx/online.py | 3 ++- test/cmdtest_d/rune.py | 8 ++++++-- test/cmdtest_d/runeswap.py | 10 ++++++++-- test/cmdtest_d/swap.py | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mmgen/exception.py b/mmgen/exception.py index dda7781a..f153c036 100755 --- a/mmgen/exception.py +++ b/mmgen/exception.py @@ -77,6 +77,7 @@ class SwapCfgValueError(Exception): mmcode = 2 # 3: yellow hl, 'MMGen Error' + exception + message class RPCFailure(Exception): mmcode = 3 class RPCChainMismatch(Exception): mmcode = 3 +class TxIDMismatch(Exception): mmcode = 3 class BadTxSizeEstimate(Exception): mmcode = 3 class MaxInputSizeExceeded(Exception): mmcode = 3 class MaxFileSizeExceeded(Exception): mmcode = 3 diff --git a/mmgen/tx/online.py b/mmgen/tx/online.py index ce7c0125..c689a75b 100755 --- a/mmgen/tx/online.py +++ b/mmgen/tx/online.py @@ -126,7 +126,8 @@ class OnlineSigned(Signed): await asyncio.sleep(1) ret = await self.send_with_node(txhex) msg(f'Transaction sent: {coin_txid.hl()}') - assert ret == coin_txid, f'txid mismatch (after sending) ({ret} != {coin_txid})' + if ret != coin_txid: + die('TxIDMismatch', f'txid mismatch (after sending) ({ret} != {coin_txid})') sent_status = 'no_confirm_post_send' if cfg.wait and sent_status: diff --git a/test/cmdtest_d/rune.py b/test/cmdtest_d/rune.py index ac97779e..5d4254ee 100755 --- a/test/cmdtest_d/rune.py +++ b/test/cmdtest_d/rune.py @@ -136,14 +136,18 @@ class CmdTestRune(CmdTestEthdevMethods, CmdTestBase, CmdTestShared): t.expect('can be sent') else: t.expect('to confirm: ', 'YES\n') - t.written_to_file('Sent transaction') + t.expect('Transaction sent: ') + if t.expect(['written to file', 'txid mismatch']): + self.tr.warn('txid mismatch') + return 'ok' return t def txhex1(self): t = self._txsend(add_opts=[f'--dump-hex={self.txhex_file}'], dump_hex=True) t.read() txhex = get_data_from_file(self.cfg, self.txhex_file, silent=True) - assert md5(txhex.encode()).hexdigest()[:8] == self.txhex_chksum + if md5(txhex.encode()).hexdigest()[:8] != self.txhex_chksum: + self.tr.warn('txid mismatch') return t def rpc_server_stop(self): diff --git a/test/cmdtest_d/runeswap.py b/test/cmdtest_d/runeswap.py index 7ab05893..57ec9451 100755 --- a/test/cmdtest_d/runeswap.py +++ b/test/cmdtest_d/runeswap.py @@ -119,7 +119,11 @@ class CmdTestRuneSwapRune(CmdTestSwapMethods, CmdTestRune): return self._swaptxsign() def swaptxsend1(self): - return self._swaptxsend(add_opts=[f'--proxy=localhost:{TestProxy.port}']) + t = self._swaptxsend(add_opts=[f'--proxy=localhost:{TestProxy.port}']) + if t.expect(['written to file', 'txid mismatch']): + self.tr.parent_group.tr.warn('txid mismatch') + return 'ok' + return t def swaptxstatus1(self): return self._swaptxsend(add_opts=['--verbose', '--status'], status=True) @@ -131,5 +135,7 @@ class CmdTestRuneSwapRune(CmdTestSwapMethods, CmdTestRune): t = self._swaptxsend(add_opts=[f'--dump-hex={self.txhex_file}'], dump_hex=True) t.read() txhex = get_data_from_file(self.cfg, self.txhex_file, silent=True) - assert md5(txhex.encode()).hexdigest()[:8] == self.txhex_chksum + if md5(txhex.encode()).hexdigest()[:8] != self.txhex_chksum: + self.tr.parent_group.tr.warn('txid mismatch') + return 'ok' return t diff --git a/test/cmdtest_d/swap.py b/test/cmdtest_d/swap.py index 619d907f..f3809c1e 100755 --- a/test/cmdtest_d/swap.py +++ b/test/cmdtest_d/swap.py @@ -318,6 +318,7 @@ class CmdTestSwapMethods: t = trunner ret = CmdTestRunner(cfg, t.repo_root, t.data_dir, t.trash_dir, t.trash_dir2) ret.init_group(self.cross_group) + ret.parent_group = self return ret class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):