From 13976084abee62ba7c974c37b0b4fb286471553c Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 30 Dec 2024 11:31:39 +0000 Subject: [PATCH] test suite: use `eth-keys` instead of `ethkey` --- test-requirements.txt | 1 + test/altcointest.py | 4 ++-- test/gentest.py | 21 +++++++++------------ test/include/common.py | 11 ----------- test/modtest_d/ut_testdep.py | 12 +++--------- test/test-release.d/cfg.sh | 8 +++----- 6 files changed, 18 insertions(+), 39 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 23b433c4..5da46efd 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,5 @@ pycoin monero +eth_keys pylint==3.1.1 # pylint 3.2.0 fails with import errors for mmgen.term and mmgen.proto.secp256k1.secp256k1 diff --git a/test/altcointest.py b/test/altcointest.py index b9ed0c90..84afcd74 100755 --- a/test/altcointest.py +++ b/test/altcointest.py @@ -414,7 +414,7 @@ class TestCoinInfo(CoinInfo): 'OMC', 'PIGGY', 'PINK', 'PKB', 'PND', 'POT', 'PPC', 'PTC', 'PTS', 'QTUM', 'RBY', 'RDD', 'RIC', 'SCA', 'SDC', 'SKC', 'SPR', 'START', 'SXC', 'TPC', 'UIS', 'UNO', 'VIA', 'VPN', 'VTC', 'WDC', 'WKC', 'WUBS', 'XC', 'XPM', 'YAC', 'ZOOM', 'ZRC'), - 'ethkey': ('ETH', 'ETC'), + 'eth-keys': ('ETH', 'ETC'), 'zcash-mini': ('ZEC',), 'monero-python': ('XMR',), }, @@ -424,7 +424,7 @@ class TestCoinInfo(CoinInfo): 'BCH':'XTN', 'BTC':'XTN', 'LTC':'XLT', 'VIA':'TVI', 'FTC':'FTX', 'DOGE':'XDT', 'DCR':'DCRT' }, - 'ethkey': {}, + 'eth-keys': {}, 'keyconv': {} } } diff --git a/test/gentest.py b/test/gentest.py index 36076682..47a18aef 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -106,9 +106,8 @@ EXAMPLES: SUPPORTED EXTERNAL TOOLS: - + ethkey (for ETH, ETC) - https://github.com/openethereum/openethereum - (build with 'cargo build -p ethkey-cli --release') + + eth-keys (for ETH, ETC) + https://github.com/ethereum/eth-keys + zcash-mini (for Zcash-Z addresses and view keys) https://github.com/FiloSottile/zcash-mini @@ -163,19 +162,17 @@ class GenTool: self.data[key] = sd(**{'reduced':sec.hex()}, **ret._asdict()) return ret -class GenToolEthkey(GenTool): - desc = 'ethkey' +class GenToolEth_keys(GenTool): + desc = 'eth-keys' def __init__(self, *args, **kwargs): - self.cmdname = get_ethkey() + from eth_keys import keys + self.keys = keys super().__init__(*args, **kwargs) def run(self, sec, vcoin): - o = get_cmd_output([self.cmdname, 'info', sec.hex()]) - return gtr( - o[0].split()[1], - o[-1].split()[1], - None) + sk = self.keys.PrivateKey(sec) + return gtr(str(sk)[2:], sk.public_key.to_address()[2:], None) class GenToolKeyconv(GenTool): desc = 'keyconv' @@ -565,7 +562,7 @@ from mmgen.key import PrivKey from mmgen.addr import MMGenAddrType from mmgen.addrgen import KeyGenerator, AddrGenerator from mmgen.keygen import get_backends -from test.include.common import getrand, get_ethkey, set_globals +from test.include.common import getrand, set_globals gtr = namedtuple('gen_tool_result', ['wif', 'addr', 'viewkey']) sd = namedtuple('saved_data_item', ['reduced', 'wif', 'addr', 'viewkey']) diff --git a/test/include/common.py b/test/include/common.py index 4a6e9dc6..750e98da 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -334,17 +334,6 @@ def check_solc_ver(): omsg(res) return False -def get_ethkey(): - cmdnames = ('ethkey', 'openethereum-ethkey') - for cmdname in cmdnames: - try: - run([cmdname, '--help'], stdout=PIPE) - except: - pass - else: - return cmdname - die(1, f'ethkey executable not found (tried {cmdnames})') - def do_run(cmd, check=True): return run(cmd, stdout=PIPE, stderr=DEVNULL, check=check) diff --git a/test/modtest_d/ut_testdep.py b/test/modtest_d/ut_testdep.py index 46accab1..394bd03f 100755 --- a/test/modtest_d/ut_testdep.py +++ b/test/modtest_d/ut_testdep.py @@ -14,7 +14,7 @@ sec = 'deadbeef' * 8 class unit_tests: - altcoin_deps = ('pycoin', 'monero_python', 'keyconv', 'zcash_mini', 'ethkey', 'ssh_socks_proxy') + altcoin_deps = ('pycoin', 'monero_python', 'keyconv', 'zcash_mini', 'eth_keys', 'ssh_socks_proxy') win_skip = ('losetup', 'zcash_mini', 'sudo') mac_skip = ('losetup',) @@ -61,14 +61,8 @@ class unit_tests: run(['zcash-mini'], stdout=DEVNULL, check=True) return True - def ethkey(self, name, ut): - if sys.platform == 'linux' and os.uname().machine != 'x86_64': - distro = [l for l in open('/etc/os-release').read().split('\n') if l.startswith('ID=')][0][3:] - if distro != 'archarm': - ut.skip_msg(f'distro {distro!r} on architecture {os.uname().machine!r}') - return True - from test.include.common import get_ethkey - get_ethkey() + def eth_keys(self, name, ut): + from eth_keys import keys return True def ssh_socks_proxy(self, name, ut): diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index a31ff7c6..21c1386d 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -138,9 +138,9 @@ init_tests() { - # keyconv - $gentest_py --all-coins --type=legacy 1:keyconv $rounds_min - $gentest_py --all-coins --type=compressed 1:keyconv $rounds_min - e # ethkey - e $gentest_py --coin=eth 1:ethkey $rounds10x - e $gentest_py --coin=eth --use-internal-keccak-module 2:ethkey $rounds5x + e # eth-keys + e $gentest_py --coin=eth 1:eth-keys $rounds10x + e $gentest_py --coin=eth --use-internal-keccak-module 2:eth-keys $rounds5x m # monero-python m $gentest_py --coin=xmr 1:monero-python $rounds100x M $gentest_py --coin=xmr all:monero-python $rounds_min # very slow, please be patient! @@ -150,8 +150,6 @@ init_tests() { [ "$MSYS2" ] && t_altgen_skip='z' # no zcash-mini (golang) [ "$ARM32" ] && t_altgen_skip='z e' [ "$FAST" ] && t_altgen_skip+=' M' - # ARM ethkey available only on Arch Linux: - [ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_altgen_skip+=' e' d_help="helpscreens for selected coins" t_help="