Browse Source

add ethkey dependency test

The MMGen Project 2 years ago
parent
commit
1eabba00a8
3 changed files with 19 additions and 3 deletions
  1. 7 2
      test/gentest.py
  2. 10 0
      test/include/common.py
  3. 2 1
      test/unit_tests_d/ut_testdep.py

+ 7 - 2
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],

+ 10 - 0
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})')

+ 2 - 1
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):