@@ -20,13 +20,13 @@ import (
2020 "math/big"
2121 "testing"
2222
23- "github.com/google/go-cmp/cmp"
2423 "github.com/holiman/uint256"
2524 "github.com/stretchr/testify/require"
2625
2726 "github.com/ava-labs/libevm/common"
2827 "github.com/ava-labs/libevm/core"
2928 "github.com/ava-labs/libevm/core/types"
29+ "github.com/ava-labs/libevm/core/vm"
3030 "github.com/ava-labs/libevm/crypto"
3131 "github.com/ava-labs/libevm/libevm"
3232 "github.com/ava-labs/libevm/libevm/ethtest"
@@ -140,17 +140,34 @@ func TestMinimumGasConsumption(t *testing.T) {
140140 stateDB .SetNonce (msg .From , 0 )
141141 stateDB .SetBalance (msg .From , uint256 .NewInt (startingBalance ))
142142
143- gotPool := core .GasPool (1e9 ) // modified when passed as pointer
143+ var (
144+ // Both variables are passed as pointers to
145+ // [core.ApplyTransaction], which will modify them.
146+ gotUsed uint64
147+ gotPool = core .GasPool (1e9 ) // modified when passed as pointer
148+ )
144149 wantPool := gotPool - core .GasPool (tt .wantUsed )
145150
146- got , err := core .ApplyMessage (evm , msg , & gotPool )
147- require .NoError (t , err , "core.ApplyMessage()" )
148-
149- want := & core.ExecutionResult {
150- UsedGas : tt .wantUsed ,
151- }
152- if diff := cmp .Diff (want , got ); diff != "" {
153- t .Errorf ("core.ApplyMessage(...) diff (-want +got):\n %s" , diff )
151+ receipt , err := core .ApplyTransaction (
152+ evm .ChainConfig (), nil , & common.Address {}, & gotPool , stateDB ,
153+ & types.Header {
154+ BaseFee : big .NewInt (gasPrice ),
155+ // Required but irrelevant fields
156+ Number : big .NewInt (0 ),
157+ Difficulty : big .NewInt (0 ),
158+ },
159+ tx , & gotUsed , vm.Config {},
160+ )
161+ require .NoError (t , err , "core.ApplyTransaction(...)" )
162+
163+ for desc , got := range map [string ]uint64 {
164+ "receipt.GasUsed" : receipt .GasUsed ,
165+ "receipt.CumulativeGasUsed" : receipt .CumulativeGasUsed ,
166+ "core.ApplyTransaction(..., usedGas *uint64, ...)" : gotUsed ,
167+ } {
168+ if got != tt .wantUsed {
169+ t .Errorf ("%s got %d; want %d" , desc , got , tt .wantUsed )
170+ }
154171 }
155172 if gotPool != wantPool {
156173 t .Errorf ("After core.ApplyMessage(..., *%T); got %[1]T = %[1]d; want %d" , gotPool , wantPool )
0 commit comments