test suite: support ethkey as alternative to eth-keys
This commit is contained in:
parent
84b0843be3
commit
9e62934151
3 changed files with 42 additions and 9 deletions
|
|
@ -107,7 +107,10 @@ EXAMPLES:
|
|||
SUPPORTED EXTERNAL TOOLS:
|
||||
|
||||
+ eth-keys (for ETH, ETC)
|
||||
https://github.com/ethereum/eth-keys
|
||||
https://github.com/ethereum/eth-keys
|
||||
|
||||
+ ethkey (eth-keys alternative for MSYS2, or if eth-keys is unavailable)
|
||||
https://github.com/openethereum/openethereum/releases/tag/v3.1.0
|
||||
|
||||
+ zcash-mini (for Zcash-Z addresses and view keys)
|
||||
https://github.com/FiloSottile/zcash-mini
|
||||
|
|
@ -166,13 +169,25 @@ class GenToolEth_keys(GenTool):
|
|||
desc = 'eth-keys'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from eth_keys import keys
|
||||
self.keys = keys
|
||||
self.keys = self.cmdname = None
|
||||
try:
|
||||
from eth_keys import keys
|
||||
self.keys = keys
|
||||
except ImportError:
|
||||
self.cmdname = get_ethkey()
|
||||
self.desc = 'ethkey'
|
||||
if not (self.keys or self.cmdname):
|
||||
die(2, 'Neither the ‘eth-keys’ package nor the ‘ethkey’ executable '
|
||||
'could be found on the system!')
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def run(self, sec, vcoin):
|
||||
sk = self.keys.PrivateKey(sec)
|
||||
return gtr(str(sk)[2:], sk.public_key.to_address()[2:], None)
|
||||
if self.keys:
|
||||
sk = self.keys.PrivateKey(sec)
|
||||
return gtr(str(sk)[2:], sk.public_key.to_address()[2:], None)
|
||||
else:
|
||||
o = get_cmd_output([self.cmdname, 'info', sec.hex()])
|
||||
return gtr(o[0].split()[1], o[-1].split()[1], None)
|
||||
|
||||
class GenToolKeyconv(GenTool):
|
||||
desc = 'keyconv'
|
||||
|
|
@ -562,7 +577,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, set_globals
|
||||
from test.include.common import getrand, get_ethkey, set_globals
|
||||
|
||||
gtr = namedtuple('gen_tool_result', ['wif', 'addr', 'viewkey'])
|
||||
sd = namedtuple('saved_data_item', ['reduced', 'wif', 'addr', 'viewkey'])
|
||||
|
|
|
|||
|
|
@ -339,6 +339,18 @@ def check_solc_ver():
|
|||
omsg(res)
|
||||
return False
|
||||
|
||||
def get_ethkey():
|
||||
cmdnames = ('ethkey', 'openethereum-ethkey')
|
||||
for cmdname in cmdnames:
|
||||
try:
|
||||
cp = run([cmdname, '--help'], stdout=PIPE, text=True)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
if 'Parity' in cp.stdout:
|
||||
return cmdname
|
||||
return None
|
||||
|
||||
def do_run(cmd, check=True):
|
||||
return run(cmd, stdout=PIPE, stderr=DEVNULL, check=check)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import os
|
|||
from subprocess import run, DEVNULL
|
||||
|
||||
from mmgen.util import ymsg, bmsg
|
||||
from ..include.common import cfg
|
||||
from ..include.common import cfg, get_ethkey
|
||||
|
||||
sec = 'deadbeef' * 8
|
||||
|
||||
|
|
@ -61,8 +61,14 @@ class unit_tests:
|
|||
return True
|
||||
|
||||
def eth_keys(self, name, ut):
|
||||
from eth_keys import keys
|
||||
return True
|
||||
try:
|
||||
from eth_keys import keys
|
||||
return True
|
||||
except ImportError:
|
||||
if get_ethkey():
|
||||
return True
|
||||
ymsg('Neither the ‘eth-keys’ package nor the Parity ‘ethkey’ executable '
|
||||
'could be found on the system!')
|
||||
|
||||
def ssh_socks_proxy(self, name, ut):
|
||||
from test.cmdtest_d.include.proxy import TestProxy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue