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

Problem: no integration test case for fee calculation of reverted contract call tx. #590

Merged
merged 1 commit into from
Jul 25, 2022
Merged
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
28 changes: 28 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,34 @@ def test_exception(cluster):
assert 5 * (10**18) == contract.caller.query()


def test_refund_unused_gas_when_contract_tx_reverted(cluster):
"""
Call a smart contract method that reverts with very high gas limit

Call tx receipt should be status 0 (fail)
Fee is gasUsed * effectiveGasPrice
"""
w3 = cluster.w3
contract = deploy_contract(w3, CONTRACTS["TestRevert"])
more_than_enough_gas = 1000000

balance_bef = w3.eth.get_balance(ADDRS["community"])
receipt = send_transaction(
w3,
contract.functions.transfer(5 * (10**18) - 1).buildTransaction(
{"gas": more_than_enough_gas}
),
key=KEYS["community"],
)
balance_aft = w3.eth.get_balance(ADDRS["community"])

assert receipt["status"] == 0, "should be a failed tx"
assert receipt["gasUsed"] != more_than_enough_gas
assert (
balance_bef - balance_aft == receipt["gasUsed"] * receipt["effectiveGasPrice"]
)


def test_message_call(cronos):
"stress test the evm by doing message calls as much as possible"
w3 = cronos.w3
Expand Down