ut_testdep.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python3
  2. """
  3. test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite
  4. """
  5. from mmgen.common import *
  6. from subprocess import run,PIPE
  7. sec = 'deadbeef' * 8
  8. class unit_tests:
  9. altcoin_deps = ('pycoin','moneropy','keyconv','zcash_mini','ethkey','ssh_socks_proxy')
  10. win_skip = ('losetup','moneropy','zcash_mini')
  11. arm_skip = ('zcash_mini','ethkey')
  12. def core_repo(self,name,ut):
  13. crr = os.getenv('CORE_REPO_ROOT')
  14. if not crr or not os.path.exists(os.path.join(crr,'src/test/data/tx_valid.json')):
  15. ymsg('CORE_REPO_ROOT not set, or does not point to Bitcoin Core repository')
  16. return False
  17. return True
  18. def losetup(self,name,ut):
  19. os.stat('/dev/loop0')
  20. run(['/sbin/losetup','-f'],check=True,stdout=PIPE)
  21. return True
  22. def pycoin(self,name,ut):
  23. from pycoin.networks.registry import network_for_netcode as nfnc
  24. network = nfnc('btc')
  25. key = network.keys.private(secret_exponent=int(sec,16),is_compressed=True)
  26. hash160_c = key.hash160(is_compressed=True)
  27. addr = network.address.for_p2pkh_wit(hash160_c)
  28. return True
  29. def moneropy(self,name,ut):
  30. from moneropy import account
  31. res = account.account_from_spend_key(sec)
  32. return True
  33. def keyconv(self,name,ut):
  34. res = run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE)
  35. return True
  36. def zcash_mini(self,name,ut):
  37. res = run(['zcash-mini'],stdout=PIPE)
  38. return True
  39. def ethkey(self,name,ut):
  40. from test.include.common import get_ethkey
  41. get_ethkey()
  42. return True
  43. def ssh_socks_proxy(self,name,ut):
  44. from test.test_py_d.ts_xmrwallet import TestSuiteXMRWallet
  45. return TestSuiteXMRWallet.init_proxy(external_call=True)