voith / eth-tester-rpc

Rewrite of piper merriams eth-testrpc
MIT License
3 stars 3 forks source link

Correctly remap transactions that are returned with a block #26

Closed koirikivi closed 6 years ago

koirikivi commented 6 years ago

This happens when calling web3.eth.getBlock(123, fullTransactions=True)

Without this fix, some features like web3 gas price strategies were broken.

Unfortunately, I don't have the time to write a test for this at the moment. However, the internal test I write looked something like this:

def test_block_transaction_remapping(web3, account_1, account_2):
    tx_hash = web3.eth.sendTransaction({
        'from': account_1,
        'to': account_2,
        'value': 1_000_000,
    })
    receipt = wait_for_transaction_receipt(web3, tx_hash)
    block = web3.eth.getBlock(receipt.blockNumber, full_transactions=True)
    transactions = block['transactions']
    transaction = transactions[0]
    assert 'gasPrice' in transaction  # should also assert other keys

Maybe that can serve as a starting point.

voith commented 6 years ago

closing in favour of #27. commit has been cherry-picked. Thanks for the fix!