Add rpc cache test

This commit is contained in:
lash 2022-03-01 18:45:33 +00:00
parent 50804f4d70
commit 8946dfac77
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -21,6 +21,7 @@ from chainlib.eth.tx import (
)
from chainlib.eth.block import (
block_by_hash,
block_by_number,
Block,
)
from chainlib.eth.address import is_same_address
@ -28,6 +29,7 @@ from hexathon import strip_0x
# local imports
from eth_cache.store.file import FileStore
from eth_cache.rpc import CacheRPC
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@ -136,5 +138,21 @@ class TestCache(EthTesterCase):
self.assertEqual(len(txs), 2)
def test_cache_rpc(self):
rpc = CacheRPC(None, self.store)
o = block_by_hash(self.block.hash)
block_src = self.rpc.do(o)
self.assertEqual(block_src['hash'], self.block.hash)
o = block_by_number(self.block.number)
block_src = self.rpc.do(o)
self.assertEqual(block_src['hash'], self.block.hash)
o = transaction(self.tx.hash)
tx_src = self.rpc.do(o)
self.assertTrue(is_same_address(tx_src['hash'], self.tx.hash))
if __name__ == '__main__':
unittest.main()