Browse Source

test suite: use `eth-keys` instead of `ethkey`

The MMGen Project 2 months ago
parent
commit
13976084ab
6 changed files with 18 additions and 39 deletions
  1. 1 0
      test-requirements.txt
  2. 2 2
      test/altcointest.py
  3. 9 12
      test/gentest.py
  4. 0 11
      test/include/common.py
  5. 3 9
      test/modtest_d/ut_testdep.py
  6. 3 5
      test/test-release.d/cfg.sh

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

+ 2 - 2
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': {}
 		}
 	}

+ 9 - 12
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'])

+ 0 - 11
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)
 

+ 3 - 9
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):

+ 3 - 5
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="