Add basic send test
This commit is contained in:
parent
7d5d7f67c6
commit
e166f3d101
@ -568,6 +568,7 @@ def sync_tx(self, tx_hash_hex, chain_str):
|
|||||||
# return txpending_hash_hex
|
# return txpending_hash_hex
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Move to cic_eth.eth.gas
|
||||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||||
def cache_gas_data(
|
def cache_gas_data(
|
||||||
tx_hash_hex,
|
tx_hash_hex,
|
||||||
|
58
apps/cic-eth/tests/task/test_task_send.py
Normal file
58
apps/cic-eth/tests/task/test_task_send.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# standard imports
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
import celery
|
||||||
|
from chainlib.eth.gas import Gas
|
||||||
|
from chainlib.eth.nonce import RPCNonceOracle
|
||||||
|
from chainlib.eth.tx import (
|
||||||
|
TxFormat,
|
||||||
|
unpack,
|
||||||
|
transaction,
|
||||||
|
receipt,
|
||||||
|
)
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from cic_eth.queue.tx import register_tx
|
||||||
|
from cic_eth.eth.tx import cache_gas_data
|
||||||
|
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def test_tx_send(
|
||||||
|
init_database,
|
||||||
|
default_chain_spec,
|
||||||
|
eth_rpc,
|
||||||
|
eth_signer,
|
||||||
|
agent_roles,
|
||||||
|
contract_roles,
|
||||||
|
celery_worker,
|
||||||
|
):
|
||||||
|
|
||||||
|
chain_id = default_chain_spec.chain_id()
|
||||||
|
nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc)
|
||||||
|
c = Gas(signer=eth_signer, nonce_oracle=nonce_oracle, chain_id=chain_id)
|
||||||
|
(tx_hash_hex, tx_signed_raw_hex) = c.create(agent_roles['ALICE'], agent_roles['BOB'], 1024, tx_format=TxFormat.RLP_SIGNED)
|
||||||
|
#unpack(bytes.fromhex(strip_0x(tx_signed_raw_hex)), chain_id)
|
||||||
|
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())
|
||||||
|
|
||||||
|
s_send = celery.signature(
|
||||||
|
'cic_eth.eth.tx.send',
|
||||||
|
[
|
||||||
|
[tx_signed_raw_hex],
|
||||||
|
default_chain_spec.asdict(),
|
||||||
|
],
|
||||||
|
queue=None,
|
||||||
|
)
|
||||||
|
t = s_send.apply_async()
|
||||||
|
r = t.get()
|
||||||
|
assert t.successful()
|
||||||
|
|
||||||
|
o = transaction(tx_hash_hex)
|
||||||
|
tx = eth_rpc.do(o)
|
||||||
|
assert r == tx['hash']
|
||||||
|
|
||||||
|
o = receipt(tx_hash_hex)
|
||||||
|
rcpt = eth_rpc.do(o)
|
||||||
|
assert rcpt['status'] == 1
|
@ -16,9 +16,8 @@ import random
|
|||||||
# external imports
|
# external imports
|
||||||
import vobject
|
import vobject
|
||||||
import celery
|
import celery
|
||||||
import web3
|
|
||||||
from faker import Faker
|
from faker import Faker
|
||||||
import cic_registry
|
import cic_eth_registry
|
||||||
import confini
|
import confini
|
||||||
from cic_eth.api import Api
|
from cic_eth.api import Api
|
||||||
from cic_types.models.person import (
|
from cic_types.models.person import (
|
||||||
@ -26,7 +25,7 @@ from cic_types.models.person import (
|
|||||||
generate_vcard_from_contact_data,
|
generate_vcard_from_contact_data,
|
||||||
get_contact_data_from_vcard,
|
get_contact_data_from_vcard,
|
||||||
)
|
)
|
||||||
from chainlib.eth.address import to_checksum
|
from chainlib.eth.address import to_checksum_address
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -142,7 +141,7 @@ def genDob():
|
|||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
old_blockchain_address = '0x' + os.urandom(20).hex()
|
old_blockchain_address = '0x' + os.urandom(20).hex()
|
||||||
old_blockchain_checksum_address = to_checksum(old_blockchain_address)
|
old_blockchain_checksum_address = to_checksum_address(old_blockchain_address)
|
||||||
gender = random.choice(['female', 'male', 'other'])
|
gender = random.choice(['female', 'male', 'other'])
|
||||||
phone = genPhone()
|
phone = genPhone()
|
||||||
city = fake.city_name()
|
city = fake.city_name()
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
cic-base[full_graph]==0.1.1a23
|
cic-base[full_graph]==0.1.2a22
|
||||||
cic-eth==0.10.0a41
|
cic-eth==0.10.1a5+build.21f71043
|
||||||
cic-types==0.1.0a8
|
cic-types==0.1.0a8
|
||||||
|
Loading…
Reference in New Issue
Block a user