test.py 660 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. test: functions required by the MMGen test suite
  12. """
  13. import sys
  14. from hashlib import sha256
  15. rand_h = sha256('.'.join(sys.argv).encode())
  16. def fake_urandom(n):
  17. def gen(rounds):
  18. for _ in range(rounds):
  19. rand_h.update(b'foo')
  20. yield rand_h.digest()
  21. return b''.join(gen(int(n/32)+1))[:n]