ut_testdep.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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','monero_python','keyconv','zcash_mini','ethkey','ssh_socks_proxy')
  10. win_skip = ('losetup','zcash_mini')
  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 monero_python(self,name,ut):
  29. from monero.seed import Seed
  30. res = Seed('deadbeef' * 8).public_address()
  31. return True
  32. def keyconv(self,name,ut):
  33. res = run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE,check=True)
  34. return True
  35. def zcash_mini(self,name,ut):
  36. res = run(['zcash-mini'],stdout=PIPE,check=True)
  37. return True
  38. def ethkey(self,name,ut):
  39. if gc.platform == 'linux' and os.uname().machine != 'x86_64':
  40. distro = [l for l in open('/etc/os-release').read().split('\n') if l.startswith('ID=')][0][3:]
  41. if distro != 'archarm':
  42. ut.skip_msg('distro {!r} on architecture {!r}'.format( distro, os.uname().machine ))
  43. return True
  44. from test.include.common import get_ethkey
  45. get_ethkey()
  46. return True
  47. def ssh_socks_proxy(self,name,ut):
  48. from test.test_py_d.ts_xmrwallet import TestSuiteXMRWallet
  49. return TestSuiteXMRWallet.init_proxy(external_call=True)