diff --git a/tests/eth-module/test_eth_getTransaction.py b/tests/eth-module/test_eth_getTransaction.py new file mode 100644 index 0000000..3935554 --- /dev/null +++ b/tests/eth-module/test_eth_getTransaction.py @@ -0,0 +1,27 @@ +import pytest + +from web3.utils.string import force_bytes + + +@pytest.fixture(autouse=True) +def wait_for_first_block(web3, wait_for_block): + wait_for_block(web3) + + +def test_eth_getTransaction_for_unknown_transaction(web3): + txn_hash = b'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238' + txn = web3.eth.getTransaction(txn_hash) + assert txn is None + + +def test_eth_getTransaction(web3, extra_accounts, wait_for_transaction): + txn_hash = web3.eth.sendTransaction({ + "from": web3.eth.coinbase, + "to": extra_accounts[1], + "value": 1234, + }) + + wait_for_transaction(web3, txn_hash) + + txn = web3.eth.getTransaction(txn_hash) + assert txn['hash'] == txn_hash diff --git a/web3/formatters.py b/web3/formatters.py index e62861a..d5ba07f 100644 --- a/web3/formatters.py +++ b/web3/formatters.py @@ -116,6 +116,7 @@ def input_transaction_formatter(eth, txn): @coerce_args_to_text @coerce_return_to_text +@apply_if_not_null def output_transaction_formatter(txn): formatters = { 'blockNumber': apply_if_not_null(to_decimal),