ut_testdep.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. sec = 'deadbeef' * 8
  7. class unit_tests:
  8. altcoin_deps = ('pycoin','moneropy','keyconv','zcash_mini','ethkey')
  9. win_skip = ('losetup','moneropy','zcash_mini')
  10. arm_skip = ('zcash_mini','ethkey')
  11. def core_repo(self,name,ut):
  12. crr = os.getenv('CORE_REPO_ROOT')
  13. if not crr or not os.path.exists(os.path.join(crr,'src/test/data/tx_valid.json')):
  14. ymsg('CORE_REPO_ROOT not set, or does not point to Bitcoin Core repository')
  15. return False
  16. return True
  17. def losetup(self,name,ut):
  18. os.stat('/dev/loop0')
  19. run(['/sbin/losetup','-f'],check=True,stdout=PIPE)
  20. return True
  21. def pycoin(self,name,ut):
  22. from pycoin.networks.registry import network_for_netcode as nfnc
  23. network = nfnc('btc')
  24. key = network.keys.private(secret_exponent=int(sec,16),is_compressed=True)
  25. hash160_c = key.hash160(is_compressed=True)
  26. addr = network.address.for_p2pkh_wit(hash160_c)
  27. return True
  28. def moneropy(self,name,ut):
  29. from moneropy import account
  30. res = account.account_from_spend_key(sec)
  31. return True
  32. def keyconv(self,name,ut):
  33. res = run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE)
  34. return True
  35. def zcash_mini(self,name,ut):
  36. res = run(['zcash-mini'],stdout=PIPE)
  37. return True
  38. def ethkey(self,name,ut):
  39. res = run(['ethkey','generate','random'],stdout=PIPE)
  40. return True