Browse Source

various testing fixes

The MMGen Project 2 months ago
parent
commit
0952cc80a3

+ 1 - 0
mmgen/cfg.py

@@ -86,6 +86,7 @@ class GlobalConstants(Lockable):
 		'walletgen':    _cc(False, False, False, None,     [],      'lmw'),
 		'xmrwallet':    _cc(True,  True,  False, '-rx',    ['rpc'], 'lmw'),
 	}
+	altcoin_cmds = ('swaptxcreate', 'swaptxdo', 'xmrwallet')
 
 	prog_name = os.path.basename(sys.argv[0])
 	prog_id = prog_name.removeprefix(f'{proj_id}-')

+ 1 - 1
mmgen/tx/online.py

@@ -125,8 +125,8 @@ class OnlineSigned(Signed):
 						if idx != '':
 							await asyncio.sleep(1)
 						ret = await self.send_with_node(txhex)
-						assert ret == coin_txid, f'txid mismatch (after sending) ({ret} != {coin_txid})'
 						msg(f'Transaction sent: {coin_txid.hl()}')
+						assert ret == coin_txid, f'txid mismatch (after sending) ({ret} != {coin_txid})'
 					sent_status = 'no_confirm_post_send'
 
 				if cfg.wait and sent_status:

+ 4 - 2
test/cmdtest_d/cfgfile.py

@@ -209,6 +209,10 @@ class CmdTestCfgFile(CmdTestBase):
 		"""
 		ensure that derived classes explicitly set these variables
 		"""
+
+		if self.cfg.no_altcoin:
+			return 'skip'
+
 		d = [
 			'btc_max_tx_fee 1.2345',
 			'eth_max_tx_fee 5.4321',
@@ -224,8 +228,6 @@ class CmdTestCfgFile(CmdTestBase):
 			('ETH', 'True',  '5.4321', True),
 			('ETC', 'None',  '5.4321', False)
 		):
-			if self.cfg.no_altcoin and coin != 'BTC':
-				continue
 			t = self.spawn_test(
 				args = [
 					f'--coin={coin}',

+ 8 - 2
test/cmdtest_d/ethdev.py

@@ -34,6 +34,7 @@ from ..include.common import (
 	cfg,
 	check_solc_ver,
 	omsg,
+	omsg_r,
 	imsg,
 	imsg_r,
 	joinpath,
@@ -305,7 +306,8 @@ class CmdTestEthdevMethods:
 			caller = mmgen_cmd,
 			quiet  = mmgen_cmd == 'txdo' or not self.cfg.debug,
 			contract_addr = contract_addr,
-			bogus_send = False)
+			bogus_send = False,
+			wait = self.name == 'CmdTestEthBump')
 
 		if key == 'Token':
 			imsg(f'\nToken MM{num} deployed!')
@@ -361,11 +363,15 @@ class CmdTestEthdevMethods:
 					gas       = 120000,
 					gasPrice  = self.proto.coin_amt(8, from_unit='Gwei'))
 				rpc = await self.rpc
+				imsg_r('Waiting for transaction receipt: ')
 				for n in range(50): # long delay for txbump
 					rx = await rpc.call('eth_getTransactionReceipt', '0x' + txid) # -> null if pending
 					if rx:
+						imsg('OK')
 						break
 					await asyncio.sleep(0.5)
+					if n % 2:
+						omsg_r('+')
 				if not rx:
 					die(1, 'tx receipt timeout exceeded')
 
@@ -1606,7 +1612,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
 	def token_txdo_cached_balances(self):
 		return self.txdo_cached_balances(
 			acct          = '1',
-			fee_info_data = ('0.00260265', '50'),
+			fee_info_data = (0.0025786 if self.daemon.id == 'parity' else '0.00260265', '50'),
 			add_args      = ['--token=mm1', '98831F3A:E:12,43.21'])
 
 	def token_txcreate_refresh_balances(self):

+ 4 - 1
test/cmdtest_d/help.py

@@ -118,7 +118,10 @@ class CmdTestHelp(CmdTestBase):
 
 		scripts = list(scripts or gc.cmd_caps_data)
 
-		cmdlist = sorted(set(scripts) - self._gen_skiplist(scripts))
+		cmdlist = sorted(
+			set(scripts)
+			- self._gen_skiplist(scripts)
+			- (set(gc.altcoin_cmds if self.cfg.no_altcoin else [])))
 
 		for cmdname in cmdlist:
 			cmd_caps = gc.cmd_caps_data[cmdname]

+ 4 - 0
test/cmdtest_d/opts.py

@@ -293,12 +293,16 @@ class CmdTestOpts(CmdTestBase):
 		return self.check_vals(['--etc-max-tx-fee=0.1'], (('cfg.etc_max_tx_fee', '0.1'),), need_proto=True)
 
 	def opt_good30(self):
+		if self.cfg.no_altcoin:
+			return 'skip'
 		return self.check_vals(
 			['--coin=eth', '--eth-mainnet-chain-names=foo,bar'],
 			(('cfg.eth_mainnet_chain_names', r"\['foo', 'bar'\]"), ('proto.chain_names', r"\['foo', 'bar'\]")),
 			need_proto = True)
 
 	def opt_good31(self):
+		if self.cfg.no_altcoin:
+			return 'skip'
 		return self.check_vals(
 			['--coin=xmr', '--xmr-rpc-port=28081'],
 			(('cfg.xmr_rpc_port', '28081'),('proto.rpc_port', '28081'),),

+ 8 - 1
test/cmdtest_d/shared.py

@@ -166,7 +166,8 @@ class CmdTestShared:
 			test         = False,
 			quiet        = False,
 			contract_addr = None,
-			has_label    = False):
+			has_label    = False,
+			wait         = False):
 
 		txdo = (caller or self.test_name)[:4] == 'txdo'
 
@@ -190,6 +191,12 @@ class CmdTestShared:
 			assert len(txid) == 64, f'{txid!r}: Incorrect txid length!'
 
 		if not test:
+			if wait:
+				t.expect('Waiting for first confirmation..')
+				while True:
+					if t.expect(['.', 'OK']):
+						break
+
 			if contract_addr:
 				_ = strip_ansi_escapes(t.expect_getend('Contract address: '))
 				assert _ == contract_addr, f'Contract address mismatch: {_} != {contract_addr}'

+ 2 - 0
test/daemontest_d/rpc.py

@@ -169,6 +169,8 @@ class unit_tests:
 
 	altcoin_deps = ('ltc', 'bch', 'geth', 'reth', 'erigon', 'parity', 'xmrwallet')
 	arm_skip = ('parity',) # no prebuilt binaries for ARM
+	riscv_skip = ('parity',) # no prebuilt binaries for RISC-V
+	fast_skip = ('reth', 'erigon')
 
 	async def btc(self, name, ut):
 		return await run_test(

+ 9 - 1
test/include/unit_test.py

@@ -211,7 +211,7 @@ def run_test(test, subtest=None):
 		tests_seen.append(test)
 
 	if cfg.no_altcoin_deps and test in altcoin_tests:
-		cfg._util.qmsg(gray(f'Skipping {test_type} test {test!r} [--no-altcoin-deps]'))
+		msg(gray(f'Skipping {test_type} test {test!r} [--no-altcoin-deps]'))
 		return
 
 	mod = importlib.import_module(f'test.{test_subdir}.{test}')
@@ -222,6 +222,8 @@ def run_test(test, subtest=None):
 		win_skip = getattr(t, 'win_skip', ())
 		mac_skip = getattr(t, 'mac_skip', ())
 		arm_skip = getattr(t, 'arm_skip', ())
+		riscv_skip = getattr(t, 'riscv_skip', ())
+		fast_skip = getattr(t, 'fast_skip', ())
 		subtests = (
 			[subtest] if subtest else
 			[k for k, v in type(t).__dict__.items() if type(v).__name__ == 'function' and k[0] != '_']
@@ -238,6 +240,9 @@ def run_test(test, subtest=None):
 			if cfg.no_altcoin_deps and _subtest in altcoin_deps:
 				subtest_skip_msg(_subtest, '[--no-altcoin-deps]')
 				continue
+			if cfg.fast and _subtest in fast_skip:
+				subtest_skip_msg(_subtest, '[--fast]')
+				continue
 			if sys.platform == 'win32' and _subtest in win_skip:
 				subtest_skip_msg(_subtest, 'for Windows platform')
 				continue
@@ -247,6 +252,9 @@ def run_test(test, subtest=None):
 			if platform.machine() == 'aarch64' and _subtest in arm_skip:
 				subtest_skip_msg(_subtest, 'for ARM platform')
 				continue
+			if platform.machine() == 'riscv64' and _subtest in riscv_skip:
+				subtest_skip_msg(_subtest, 'for RISC-V platform')
+				continue
 			run_subtest(t, _subtest)
 		if hasattr(t, '_post'):
 			t._post()

+ 1 - 1
test/modtest_d/__init__.py

@@ -4,4 +4,4 @@
 test.modtest_d: shared data for unit tests for the MMGen suite
 """
 
-altcoin_tests = ['cashaddr', 'rune', 'xmrseed']
+altcoin_tests = ['cashaddr', 'rune', 'xmrseed', 'swap']

+ 0 - 1
test/test-release.d/cfg.sh

@@ -190,7 +190,6 @@ init_tests() {
 		- $cmdtest_py misc
 		- $cmdtest_py opts
 		- $cmdtest_py cfgfile
-		- $cmdtest_py help
 		- $cmdtest_py main
 		- $cmdtest_py conv
 		- $cmdtest_py ref

+ 1 - 0
test/test-release.sh

@@ -380,6 +380,7 @@ do
 done
 
 in_nix_environment && parity --help >/dev/null 2>&1 || SKIP_PARITY=1
+[ "$RISCV64" ] && SKIP_PARITY=1
 
 [ "$MMGEN_DISABLE_COLOR" -o ! -t 1 ] || {
 	GRAY="\e[30;1m"