Rehabilitate tests, tx_list tests still failing
This commit is contained in:
@@ -59,17 +59,15 @@ def test_assemble():
|
||||
assert r[1].get('balance_xyzzy') != None
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_outgoing_balance(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
):
|
||||
|
||||
chain_str = str(default_chain_spec)
|
||||
recipient = '0x' + os.urandom(20).hex()
|
||||
tx_hash = '0x' + os.urandom(32).hex()
|
||||
signed_tx = '0x' + os.urandom(128).hex()
|
||||
otx = Otx.add(0, recipient, tx_hash, signed_tx, session=init_database)
|
||||
otx = Otx.add(0, tx_hash, signed_tx, session=init_database)
|
||||
init_database.add(otx)
|
||||
init_database.commit()
|
||||
|
||||
@@ -83,6 +81,7 @@ def test_outgoing_balance(
|
||||
token_address,
|
||||
1000,
|
||||
1000,
|
||||
session=init_database,
|
||||
)
|
||||
init_database.add(txc)
|
||||
init_database.commit()
|
||||
@@ -91,33 +90,35 @@ def test_outgoing_balance(
|
||||
'address': token_address,
|
||||
'converters': [],
|
||||
}
|
||||
b = balance_outgoing([token_data], sender, chain_str)
|
||||
b = balance_outgoing([token_data], sender, default_chain_spec.asdict())
|
||||
assert b[0]['balance_outgoing'] == 1000
|
||||
|
||||
otx.readysend(session=init_database)
|
||||
init_database.flush()
|
||||
otx.reserve(session=init_database)
|
||||
init_database.flush()
|
||||
otx.sent(session=init_database)
|
||||
init_database.commit()
|
||||
|
||||
b = balance_outgoing([token_data], sender, chain_str)
|
||||
b = balance_outgoing([token_data], sender, default_chain_spec.asdict())
|
||||
assert b[0]['balance_outgoing'] == 1000
|
||||
|
||||
otx.success(block=1024, session=init_database)
|
||||
init_database.commit()
|
||||
|
||||
b = balance_outgoing([token_data], sender, chain_str)
|
||||
b = balance_outgoing([token_data], sender, default_chain_spec.asdict())
|
||||
assert b[0]['balance_outgoing'] == 0
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_incoming_balance(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
):
|
||||
|
||||
chain_str = str(default_chain_spec)
|
||||
recipient = '0x' + os.urandom(20).hex()
|
||||
tx_hash = '0x' + os.urandom(32).hex()
|
||||
signed_tx = '0x' + os.urandom(128).hex()
|
||||
otx = Otx.add(0, recipient, tx_hash, signed_tx, session=init_database)
|
||||
otx = Otx.add(0, tx_hash, signed_tx, session=init_database)
|
||||
init_database.add(otx)
|
||||
init_database.commit()
|
||||
|
||||
@@ -131,6 +132,7 @@ def test_incoming_balance(
|
||||
token_address,
|
||||
1000,
|
||||
1000,
|
||||
session=init_database,
|
||||
)
|
||||
init_database.add(txc)
|
||||
init_database.commit()
|
||||
@@ -139,19 +141,23 @@ def test_incoming_balance(
|
||||
'address': token_address,
|
||||
'converters': [],
|
||||
}
|
||||
b = balance_incoming([token_data], recipient, chain_str)
|
||||
b = balance_incoming([token_data], recipient, default_chain_spec.asdict())
|
||||
assert b[0]['balance_incoming'] == 0
|
||||
|
||||
otx.readysend(session=init_database)
|
||||
init_database.flush()
|
||||
otx.reserve(session=init_database)
|
||||
init_database.flush()
|
||||
otx.sent(session=init_database)
|
||||
init_database.commit()
|
||||
|
||||
b = balance_incoming([token_data], recipient, chain_str)
|
||||
b = balance_incoming([token_data], recipient, default_chain_spec.asdict())
|
||||
assert b[0]['balance_incoming'] == 1000
|
||||
|
||||
otx.success(block=1024, session=init_database)
|
||||
init_database.commit()
|
||||
|
||||
b = balance_incoming([token_data], recipient, chain_str)
|
||||
b = balance_incoming([token_data], recipient, default_chain_spec.asdict())
|
||||
assert b[0]['balance_incoming'] == 0
|
||||
|
||||
|
||||
|
||||
58
apps/cic-eth/tests/unit/queue/test_query.py
Normal file
58
apps/cic-eth/tests/unit/queue/test_query.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# external imports
|
||||
from chainqueue.db.enum import (
|
||||
StatusEnum,
|
||||
StatusBits,
|
||||
)
|
||||
from chainlib.connection import RPCConnection
|
||||
from chainlib.eth.gas import (
|
||||
RPCGasOracle,
|
||||
Gas,
|
||||
)
|
||||
from chainlib.chain import ChainSpec
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.queue.query import get_upcoming_tx
|
||||
from cic_eth.queue.tx import register_tx
|
||||
from cic_eth.eth.tx import cache_gas_data
|
||||
|
||||
# test imports
|
||||
from tests.util.nonce import StaticNonceOracle
|
||||
|
||||
|
||||
def test_upcoming_with_lock(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
eth_rpc,
|
||||
eth_signer,
|
||||
agent_roles,
|
||||
):
|
||||
|
||||
rpc = RPCConnection.connect(default_chain_spec, 'default')
|
||||
nonce_oracle = StaticNonceOracle(42)
|
||||
gas_oracle = RPCGasOracle(eth_rpc)
|
||||
c = Gas(signer=eth_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle, chain_id=default_chain_spec.chain_id())
|
||||
|
||||
(tx_hash_hex, tx_rpc) = c.create(agent_roles['ALICE'], agent_roles['BOB'], 100 * (10 ** 6))
|
||||
tx_signed_raw_hex = tx_rpc['params'][0]
|
||||
|
||||
register_tx(tx_hash_hex, tx_signed_raw_hex, default_chain_spec, None, session=init_database)
|
||||
cache_gas_data(tx_hash_hex, tx_signed_raw_hex, default_chain_spec.asdict())
|
||||
|
||||
txs = get_upcoming_tx(default_chain_spec, StatusEnum.PENDING)
|
||||
assert len(txs.keys()) == 1
|
||||
|
||||
Lock.set(str(default_chain_spec), LockEnum.SEND, address=agent_roles['ALICE'])
|
||||
|
||||
txs = get_upcoming_tx(default_chain_spec, StatusEnum.PENDING)
|
||||
assert len(txs.keys()) == 0
|
||||
|
||||
(tx_hash_hex, tx_rpc) = c.create(agent_roles['BOB'], agent_roles['ALICE'], 100 * (10 ** 6))
|
||||
tx_signed_raw_hex = tx_rpc['params'][0]
|
||||
|
||||
register_tx(tx_hash_hex, tx_signed_raw_hex, default_chain_spec, None, session=init_database)
|
||||
cache_gas_data(tx_hash_hex, tx_signed_raw_hex, default_chain_spec.asdict())
|
||||
|
||||
txs = get_upcoming_tx(default_chain_spec, StatusEnum.PENDING)
|
||||
assert len(txs.keys()) == 1
|
||||
@@ -3,12 +3,12 @@ import os
|
||||
|
||||
# third-party imports
|
||||
import pytest
|
||||
from chainqueue.tx import create as queue_create
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.error import LockedError
|
||||
from cic_eth.queue.tx import queue_create
|
||||
|
||||
|
||||
def test_queue_lock(
|
||||
@@ -25,41 +25,41 @@ def test_queue_lock(
|
||||
Lock.set(chain_str, LockEnum.QUEUE)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
0,
|
||||
address,
|
||||
tx_hash,
|
||||
tx_raw,
|
||||
chain_str
|
||||
)
|
||||
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
0,
|
||||
address,
|
||||
tx_hash,
|
||||
tx_raw,
|
||||
chain_str
|
||||
)
|
||||
|
||||
Lock.reset(chain_str, LockEnum.QUEUE)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
0,
|
||||
address,
|
||||
tx_hash,
|
||||
tx_raw,
|
||||
chain_str
|
||||
)
|
||||
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address, tx_hash=tx_hash)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
0,
|
||||
address,
|
||||
tx_hash,
|
||||
tx_raw,
|
||||
chain_str
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user