commit 8946dfac77d58c00af5bccf3c954d545f2ebf109
parent 50804f4d70dd00831ae909448a54b237abbeed7e
Author: lash <dev@holbrook.no>
Date: Tue, 1 Mar 2022 18:45:33 +0000
Add rpc cache test
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/tests/test_basic.py b/tests/test_basic.py
@@ -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()