Pass parse filter

This commit is contained in:
nolash 2021-04-14 12:44:00 +02:00
parent 537ea782c7
commit bf8ddd0a5c
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 32 additions and 3 deletions

View File

@ -26,8 +26,8 @@ def parse_transfer(tx):
transfer_data = {} transfer_data = {}
transfer_data['to'] = r[0] transfer_data['to'] = r[0]
transfer_data['value'] = r[1] transfer_data['value'] = r[1]
transfer_data['from'] = tx['from'] transfer_data['from'] = tx.outputs[0]
transfer_data['token_address'] = tx['to'] transfer_data['token_address'] = tx.inputs[0]
return ('transfer', transfer_data) return ('transfer', transfer_data)

View File

@ -1,10 +1,25 @@
# standard import
import logging
# external imports # external imports
from chainlib.connection import RPCConnection from chainlib.connection import RPCConnection
from chainlib.eth.nonce import RPCNonceOracle from chainlib.eth.nonce import RPCNonceOracle
from chainlib.eth.gas import OverrideGasOracle from chainlib.eth.gas import OverrideGasOracle
from chainlib.eth.tx import receipt from chainlib.eth.tx import (
receipt,
transaction,
Tx,
snake_and_camel,
)
from chainlib.eth.erc20 import ERC20 from chainlib.eth.erc20 import ERC20
# local imports
from cic_eth.runnable.daemons.filters.callback import (
parse_transfer,
)
logg = logging.getLogger()
def test_transfer_tx( def test_transfer_tx(
default_chain_spec, default_chain_spec,
@ -24,6 +39,20 @@ def test_transfer_tx(
txf = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle) txf = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
(tx_hash_hex, o) = txf.transfer(foo_token, token_roles['FOO_TOKEN_OWNER'], agent_roles['ALICE'], 1024) (tx_hash_hex, o) = txf.transfer(foo_token, token_roles['FOO_TOKEN_OWNER'], agent_roles['ALICE'], 1024)
r = rpc.do(o) r = rpc.do(o)
o = transaction(tx_hash_hex)
r = rpc.do(o)
logg.debug(r)
tx_src = snake_and_camel(r)
tx = Tx(tx_src)
o = receipt(tx_hash_hex) o = receipt(tx_hash_hex)
r = rpc.do(o) r = rpc.do(o)
assert r['status'] == 1 assert r['status'] == 1
rcpt = snake_and_camel(r)
tx.apply_receipt(rcpt)
(transfer_type, transfer_data) = parse_transfer(tx)
assert transfer_type == 'transfer'