common.py 877 B

123456789101112131415161718192021222324252627
  1. import os
  2. from .common_orig import *
  3. if os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC'):
  4. def _time_gen():
  5. """ add a minute to each successive time value """
  6. for i in range(1000000):
  7. yield 1321009871 + (i*60)
  8. _time_iter = _time_gen()
  9. TwCommon.date_formatter = {
  10. 'days': lambda rpc,secs: (next(_time_iter) - secs) // 86400,
  11. 'date': lambda rpc,secs: '{}-{:02}-{:02}'.format(*time.gmtime(next(_time_iter))[:3])[2:],
  12. 'date_time': lambda rpc,secs: '{}-{:02}-{:02} {:02}:{:02}'.format(*time.gmtime(next(_time_iter))[:5]),
  13. }
  14. if os.getenv('MMGEN_BOGUS_WALLET_DATA'):
  15. async def fake_set_dates(foo,rpc,us):
  16. for o in us:
  17. o.date = 1831006505 - int(9.7 * 60 * (o.confs - 1))
  18. TwCommon.set_dates = fake_set_dates
  19. # 1831006505 (09 Jan 2028) = projected time of block 1000000
  20. TwCommon.date_formatter['days'] = lambda rpc,secs: (1831006505 - secs) // 86400