From 1eabba00a853076ed2214fb5458b4e624af0f123 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 6 May 2022 12:52:40 +0000 Subject: [PATCH] add ethkey dependency test --- test/gentest.py | 9 +++++++-- test/include/common.py | 10 ++++++++++ test/unit_tests_d/ut_testdep.py | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/test/gentest.py b/test/gentest.py index fd61ed29..f3e174a4 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -28,7 +28,7 @@ sys.path.insert(0,overlay_setup(repo_root)) # Import these _after_ local path's been added to sys.path from mmgen.common import * -from test.include.common import getrand +from test.include.common import getrand,get_ethkey results_file = 'gentest.out.json' @@ -166,8 +166,13 @@ class GenTool(object): class GenToolEthkey(GenTool): desc = 'ethkey' + + def __init__(self,*args,**kwargs): + self.cmdname = get_ethkey() + return super().__init__(*args,**kwargs) + def run(self,sec,vcoin): - o = get_cmd_output(['ethkey','info',sec.hex()]) + o = get_cmd_output([self.cmdname,'info',sec.hex()]) return gtr( o[0].split()[1], o[-1].split()[1], diff --git a/test/include/common.py b/test/include/common.py index 68598549..d7892feb 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -249,3 +249,13 @@ def check_solc_ver(): omsg(yellow('Warning: Solidity compiler (solc) could not be executed or has unsupported version')) 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 + else: + die(1,f'ethkey executable not found (tried {cmdnames})') diff --git a/test/unit_tests_d/ut_testdep.py b/test/unit_tests_d/ut_testdep.py index 5ae90c42..a0ae645a 100755 --- a/test/unit_tests_d/ut_testdep.py +++ b/test/unit_tests_d/ut_testdep.py @@ -48,7 +48,8 @@ class unit_tests: return True def ethkey(self,name,ut): - res = run(['ethkey','generate','random'],stdout=PIPE) + from test.include.common import get_ethkey + get_ethkey() return True def ssh_socks_proxy(self,name,ut):