cic-internal-integration/apps/cic-cache/tests/test_cache.py

57 lines
1.0 KiB
Python
Raw Normal View History

2021-02-18 06:04:30 +01:00
# standard imports
import os
import datetime
import logging
import json
# external imports
2021-02-18 06:04:30 +01:00
import pytest
# local imports
from cic_cache import BloomCache
2021-05-18 19:13:57 +02:00
from cic_cache.cache import DataCache
2021-02-18 06:04:30 +01:00
logg = logging.getLogger()
def test_cache(
init_database,
list_defaults,
list_actors,
list_tokens,
txs,
):
session = init_database
c = BloomCache(session)
b = c.load_transactions(0, 100)
assert b[0] == list_defaults['block'] - 1
c = BloomCache(session)
c.load_transactions_account(list_actors['alice'],0, 100)
assert b[0] == list_defaults['block'] - 1
2021-05-18 19:13:57 +02:00
def test_cache_data(
init_database,
list_defaults,
list_actors,
list_tokens,
txs,
tag_txs,
):
session = init_database
c = DataCache(session)
b = c.load_transactions_with_data(410000, 420000)
assert len(b[2]) == 2
assert b[2][0]['tx_hash'] == txs[1]
assert b[2][1]['tx_type'] == 'unknown'
assert b[2][0]['tx_type'] == 'test.taag'