ut_testdep.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python3
  2. """
  3. test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite
  4. """
  5. import os
  6. from subprocess import run,PIPE
  7. from mmgen.cfg import gc
  8. from mmgen.util import ymsg
  9. sec = 'deadbeef' * 8
  10. class unit_tests:
  11. altcoin_deps = ('pycoin','monero_python','keyconv','zcash_mini','ethkey','ssh_socks_proxy')
  12. win_skip = ('losetup','zcash_mini')
  13. def core_repo(self,name,ut):
  14. crr = os.getenv('CORE_REPO_ROOT')
  15. if not crr or not os.path.exists(os.path.join(crr,'src/test/data/tx_valid.json')):
  16. ymsg('CORE_REPO_ROOT not set, or does not point to Bitcoin Core repository')
  17. return False
  18. return True
  19. def losetup(self,name,ut):
  20. os.stat('/dev/loop0')
  21. run(['/sbin/losetup','-f'],check=True,stdout=PIPE)
  22. return True
  23. def pycoin(self,name,ut):
  24. from pycoin.networks.registry import network_for_netcode as nfnc
  25. network = nfnc('btc')
  26. key = network.keys.private(secret_exponent=int(sec,16),is_compressed=True)
  27. hash160_c = key.hash160(is_compressed=True)
  28. network.address.for_p2pkh_wit(hash160_c)
  29. return True
  30. def monero_python(self,name,ut):
  31. from monero.seed import Seed
  32. Seed('deadbeef' * 8).public_address()
  33. return True
  34. def keyconv(self,name,ut):
  35. run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE,check=True)
  36. return True
  37. def zcash_mini(self,name,ut):
  38. run(['zcash-mini'],stdout=PIPE,check=True)
  39. return True
  40. def ethkey(self,name,ut):
  41. if gc.platform == 'linux' and os.uname().machine != 'x86_64':
  42. distro = [l for l in open('/etc/os-release').read().split('\n') if l.startswith('ID=')][0][3:]
  43. if distro != 'archarm':
  44. ut.skip_msg(f'distro {distro!r} on architecture {os.uname().machine!r}')
  45. return True
  46. from test.include.common import get_ethkey
  47. get_ethkey()
  48. return True
  49. def ssh_socks_proxy(self,name,ut):
  50. from test.test_py_d.ts_xmrwallet import TestSuiteXMRWallet
  51. return TestSuiteXMRWallet.init_proxy(external_call=True)