diff --git a/mmgen/baseconv.py b/mmgen/baseconv.py index 19f44e6a..da1bf323 100755 --- a/mmgen/baseconv.py +++ b/mmgen/baseconv.py @@ -102,6 +102,7 @@ class baseconv(object): for k,v in list(cls.wl_chksums.items()): res = cls.get_wordlist_chksum(k) assert res == v,'{}: checksum mismatch for {} (should be {})'.format(res,k,v) + return True @classmethod def check_wordlist(cls,wl_id): @@ -109,13 +110,16 @@ class baseconv(object): wl = cls.digits[wl_id] from mmgen.util import qmsg,compare_chksums - qmsg('Wordlist: {}\nLength: {} words'.format(wl_id,len(wl))) + ret = 'Wordlist: {}\nLength: {} words'.format(wl_id,len(wl)) new_chksum = cls.get_wordlist_chksum(wl_id) a,b = 'generated','saved' compare_chksums(new_chksum,a,cls.wl_chksums[wl_id],b,die_on_fail=True) - qmsg('List is sorted') if tuple(sorted(wl)) == wl else die(3,'ERROR: List is not sorted!') + if tuple(sorted(wl)) == wl: + return ret + '\nList is sorted' + else: + die(3,'ERROR: List is not sorted!') @classmethod def get_pad(cls,pad,seed_pad_func): diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 6130a01e..b36c42d7 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -464,12 +464,13 @@ class CoinProtocol(MMGenObject): coin = coin.lower() assert type(testnet) == bool m = "{}: not a valid coin for network {}\nSupported coins: {}" - assert coin in cls.coins, m.format(coin.upper(),g.network.upper(),cls.list_coins()) - return cls.coins[coin][testnet] + assert coin in cls.coins, m.format(coin.upper(),g.network.upper(),' '.join(cls.list_coins())) + proto = cls.coins[coin][testnet] + return proto @classmethod def list_coins(cls): - return ' '.join(c.upper() for c in cls.coins) + return [c.upper() for c in cls.coins] @classmethod def get_base_coin_from_name(cls,name): @@ -557,6 +558,8 @@ def make_init_genonly_altcoins_str(data): def init_coin(coin,testnet=None): if testnet is not None: g.testnet = testnet + g.network = ('mainnet','testnet')[g.testnet] coin = coin.upper() g.coin = coin g.proto = CoinProtocol(coin,g.testnet) + return g.proto diff --git a/mmgen/tool.py b/mmgen/tool.py index d9a37349..c6b7b548 100755 --- a/mmgen/tool.py +++ b/mmgen/tool.py @@ -527,7 +527,6 @@ class MMGenToolCmdMnemonic(MMGenToolCmdBase): def hex2mn( self, hexstr:'sstr', fmt:mn_opts_disp = dfl_mnemonic_fmt ): "convert a 16, 24 or 32-byte hexadecimal number to a mnemonic seed phrase" - opt.out_fmt = self._get_mnemonic_fmt(fmt) if fmt == 'bip39': from mmgen.bip39 import bip39 return ' '.join(bip39.fromhex(hexstr,fmt)) @@ -539,7 +538,6 @@ class MMGenToolCmdMnemonic(MMGenToolCmdBase): def mn2hex( self, seed_mnemonic:'sstr', fmt:mn_opts_disp = dfl_mnemonic_fmt ): "convert a 12, 18 or 24-word mnemonic seed phrase to a hexadecimal number" - in_fmt = self._get_mnemonic_fmt(fmt) if fmt == 'bip39': from mmgen.bip39 import bip39 return bip39.tohex(seed_mnemonic.split(),fmt) @@ -549,8 +547,7 @@ class MMGenToolCmdMnemonic(MMGenToolCmdBase): def mn_stats(self, fmt:mn_opts_disp = dfl_mnemonic_fmt ): "show stats for mnemonic wordlist" conv_cls = mnemonic_fmts[fmt]['conv_cls']() - conv_cls.check_wordlist(fmt) - return True + return conv_cls.check_wordlist(fmt) def mn_printlist( self, fmt:mn_opts_disp = dfl_mnemonic_fmt, enum=False, pager=False ): "print mnemonic wordlist" @@ -896,12 +893,12 @@ class MMGenToolCmdRPC(MMGenToolCmdBase): class MMGenToolCmdMonero(MMGenToolCmdBase): "Monero wallet utilities" - _chain_height = None + _monero_chain_height = None monerod_args = [] @property - def chain_height(self): - if self._chain_height == None: + def monero_chain_height(self): + if self._monero_chain_height == None: from mmgen.daemon import CoinDaemon port = CoinDaemon('xmr',test_suite=g.test_suite).rpc_port cmd = ['monerod','--rpc-bind-port={}'.format(port)] + self.monerod_args + ['status'] @@ -912,10 +909,10 @@ class MMGenToolCmdMonero(MMGenToolCmdBase): m = re.search(r'Height: (\d+)/\d+ ',cp.stdout.decode()) if not m: die(1,'Unable to connect to monerod!') - self._chain_height = int(m.group(1)) - msg('Chain height: {}'.format(self._chain_height)) + self._monero_chain_height = int(m.group(1)) + msg('Chain height: {}'.format(self._monero_chain_height)) - return self._chain_height + return self._monero_chain_height def keyaddrlist2monerowallets( self, xmr_keyaddrfile:str, @@ -962,7 +959,7 @@ class MMGenToolCmdMonero(MMGenToolCmdBase): ymsg("Wallet '{}' does not exist!".format(fn)) return False - chain_height = self.chain_height + chain_height = self.monero_chain_height gmsg(m) import time diff --git a/test/test-release.sh b/test/test-release.sh index b70db5cf..af8e084b 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -305,14 +305,17 @@ t_alts=" f_alts='Gen-only altcoin tests completed' -[ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release* - -if [ "$MSYS2" ]; then - TMPDIR='/tmp/mmgen-test-release' +if [ "$NO_TMPFILE_REMOVAL" ]; then + TMPDIR=$(echo /tmp/mmgen-test-release*) else - TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16) + rm -rf /tmp/mmgen-test-release* + if [ "$MSYS2" ]; then + TMPDIR='/tmp/mmgen-test-release' + else + TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16) + fi + mkdir -p $TMPDIR fi -mkdir -p $TMPDIR i_xmr='Monero' s_xmr='Testing key-address file generation and wallet creation and sync operations for Monero' @@ -439,6 +442,11 @@ f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed' i_tool2='Tooltest2' s_tool2="The following tests will run '$tooltest2_py' for all supported coins" t_tool2=" + $tooltest2_py --tool-api # test the tool_api subsystem + $tooltest2_py --tool-api --testnet=1 + $tooltest2_py --tool-api --coin=eth + $tooltest2_py --tool-api --coin=xmr + $tooltest2_py --tool-api --coin=zec $tooltest2_py --fork # run once with --fork so commands are actually executed $tooltest2_py $tooltest2_py --testnet=1