ut_testdep.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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')
  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. res = run(['ethkey','generate','random'],stdout=PIPE)
  41. return True