chainlib-eth

Ethereum implementation of the chainlib interface
Log | Files | Refs | README | LICENSE

commit 601db731d9433dc7a709c19ac389c34c771f8817
parent c954f4d1b4610c558226e754c89f4135fa5d2240
Author: lash <dev@holbrook.no>
Date:   Tue,  1 Mar 2022 14:43:43 +0000

Handle int instead of hex signature values in pack from eth_tester

Diffstat:
Mchainlib/eth/tx.py | 6+++++-
Msetup.cfg | 2+-
Mtests/test_tx.py | 13+++++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py @@ -95,7 +95,11 @@ def pack(tx_src, chain_spec): tx_src['r'], tx_src['s'], ]: - for b in bytes.fromhex(strip_0x(a)): + try: + a = strip_0x(a) + except TypeError: + a = strip_0x(hex(a)) # believe it or not, eth_tester returns signatures as ints not hex + for b in bytes.fromhex(a): signature[cursor] = b cursor += 1 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.1.0b2 +version = 0.1.0b3 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no diff --git a/tests/test_tx.py b/tests/test_tx.py @@ -50,6 +50,19 @@ class TxTestCase(EthTesterCase): self.assertTrue(is_same_address(tx['to'], self.accounts[1])) + def test_tx_repack(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + gas_oracle = RPCGasOracle(self.rpc) + c = Gas(signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle, chain_spec=self.chain_spec) + (tx_hash_hex, o) = c.create(self.accounts[0], self.accounts[1], 1024) + self.rpc.do(o) + + o = transaction(tx_hash_hex) + tx_src = self.rpc.do(o) + tx = Tx(tx_src) + tx_bin = pack(tx.src(), self.chain_spec) + + def test_tx_pack(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) gas_oracle = RPCGasOracle(self.rpc)