Handle int instead of hex signature values in pack from eth_tester

This commit is contained in:
lash 2022-03-01 14:43:43 +00:00
parent c954f4d1b4
commit 601db731d9
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 19 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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)