ut_testdep.py 1.4 KB

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