2021-03-29 15:27:53 +02:00
|
|
|
# external imports
|
|
|
|
from chainlib.eth.gas import (
|
|
|
|
Gas,
|
|
|
|
RPCGasOracle,
|
|
|
|
)
|
|
|
|
from chainlib.eth.tx import (
|
|
|
|
TxFormat,
|
|
|
|
unpack,
|
|
|
|
)
|
|
|
|
from chainlib.eth.nonce import RPCNonceOracle
|
|
|
|
from chainlib.connection import RPCConnection
|
|
|
|
from hexathon import strip_0x
|
2021-02-01 18:12:51 +01:00
|
|
|
|
|
|
|
def test_unpack(
|
2021-03-29 15:27:53 +02:00
|
|
|
default_chain_spec,
|
|
|
|
eth_rpc,
|
|
|
|
eth_signer,
|
|
|
|
agent_roles,
|
2021-02-01 18:12:51 +01:00
|
|
|
):
|
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
rpc = RPCConnection.connect(default_chain_spec, 'default')
|
|
|
|
nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc)
|
|
|
|
gas_oracle = RPCGasOracle(eth_rpc)
|
2021-04-04 13:27:28 +02:00
|
|
|
c = Gas(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
2021-03-29 15:27:53 +02:00
|
|
|
(tx_hash_hex, tx_signed_raw_hex) = c.create(agent_roles['ALICE'], agent_roles['BOB'], 100 * (10 ** 6), tx_format=TxFormat.RLP_SIGNED)
|
2021-02-01 18:12:51 +01:00
|
|
|
|
2021-04-04 13:27:28 +02:00
|
|
|
tx = unpack(bytes.fromhex(strip_0x(tx_signed_raw_hex)), default_chain_spec)
|
2021-02-01 18:12:51 +01:00
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
assert tx_hash_hex == tx['hash']
|