chainsyncer/tests/test_mem.py

33 lines
895 B
Python
Raw Normal View History

2021-09-27 20:37:13 +02:00
# standard imports
import unittest
import logging
2021-09-27 20:37:13 +02:00
# external imports
from chainlib.chain import ChainSpec
# local imports
from chainsyncer.backend.memory import MemBackend
# testutil imports
from tests.chainsyncer_base import TestBase
logging.basicConfig(level=logging.DEBUG)
2021-09-27 20:37:13 +02:00
class TestMem(TestBase):
def test_backend_mem_custom(self):
chain_spec = ChainSpec('evm', 'bloxberg', 8996, 'foo')
flags = int(5).to_bytes(2, 'big')
flag_count = 10
flags_target = (2 ** 10) - 1
2021-09-27 20:37:13 +02:00
backend = MemBackend.custom(chain_spec, 666, 42, 2, flags, flag_count, object_id='xyzzy')
self.assertEqual(((42, 2), flags), backend.start())
self.assertEqual(((42, 2), flags), backend.get())
self.assertEqual((666, flags_target), backend.target())
2021-09-27 20:37:13 +02:00
self.assertEqual(backend.object_id, 'xyzzy')
if __name__ == '__main__':
unittest.main()