From 4c35218fc2e5021198c8e1aecd4b50badd038654 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 26 Sep 2021 21:16:20 +0000 Subject: [PATCH] unit_tests.py: new testdep test --- test/test-release.sh | 4 +-- test/unit_tests_d/ut_dep.py | 1 + test/unit_tests_d/ut_testdep.py | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 test/unit_tests_d/ut_testdep.py diff --git a/test/test-release.sh b/test/test-release.sh index e5df87d7..cc71e60e 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -250,12 +250,12 @@ f_color='Terminal color tests completed' i_dep='Dependency' s_dep='Testing for installed dependencies' -t_dep="- $unit_tests_py dep" +t_dep="- $unit_tests_py testdep dep daemon.exec" f_dep='Dependency tests completed' i_unit='Unit' s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests' -t_unit="- $unit_tests_py --exclude dep" +t_unit="- $unit_tests_py --exclude testdep,dep,daemon" f_unit='Unit tests completed' i_hash='Internal hash function implementations' diff --git a/test/unit_tests_d/ut_dep.py b/test/unit_tests_d/ut_dep.py index 75ab5111..cd4ad2d2 100755 --- a/test/unit_tests_d/ut_dep.py +++ b/test/unit_tests_d/ut_dep.py @@ -11,6 +11,7 @@ from mmgen.common import * class unit_tests: altcoin_deps = ('keccak','py_ecc') + win_skip = ('aiohttp',) def keccak(self,name,ut): # ETH,XMR from sha3 import keccak_256 diff --git a/test/unit_tests_d/ut_testdep.py b/test/unit_tests_d/ut_testdep.py new file mode 100755 index 00000000..047b64ae --- /dev/null +++ b/test/unit_tests_d/ut_testdep.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +""" +test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite +""" + +from mmgen.common import * + +sec = 'deadbeef' * 8 + +class unit_tests: + + altcoin_deps = ('pycoin','moneropy','keyconv','zcash_mini','ethkey') + win_skip = ('losetup',) + + def core_repo(self,name,ut): + crr = os.getenv('CORE_REPO_ROOT') + if not crr or not os.path.exists(os.path.join(crr,'src/test/data/tx_valid.json')): + ymsg('CORE_REPO_ROOT not set, or does not point to Bitcoin Core repository') + return False + return True + + def losetup(self,name,ut): + os.stat('/dev/loop0') + run(['/sbin/losetup','-f'],check=True,stdout=PIPE) + return True + + def pycoin(self,name,ut): + from pycoin.networks.registry import network_for_netcode as nfnc + network = nfnc('btc') + key = network.keys.private(secret_exponent=int(sec,16),is_compressed=True) + hash160_c = key.hash160(is_compressed=True) + addr = network.address.for_p2pkh_wit(hash160_c) + return True + + def moneropy(self,name,ut): + from moneropy import account + res = account.account_from_spend_key(sec) + return True + + def keyconv(self,name,ut): + res = run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE) + return True + + def zcash_mini(self,name,ut): + res = run(['zcash-mini'],stdout=PIPE) + return True + + def ethkey(self,name,ut): + res = run(['ethkey','generate','random'],stdout=PIPE) + return True