Rehabilitate tests after url format change
This commit is contained in:
parent
3a52a78e93
commit
15618fa061
@ -1,2 +0,0 @@
|
|||||||
[bancor]
|
|
||||||
dir =
|
|
@ -1,4 +1,3 @@
|
|||||||
[cic]
|
[cic]
|
||||||
registry_address =
|
registry_address =
|
||||||
chain_spec =
|
|
||||||
trust_address =
|
trust_address =
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[database]
|
[database]
|
||||||
NAME=cic-cache-test
|
PREFIX=cic-cache-test
|
||||||
USER=postgres
|
USER=postgres
|
||||||
PASSWORD=
|
PASSWORD=
|
||||||
HOST=localhost
|
HOST=localhost
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
[eth]
|
|
||||||
#ws_provider = ws://localhost:8546
|
|
||||||
#ttp_provider = http://localhost:8545
|
|
||||||
provider = http://localhost:8545
|
|
||||||
#chain_id =
|
|
@ -2,7 +2,7 @@ alembic==1.4.2
|
|||||||
confini~=0.5.3
|
confini~=0.5.3
|
||||||
uwsgi==2.0.19.1
|
uwsgi==2.0.19.1
|
||||||
moolb~=0.2.0
|
moolb~=0.2.0
|
||||||
cic-eth-registry~=0.6.3
|
cic-eth-registry~=0.6.5
|
||||||
SQLAlchemy==1.3.20
|
SQLAlchemy==1.3.20
|
||||||
semver==2.13.0
|
semver==2.13.0
|
||||||
psycopg2==2.8.6
|
psycopg2==2.8.6
|
||||||
|
@ -6,6 +6,7 @@ import datetime
|
|||||||
# external imports
|
# external imports
|
||||||
import pytest
|
import pytest
|
||||||
import moolb
|
import moolb
|
||||||
|
from chainlib.encode import TxHexNormalizer
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_cache import db
|
from cic_cache import db
|
||||||
@ -42,6 +43,8 @@ def txs(
|
|||||||
list_tokens,
|
list_tokens,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
tx_normalize = TxHexNormalizer()
|
||||||
|
|
||||||
session = init_database
|
session = init_database
|
||||||
|
|
||||||
tx_number = 13
|
tx_number = 13
|
||||||
@ -54,10 +57,10 @@ def txs(
|
|||||||
tx_hash_first,
|
tx_hash_first,
|
||||||
list_defaults['block'],
|
list_defaults['block'],
|
||||||
tx_number,
|
tx_number,
|
||||||
list_actors['alice'],
|
tx_normalize.wallet_address(list_actors['alice']),
|
||||||
list_actors['bob'],
|
tx_normalize.wallet_address(list_actors['bob']),
|
||||||
list_tokens['foo'],
|
tx_normalize.executable_address(list_tokens['foo']),
|
||||||
list_tokens['foo'],
|
tx_normalize.executable_address(list_tokens['foo']),
|
||||||
1024,
|
1024,
|
||||||
2048,
|
2048,
|
||||||
True,
|
True,
|
||||||
@ -74,10 +77,10 @@ def txs(
|
|||||||
tx_hash_second,
|
tx_hash_second,
|
||||||
list_defaults['block']-1,
|
list_defaults['block']-1,
|
||||||
tx_number,
|
tx_number,
|
||||||
list_actors['diane'],
|
tx_normalize.wallet_address(list_actors['diane']),
|
||||||
list_actors['alice'],
|
tx_normalize.wallet_address(list_actors['alice']),
|
||||||
list_tokens['foo'],
|
tx_normalize.executable_address(list_tokens['foo']),
|
||||||
list_tokens['foo'],
|
tx_normalize.wallet_address(list_tokens['foo']),
|
||||||
1024,
|
1024,
|
||||||
2048,
|
2048,
|
||||||
False,
|
False,
|
||||||
@ -103,6 +106,8 @@ def more_txs(
|
|||||||
|
|
||||||
session = init_database
|
session = init_database
|
||||||
|
|
||||||
|
tx_normalize = TxHexNormalizer()
|
||||||
|
|
||||||
tx_number = 666
|
tx_number = 666
|
||||||
tx_hash = '0x' + os.urandom(32).hex()
|
tx_hash = '0x' + os.urandom(32).hex()
|
||||||
tx_signed = '0x' + os.urandom(128).hex()
|
tx_signed = '0x' + os.urandom(128).hex()
|
||||||
@ -115,10 +120,10 @@ def more_txs(
|
|||||||
tx_hash,
|
tx_hash,
|
||||||
list_defaults['block']+2,
|
list_defaults['block']+2,
|
||||||
tx_number,
|
tx_number,
|
||||||
list_actors['alice'],
|
tx_normalize.wallet_address(list_actors['alice']),
|
||||||
list_actors['diane'],
|
tx_normalize.wallet_address(list_actors['diane']),
|
||||||
list_tokens['bar'],
|
tx_normalize.executable_address(list_tokens['bar']),
|
||||||
list_tokens['bar'],
|
tx_normalize.executable_address(list_tokens['bar']),
|
||||||
2048,
|
2048,
|
||||||
4096,
|
4096,
|
||||||
False,
|
False,
|
||||||
|
@ -14,7 +14,8 @@ logg = logging.getLogger(__file__)
|
|||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def load_config():
|
def load_config():
|
||||||
config_dir = os.path.join(root_dir, 'config/test')
|
config_dir = os.path.join(root_dir, 'config/test')
|
||||||
conf = confini.Config(config_dir, 'CICTEST')
|
schema_config_dir = os.path.join(root_dir, 'cic_cache', 'data', 'config')
|
||||||
|
conf = confini.Config(schema_config_dir, 'CICTEST', override_dirs=config_dir)
|
||||||
conf.process()
|
conf.process()
|
||||||
logg.debug('config {}'.format(conf))
|
logg.debug('config {}'.format(conf))
|
||||||
return conf
|
return conf
|
||||||
|
@ -24,11 +24,15 @@ def database_engine(
|
|||||||
if load_config.get('DATABASE_ENGINE') == 'sqlite':
|
if load_config.get('DATABASE_ENGINE') == 'sqlite':
|
||||||
SessionBase.transactional = False
|
SessionBase.transactional = False
|
||||||
SessionBase.poolable = False
|
SessionBase.poolable = False
|
||||||
|
name = 'cic_cache'
|
||||||
|
database_name = name
|
||||||
|
if load_config.get('DATABASE_PREFIX'):
|
||||||
|
database_name = '{}_{}'.format(load_config.get('DATABASE_PREFIX'), database_name)
|
||||||
try:
|
try:
|
||||||
os.unlink(load_config.get('DATABASE_NAME'))
|
os.unlink(database_name)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
dsn = dsn_from_config(load_config)
|
dsn = dsn_from_config(load_config, name)
|
||||||
SessionBase.connect(dsn, debug=load_config.true('DATABASE_DEBUG'))
|
SessionBase.connect(dsn, debug=load_config.true('DATABASE_DEBUG'))
|
||||||
return dsn
|
return dsn
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ def test_api_all_data(
|
|||||||
):
|
):
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
'PATH_INFO': '/txa/410000/420000',
|
'PATH_INFO': '/txa/100/0/410000/420000',
|
||||||
'HTTP_X_CIC_CACHE_MODE': 'all',
|
'HTTP_X_CIC_CACHE_MODE': 'all',
|
||||||
}
|
}
|
||||||
j = process_transactions_all_data(init_database, env)
|
j = process_transactions_all_data(init_database, env)
|
||||||
@ -23,7 +23,7 @@ def test_api_all_data(
|
|||||||
assert len(o['data']) == 2
|
assert len(o['data']) == 2
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
'PATH_INFO': '/txa/420000/410000',
|
'PATH_INFO': '/txa/100/0/420000/410000',
|
||||||
'HTTP_X_CIC_CACHE_MODE': 'all',
|
'HTTP_X_CIC_CACHE_MODE': 'all',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import json
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import pytest
|
import pytest
|
||||||
|
from chainlib.encode import TxHexNormalizer
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_cache import db
|
from cic_cache import db
|
||||||
@ -62,6 +63,8 @@ def test_cache_ranges(
|
|||||||
|
|
||||||
session = init_database
|
session = init_database
|
||||||
|
|
||||||
|
tx_normalize = TxHexNormalizer()
|
||||||
|
|
||||||
oldest = list_defaults['block'] - 1
|
oldest = list_defaults['block'] - 1
|
||||||
mid = list_defaults['block']
|
mid = list_defaults['block']
|
||||||
newest = list_defaults['block'] + 2
|
newest = list_defaults['block'] + 2
|
||||||
@ -100,32 +103,39 @@ def test_cache_ranges(
|
|||||||
assert b[1] == mid
|
assert b[1] == mid
|
||||||
|
|
||||||
# now check when supplying account
|
# now check when supplying account
|
||||||
b = c.load_transactions_account(list_actors['alice'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100)
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
|
|
||||||
b = c.load_transactions_account(list_actors['bob'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['bob'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100)
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == mid
|
assert b[1] == mid
|
||||||
|
|
||||||
b = c.load_transactions_account(list_actors['diane'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['diane'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100)
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
|
|
||||||
# add block filter to the mix
|
# add block filter to the mix
|
||||||
b = c.load_transactions_account(list_actors['alice'], 0, 100, block_offset=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100, block_offset=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
|
|
||||||
b = c.load_transactions_account(list_actors['alice'], 0, 100, block_offset=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100, block_offset=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
|
|
||||||
b = c.load_transactions_account(list_actors['bob'], 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['bob'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == mid
|
assert b[1] == mid
|
||||||
|
|
||||||
b = c.load_transactions_account(list_actors['diane'], 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['diane'])
|
||||||
|
b = c.load_transactions_account(account, 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == oldest
|
assert b[1] == oldest
|
||||||
|
|
||||||
@ -140,6 +150,8 @@ def test_cache_ranges_data(
|
|||||||
|
|
||||||
session = init_database
|
session = init_database
|
||||||
|
|
||||||
|
tx_normalize = TxHexNormalizer()
|
||||||
|
|
||||||
oldest = list_defaults['block'] - 1
|
oldest = list_defaults['block'] - 1
|
||||||
mid = list_defaults['block']
|
mid = list_defaults['block']
|
||||||
newest = list_defaults['block'] + 2
|
newest = list_defaults['block'] + 2
|
||||||
@ -203,7 +215,8 @@ def test_cache_ranges_data(
|
|||||||
assert b[2][1]['tx_hash'] == more_txs[1]
|
assert b[2][1]['tx_hash'] == more_txs[1]
|
||||||
|
|
||||||
# now check when supplying account
|
# now check when supplying account
|
||||||
b = c.load_transactions_account_with_data(list_actors['alice'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100)
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
assert len(b[2]) == 3
|
assert len(b[2]) == 3
|
||||||
@ -211,13 +224,15 @@ def test_cache_ranges_data(
|
|||||||
assert b[2][1]['tx_hash'] == more_txs[1]
|
assert b[2][1]['tx_hash'] == more_txs[1]
|
||||||
assert b[2][2]['tx_hash'] == more_txs[2]
|
assert b[2][2]['tx_hash'] == more_txs[2]
|
||||||
|
|
||||||
b = c.load_transactions_account_with_data(list_actors['bob'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['bob'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100)
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == mid
|
assert b[1] == mid
|
||||||
assert len(b[2]) == 1
|
assert len(b[2]) == 1
|
||||||
assert b[2][0]['tx_hash'] == more_txs[1]
|
assert b[2][0]['tx_hash'] == more_txs[1]
|
||||||
|
|
||||||
b = c.load_transactions_account_with_data(list_actors['diane'], 0, 100)
|
account = tx_normalize.wallet_address(list_actors['diane'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100)
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
assert len(b[2]) == 2
|
assert len(b[2]) == 2
|
||||||
@ -225,27 +240,31 @@ def test_cache_ranges_data(
|
|||||||
assert b[2][1]['tx_hash'] == more_txs[2]
|
assert b[2][1]['tx_hash'] == more_txs[2]
|
||||||
|
|
||||||
# add block filter to the mix
|
# add block filter to the mix
|
||||||
b = c.load_transactions_account_with_data(list_actors['alice'], 0, 100, block_offset=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100, block_offset=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
assert len(b[2]) == 2
|
assert len(b[2]) == 2
|
||||||
assert b[2][0]['tx_hash'] == more_txs[0]
|
assert b[2][0]['tx_hash'] == more_txs[0]
|
||||||
assert b[2][1]['tx_hash'] == more_txs[1]
|
assert b[2][1]['tx_hash'] == more_txs[1]
|
||||||
|
|
||||||
b = c.load_transactions_account_with_data(list_actors['alice'], 0, 100, block_offset=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['alice'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100, block_offset=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == newest
|
assert b[1] == newest
|
||||||
assert len(b[2]) == 2
|
assert len(b[2]) == 2
|
||||||
assert b[2][0]['tx_hash'] == more_txs[0]
|
assert b[2][0]['tx_hash'] == more_txs[0]
|
||||||
assert b[2][1]['tx_hash'] == more_txs[1]
|
assert b[2][1]['tx_hash'] == more_txs[1]
|
||||||
|
|
||||||
b = c.load_transactions_account_with_data(list_actors['bob'], 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['bob'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
||||||
assert b[0] == mid
|
assert b[0] == mid
|
||||||
assert b[1] == mid
|
assert b[1] == mid
|
||||||
assert len(b[2]) == 1
|
assert len(b[2]) == 1
|
||||||
assert b[2][0]['tx_hash'] == more_txs[1]
|
assert b[2][0]['tx_hash'] == more_txs[1]
|
||||||
|
|
||||||
b = c.load_transactions_account_with_data(list_actors['diane'], 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
account = tx_normalize.wallet_address(list_actors['diane'])
|
||||||
|
b = c.load_transactions_account_with_data(account, 0, 100, block_offset=list_defaults['block'] - 1, block_limit=list_defaults['block'])
|
||||||
assert b[0] == oldest
|
assert b[0] == oldest
|
||||||
assert b[1] == oldest
|
assert b[1] == oldest
|
||||||
assert len(b[2]) == 1
|
assert len(b[2]) == 1
|
||||||
|
@ -82,7 +82,7 @@ def test_query_regex(
|
|||||||
[
|
[
|
||||||
('alice', None, None, [(420000, 13), (419999, 42)]),
|
('alice', None, None, [(420000, 13), (419999, 42)]),
|
||||||
('alice', None, 1, [(420000, 13)]),
|
('alice', None, 1, [(420000, 13)]),
|
||||||
('alice', 1, None, [(419999, 42)]), # 420000 == list_defaults['block']
|
('alice', 1, 1, [(419999, 42)]), # 420000 == list_defaults['block']
|
||||||
('alice', 2, None, []), # 420000 == list_defaults['block']
|
('alice', 2, None, []), # 420000 == list_defaults['block']
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -107,10 +107,11 @@ def test_query_process_txs_account(
|
|||||||
path_info = '/tx/user/0x' + strip_0x(actor)
|
path_info = '/tx/user/0x' + strip_0x(actor)
|
||||||
if query_offset != None:
|
if query_offset != None:
|
||||||
path_info += '/' + str(query_offset)
|
path_info += '/' + str(query_offset)
|
||||||
if query_limit != None:
|
if query_limit == None:
|
||||||
if query_offset == None:
|
query_limit = 100
|
||||||
path_info += '/0'
|
path_info += '/' + str(query_limit)
|
||||||
path_info += '/' + str(query_limit)
|
if query_offset == None:
|
||||||
|
path_info += '/0'
|
||||||
env = {
|
env = {
|
||||||
'PATH_INFO': path_info,
|
'PATH_INFO': path_info,
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ def test_query_process_txs_bloom(
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'query_block_start, query_block_end, query_match_count',
|
'query_block_start, query_block_end, query_match_count',
|
||||||
[
|
[
|
||||||
(None, 42, 0),
|
(1, 42, 0),
|
||||||
(420000, 420001, 1),
|
(420000, 420001, 1),
|
||||||
(419999, 419999, 1), # matches are inclusive
|
(419999, 419999, 1), # matches are inclusive
|
||||||
(419999, 420000, 2),
|
(419999, 420000, 2),
|
||||||
@ -211,7 +212,7 @@ def test_query_process_txs_data(
|
|||||||
query_match_count,
|
query_match_count,
|
||||||
):
|
):
|
||||||
|
|
||||||
path_info = '/txa'
|
path_info = '/txa/100/0'
|
||||||
if query_block_start != None:
|
if query_block_start != None:
|
||||||
path_info += '/' + str(query_block_start)
|
path_info += '/' + str(query_block_start)
|
||||||
if query_block_end != None:
|
if query_block_end != None:
|
||||||
@ -227,4 +228,5 @@ def test_query_process_txs_data(
|
|||||||
assert r != None
|
assert r != None
|
||||||
|
|
||||||
o = json.loads(r[1])
|
o = json.loads(r[1])
|
||||||
|
logg.debug('oo {}'.format(o))
|
||||||
assert len(o['data']) == query_match_count
|
assert len(o['data']) == query_match_count
|
||||||
|
Loading…
Reference in New Issue
Block a user