various testing fixes

This commit is contained in:
The MMGen Project 2025-09-09 11:27:05 +00:00
commit 0952cc80a3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
12 changed files with 43 additions and 10 deletions

View file

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

View file

@ -125,8 +125,8 @@ class OnlineSigned(Signed):
if idx != '': if idx != '':
await asyncio.sleep(1) await asyncio.sleep(1)
ret = await self.send_with_node(txhex) 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()}') 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' sent_status = 'no_confirm_post_send'
if cfg.wait and sent_status: if cfg.wait and sent_status:

View file

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

View file

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

View file

@ -118,7 +118,10 @@ class CmdTestHelp(CmdTestBase):
scripts = list(scripts or gc.cmd_caps_data) 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: for cmdname in cmdlist:
cmd_caps = gc.cmd_caps_data[cmdname] cmd_caps = gc.cmd_caps_data[cmdname]

View file

@ -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) return self.check_vals(['--etc-max-tx-fee=0.1'], (('cfg.etc_max_tx_fee', '0.1'),), need_proto=True)
def opt_good30(self): def opt_good30(self):
if self.cfg.no_altcoin:
return 'skip'
return self.check_vals( return self.check_vals(
['--coin=eth', '--eth-mainnet-chain-names=foo,bar'], ['--coin=eth', '--eth-mainnet-chain-names=foo,bar'],
(('cfg.eth_mainnet_chain_names', r"\['foo', 'bar'\]"), ('proto.chain_names', r"\['foo', 'bar'\]")), (('cfg.eth_mainnet_chain_names', r"\['foo', 'bar'\]"), ('proto.chain_names', r"\['foo', 'bar'\]")),
need_proto = True) need_proto = True)
def opt_good31(self): def opt_good31(self):
if self.cfg.no_altcoin:
return 'skip'
return self.check_vals( return self.check_vals(
['--coin=xmr', '--xmr-rpc-port=28081'], ['--coin=xmr', '--xmr-rpc-port=28081'],
(('cfg.xmr_rpc_port', '28081'),('proto.rpc_port', '28081'),), (('cfg.xmr_rpc_port', '28081'),('proto.rpc_port', '28081'),),

View file

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

View file

@ -169,6 +169,8 @@ class unit_tests:
altcoin_deps = ('ltc', 'bch', 'geth', 'reth', 'erigon', 'parity', 'xmrwallet') altcoin_deps = ('ltc', 'bch', 'geth', 'reth', 'erigon', 'parity', 'xmrwallet')
arm_skip = ('parity',) # no prebuilt binaries for ARM 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): async def btc(self, name, ut):
return await run_test( return await run_test(

View file

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

View file

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

View file

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

View file

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