Browse Source

cmdtest.py rune, runeswap: make txid mismatches into warnings

The MMGen Project 2 months ago
parent
commit
8d314c6abe
5 changed files with 18 additions and 5 deletions
  1. 1 0
      mmgen/exception.py
  2. 2 1
      mmgen/tx/online.py
  3. 6 2
      test/cmdtest_d/rune.py
  4. 8 2
      test/cmdtest_d/runeswap.py
  5. 1 0
      test/cmdtest_d/swap.py

+ 1 - 0
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

+ 2 - 1
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:

+ 6 - 2
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):

+ 8 - 2
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

+ 1 - 0
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):