ot_eth_mainnet.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. """
  6. test.objtest_py_d.ot_eth_mainnet: ETH mainnet test vectors for MMGen data objects
  7. """
  8. from decimal import Decimal
  9. from mmgen.obj import ETHNonce
  10. from mmgen.amt import ETHAmt
  11. tests = {
  12. 'ETHAmt': {
  13. 'bad': ('-3.2','0.1234567891234567891',123,'123L',
  14. {'num':'1','from_decimal':True},
  15. {'num':1,'from_decimal':True},
  16. ),
  17. 'good': (('123.123456789123456789',Decimal('123.123456789123456789')),
  18. { 'num':Decimal('1.12345678912345678892345'), # rounding
  19. 'from_decimal':True,
  20. 'ret':Decimal('1.123456789123456789')},
  21. {'num':Decimal('1.234'),'from_decimal':True,'ret':Decimal('1.234')},
  22. {'num':Decimal('0.0'),'from_decimal':True,'ret':Decimal('0')},
  23. {'num':1234,'from_unit':'wei','ret':Decimal('0.000000000000001234')},
  24. {'num':1234,'from_unit':'Mwei','ret':Decimal('0.000000001234')},
  25. )
  26. },
  27. 'ETHNonce': {
  28. 'bad': ('z','я',-1,'-1',0.0,'0.0'),
  29. 'good': (
  30. ('0',0),('1',1),('100',100),1,100,
  31. {'n':'0x0','base':16,'ret':0},
  32. {'n':'0x1','base':16,'ret':1},
  33. {'n':'0xf','base':16,'ret':15},
  34. {'n':'0xff','base':16,'ret':255},
  35. )
  36. },
  37. }