2626 Storage ,
2727 Transaction ,
2828 TransactionException ,
29+ TransactionReceipt ,
2930 extend_with_defaults ,
3031)
3132from ethereum_test_tools import Opcodes as Op
@@ -688,12 +689,13 @@ def test_gas_cost(
688689 # We calculate the exact gas required to execute the test code.
689690 # We add SSTORE opcodes in order to make sure that the refund is less than one fifth (EIP-3529)
690691 # of the total gas used, so we can see the full discount being reflected in most of the tests.
691- gas_opcode_cost = 2
692+ gas_costs = fork .gas_costs ()
693+ gas_opcode_cost = gas_costs .G_BASE
692694 sstore_opcode_count = 10
693695 push_opcode_count = (2 * (sstore_opcode_count )) - 1
694- push_opcode_cost = 3 * push_opcode_count
695- sstore_opcode_cost = 20_000 * sstore_opcode_count
696- cold_storage_cost = 2_100 * sstore_opcode_count
696+ push_opcode_cost = gas_costs . G_VERY_LOW * push_opcode_count
697+ sstore_opcode_cost = gas_costs . G_STORAGE_SET * sstore_opcode_count
698+ cold_storage_cost = gas_costs . G_COLD_SLOAD * sstore_opcode_count
697699
698700 execution_gas = gas_opcode_cost + push_opcode_cost + sstore_opcode_cost + cold_storage_cost
699701
@@ -712,8 +714,6 @@ def test_gas_cost(
712714 test_code_address = pre .deploy_contract (test_code )
713715
714716 tx_gas_limit = intrinsic_gas + execution_gas
715- tx_max_fee_per_gas = 7
716- tx_exact_cost = tx_gas_limit * tx_max_fee_per_gas
717717
718718 # EIP-3529
719719 max_discount = tx_gas_limit // 5
@@ -722,20 +722,20 @@ def test_gas_cost(
722722 # Only one test hits this condition, but it's ok to also test this case.
723723 discount_gas = max_discount
724724
725- discount_cost = discount_gas * tx_max_fee_per_gas
725+ gas_used = tx_gas_limit - discount_gas
726726
727727 sender_account = pre [sender ]
728728 assert sender_account is not None
729729
730730 tx = Transaction (
731731 gas_limit = tx_gas_limit ,
732- max_fee_per_gas = tx_max_fee_per_gas ,
733732 to = test_code_address ,
734733 value = 0 ,
735734 data = data ,
736735 authorization_list = authorization_list ,
737736 access_list = access_list ,
738737 sender = sender ,
738+ expected_receipt = TransactionReceipt (gas_used = gas_used ),
739739 )
740740
741741 state_test (
@@ -744,7 +744,6 @@ def test_gas_cost(
744744 tx = tx ,
745745 post = {
746746 test_code_address : Account (storage = test_code_storage ),
747- sender : Account (balance = sender_account .balance - tx_exact_cost + discount_cost ),
748747 },
749748 )
750749
0 commit comments