cic-cli/tests/eth/test_eth_rpc.py

49 lines
1.4 KiB
Python
Raw Permalink Normal View History

2021-10-10 13:48:32 +02:00
# standard imports
import unittest
import logging
# external imports
from chainlib.eth.nonce import RPCNonceOracle
from chainlib.eth.gas import RPCGasOracle
from chainlib.eth.tx import (
TxFormat,
unpack,
)
from hexathon import strip_0x
# local imports
from cic.ext.eth import CICEth
# test imports
from tests.eth.base_eth import TestCICEthBase
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class TestCICEthRPC(TestCICEthBase):
def setUp(self):
super(TestCICEthRPC, self).setUp()
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
gas_oracle = RPCGasOracle(self.rpc)
self.adapter = CICEth(self.core_processor, self.chain_spec, self.resources, self.proofs, signer=self.signer, rpc=self.rpc, fee_oracle=gas_oracle)
2021-10-10 13:48:32 +02:00
@unittest.skip('test does not make sense anymore because nonces will be different')
2021-10-10 13:48:32 +02:00
def test_rpc_token_index(self):
self.adapter.token_address = self.token_address
v = self.adapter.process_token_index()
adapter_norpc = CICEth(self.core_processor, self.chain_spec, self.resources, self.proofs, signer=self.signer)
2021-10-10 13:48:32 +02:00
adapter_norpc.token_address = self.token_address
vv = adapter_norpc.process_token_index()
2021-10-10 14:00:47 +02:00
tx_raw = bytes.fromhex(strip_0x(vv))
2021-10-10 13:48:32 +02:00
tx = unpack(tx_raw, self.chain_spec)
self.assertEqual(strip_0x(tx['hash']), strip_0x(v))
if __name__ == '__main__':
unittest.main()