Skip to content

Commit

Permalink
Merge pull request #143 from pipermerriam/piper/fix-eth_getTransactio…
Browse files Browse the repository at this point in the history
…n-for-unknown-transaction-hash

Fix transaction formatter to handle null
  • Loading branch information
pipermerriam committed Jan 1, 2017
2 parents d874a1a + 03b4f3f commit 0eb88bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/eth-module/test_eth_getTransaction.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions web3/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 0eb88bd

Please sign in to comment.