@@ -39,6 +39,7 @@ import (
3939	"github.com/ava-labs/libevm/libevm" 
4040	"github.com/ava-labs/libevm/libevm/ethtest" 
4141	"github.com/ava-labs/libevm/libevm/hookstest" 
42+ 	"github.com/ava-labs/libevm/libevm/legacy" 
4243	"github.com/ava-labs/libevm/params" 
4344)
4445
@@ -146,16 +147,13 @@ func TestNewStatefulPrecompile(t *testing.T) {
146147	const  gasLimit  =  1e6 
147148	gasCost  :=  rng .Uint64n (gasLimit )
148149
149- 	run  :=  func (env  vm.PrecompileEnvironment , input  []byte ) ([]byte , error ) {
150+ 	run  :=  func (env  vm.PrecompileEnvironment , input  []byte ,  suppliedGas   uint64 ) ([]byte ,  uint64 , error ) {
150151		if  got , want  :=  env .StateDB () !=  nil , ! env .ReadOnly (); got  !=  want  {
151- 			return  nil , fmt .Errorf ("PrecompileEnvironment().StateDB() must be non-nil i.f.f. not read-only; got non-nil? %t; want %t" , got , want )
152+ 			return  nil , suppliedGas ,  fmt .Errorf ("PrecompileEnvironment().StateDB() must be non-nil i.f.f. not read-only; got non-nil? %t; want %t" , got , want )
152153		}
153154		hdr , err  :=  env .BlockHeader ()
154155		if  err  !=  nil  {
155- 			return  nil , err 
156- 		}
157- 		if  ! env .UseGas (gasCost ) {
158- 			return  nil , vm .ErrOutOfGas 
156+ 			return  nil , suppliedGas , err 
159157		}
160158
161159		out  :=  & statefulPrecompileOutput {
@@ -169,11 +167,15 @@ func TestNewStatefulPrecompile(t *testing.T) {
169167			Input :            input ,
170168			IncomingCallType : env .IncomingCallType (),
171169		}
172- 		return  out .Bytes (), nil 
170+ 		return  out .Bytes (), suppliedGas   -   gasCost ,  nil 
173171	}
174172	hooks  :=  & hookstest.Stub {
175173		PrecompileOverrides : map [common.Address ]libevm.PrecompiledContract {
176- 			precompile : vm .NewStatefulPrecompile (run ),
174+ 			precompile : vm .NewStatefulPrecompile (
175+ 				// In production, the new function signature should be used, but 
176+ 				// this just exercises the converter. 
177+ 				legacy .PrecompiledStatefulContract (run ).Upgrade (),
178+ 			),
177179		},
178180	}
179181	hooks .Register (t )
0 commit comments