diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py index c08f212..9ffa460 100644 --- 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 index 62b0423..f2b31e0 100644 --- 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 index bb86dc7..8dc993a 100644 --- 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)