Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return input instead of data for EthereumTesterProvider (eth_getTransaction*) #3235

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3235.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``EthereumTesterProvider`` now returns ``input`` for `eth_getTransaction*` for better consistency with JSON-RPC spec.
24 changes: 12 additions & 12 deletions tests/core/contracts/test_contract_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ def test_contract_constructor_build_transaction_no_constructor(
txn = w3.eth.get_transaction(txn_hash)
nonce = w3.eth.get_transaction_count(w3.eth.coinbase)
unsent_txn = math_contract_factory.constructor().build_transaction({"nonce": nonce})
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = w3.eth.send_transaction(unsent_txn)
new_txn = w3.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce


Expand All @@ -237,11 +237,11 @@ def test_contract_constructor_build_transaction_without_arguments(
txn = w3.eth.get_transaction(txn_hash)
nonce = w3.eth.get_transaction_count(w3.eth.coinbase)
unsent_txn = math_contract_factory.constructor().build_transaction({"nonce": nonce})
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = w3.eth.send_transaction(unsent_txn)
new_txn = w3.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce


Expand Down Expand Up @@ -269,11 +269,11 @@ def test_contract_constructor_build_transaction_with_arguments(
unsent_txn = non_strict_contract_with_constructor_args_factory.constructor(
*constructor_args, **constructor_kwargs
).build_transaction({"nonce": nonce})
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = w3_non_strict_abi.eth.send_transaction(unsent_txn)
new_txn = w3_non_strict_abi.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce


Expand Down Expand Up @@ -528,11 +528,11 @@ async def test_async_contract_constructor_build_transaction_no_constructor(
unsent_txn = await async_math_contract_factory.constructor().build_transaction(
{"nonce": nonce}
)
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = await async_w3.eth.send_transaction(unsent_txn)
new_txn = await async_w3.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce


Expand All @@ -550,11 +550,11 @@ async def test_async_contract_constructor_build_transaction_without_arguments(
unsent_txn = await async_math_contract_factory.constructor().build_transaction(
{"nonce": nonce}
)
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = await async_w3.eth.send_transaction(unsent_txn)
new_txn = await async_w3.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce


Expand Down Expand Up @@ -589,9 +589,9 @@ async def test_async_contract_constructor_build_transaction_with_arguments(
*constructor_args, **constructor_kwargs
).build_transaction({"nonce": nonce})
)
assert txn["data"] == HexBytes(unsent_txn["data"])
assert txn["input"] == HexBytes(unsent_txn["data"])

new_txn_hash = await async_w3_non_strict_abi.eth.send_transaction(unsent_txn)
new_txn = await async_w3_non_strict_abi.eth.get_transaction(new_txn_hash)
assert new_txn["data"] == HexBytes(unsent_txn["data"])
assert new_txn["input"] == HexBytes(unsent_txn["data"])
assert new_txn["nonce"] == nonce
2 changes: 0 additions & 2 deletions tests/core/eth-module/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def test_get_transaction_formatters(w3, request_mocker):
},
],
"input": "0x5b34b966",
"data": "0x5b34b966",
}

with request_mocker(
Expand Down Expand Up @@ -318,7 +317,6 @@ def test_get_transaction_formatters(w3, request_mocker):
),
],
"input": HexBytes(unformatted_transaction["input"]),
"data": HexBytes(unformatted_transaction["data"]),
}
)

Expand Down
1 change: 1 addition & 0 deletions web3/providers/eth_tester/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def is_hexstr(value: Any) -> bool:
"max_priority_fee_per_gas": "maxPriorityFeePerGas",
"transaction_hash": "transactionHash",
"transaction_index": "transactionIndex",
"data": "input",
}
transaction_result_remapper = apply_key_map(TRANSACTION_RESULT_KEY_MAPPING)

Expand Down