diff --git a/integration_tests/contracts/contracts/TheRevertContract.sol b/integration_tests/contracts/contracts/TheRevertContract.sol deleted file mode 100644 index 57ea82c968..0000000000 --- a/integration_tests/contracts/contracts/TheRevertContract.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.0; - -// the method trigger_revert() will always be reverted -contract TheRevertContract { - uint256 storedData; - - constructor() { - storedData = 10; - } - - function trigger_revert(uint256 x) public { - storedData = x; - revert("Revert to refund gas"); - } - - function get() public view returns (uint256) { - return storedData; - } -} diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index c077f69dee..3990063102 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -401,10 +401,25 @@ def test_exception(cluster): w3, CONTRACTS["TestRevert"], ) - with pytest.raises(web3.exceptions.ContractLogicError): - send_transaction( - w3, contract.functions.transfer(5 * (10**18) - 1).buildTransaction() - ) + more_than_enough_gas = 1000000 + + balance_bef = w3.eth.get_balance(ADDRS["validator"]) + receipt = send_transaction( + w3, + contract.functions.transfer(5 * (10**18) - 1).buildTransaction( + {"gas": more_than_enough_gas} + ), + ) + balance_aft = w3.eth.get_balance(ADDRS["validator"]) + + print(f"{receipt = }") + print(f"{w3.eth.max_priority_fee = }") + print(f"{w3.eth.gas_price = }") + 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"] + ) assert 0 == contract.caller.query() receipt = send_transaction( @@ -690,34 +705,3 @@ def test_tx_inclusion(cronos, max_gas_wanted): == receipts[2].blockNumber == receipts[3].blockNumber ) - - -def test_refund_unused_gas_when_contract_state_reverted(cronos): - """ - Call a smart contract method that always revert with very high gas limit - - Call tx should return status 0 (fail) - Fee is gasUsed * effectivePrice - """ - - w3 = cronos.w3 - the_revert_contract = deploy_contract( - w3, CONTRACTS["TheRevertContract"], key=KEYS["community"] - ) - - more_than_enough_gas = 1000000 - dummy = 12 - tx = the_revert_contract.functions.trigger_revert(dummy).buildTransaction( - {"gas": more_than_enough_gas} - ) - - balance_bef = w3.eth.get_balance(ADDRS["community"]) - tx_receipt = send_transaction(w3, tx, KEYS["community"]) - balance_aft = w3.eth.get_balance(ADDRS["community"]) - - assert tx_receipt["status"] == 0, "should be failed tx" - assert tx_receipt["gasUsed"] != more_than_enough_gas - assert ( - balance_bef - balance_aft - == tx_receipt["gasUsed"] * tx_receipt["effectiveGasPrice"] - ) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 0dd97ee76b..dd695a938a 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -41,7 +41,6 @@ "TestMessageCall": "TestMessageCall.sol", "CroBridge": "CroBridge.sol", "CronosGravityCancellation": "CronosGravityCancellation.sol", - "TheRevertContract": "TheRevertContract.sol", }