2021-03-17 11:24:55 +01:00
|
|
|
# standard imports
|
|
|
|
import logging
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
import pytest
|
|
|
|
from hexathon import add_0x
|
|
|
|
from chainlib.eth.address import to_checksum_address
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from cic_eth.db.models.role import AccountRole
|
2021-03-21 21:10:56 +01:00
|
|
|
from cic_eth.db.models.nonce import Nonce
|
2021-03-17 11:24:55 +01:00
|
|
|
|
2021-03-18 11:57:26 +01:00
|
|
|
#logg = logging.getLogger(__name__)
|
|
|
|
# what the actual fuck, debug is not being shown even though explicitly set
|
2021-03-18 19:36:52 +01:00
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
2021-03-18 11:57:26 +01:00
|
|
|
logg = logging.getLogger()
|
2021-03-17 11:24:55 +01:00
|
|
|
|
|
|
|
|
2021-03-21 21:10:56 +01:00
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def init_custodial(
|
|
|
|
contract_roles,
|
|
|
|
token_roles,
|
|
|
|
agent_roles,
|
|
|
|
init_database,
|
|
|
|
):
|
|
|
|
for roles in [contract_roles, token_roles, agent_roles]:
|
|
|
|
for role in roles.values():
|
|
|
|
Nonce.init(role, session=init_database)
|
|
|
|
|
|
|
|
init_database.commit()
|
|
|
|
|
|
|
|
|
2021-03-17 11:24:55 +01:00
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def custodial_roles(
|
2021-03-21 21:10:56 +01:00
|
|
|
init_custodial,
|
2021-03-17 11:24:55 +01:00
|
|
|
contract_roles,
|
2021-03-20 13:58:45 +01:00
|
|
|
token_roles,
|
2021-03-21 21:10:56 +01:00
|
|
|
agent_roles,
|
2021-03-17 11:24:55 +01:00
|
|
|
eth_accounts,
|
|
|
|
init_database,
|
|
|
|
):
|
|
|
|
r = {}
|
|
|
|
r.update(contract_roles)
|
2021-03-21 21:10:56 +01:00
|
|
|
r.update(agent_roles)
|
2021-03-17 11:24:55 +01:00
|
|
|
r.update({
|
2021-03-20 13:58:45 +01:00
|
|
|
'GAS_GIFTER': eth_accounts[10],
|
|
|
|
'FOO_TOKEN_GIFTER': token_roles['FOO_TOKEN_OWNER'],
|
2021-03-17 11:24:55 +01:00
|
|
|
})
|
|
|
|
for k in r.keys():
|
|
|
|
role = AccountRole.set(k, r[k])
|
|
|
|
init_database.add(role)
|
2021-03-23 00:13:57 +01:00
|
|
|
logg.info('adding role {} -> {}'.format(k, r[k]))
|
2021-03-17 11:24:55 +01:00
|
|
|
init_database.commit()
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def whoever(
|
|
|
|
init_eth_tester,
|
|
|
|
):
|
|
|
|
return init_eth_tester.new_account()
|