@@ -47,29 +47,31 @@ func (s *stubPrecompileEnvironment) UseGas(gas uint64) bool {
4747func  TestPrecompiledStatefulContract_Upgrade (t  * testing.T ) {
4848	t .Parallel ()
4949
50+ 	errTest  :=  errors .New ("test error" )
51+ 
5052	tests  :=  map [string ]struct  {
5153		envGas         uint64 
5254		precompileRet  []byte 
5355		remainingGas   uint64 
5456		precompileErr  error 
5557		wantRet        []byte 
56- 		wantErr        string 
58+ 		wantErr        error 
5759		wantGasUsed    uint64 
5860	}{
5961		"call_error" : {
6062			envGas :        10 ,
6163			precompileRet : []byte {2 },
6264			remainingGas :  6 ,
63- 			precompileErr : errors . New ( "test error" ) ,
65+ 			precompileErr : errTest ,
6466			wantRet :       []byte {2 },
65- 			wantErr :       "test error" ,
67+ 			wantErr :       errTest ,
6668			wantGasUsed :   4 ,
6769		},
6870		"remaining_gas_exceeds_supplied_gas" : {
6971			envGas :        10 ,
7072			precompileRet : []byte {2 },
7173			remainingGas :  11 ,
72- 			wantErr :       "remaining gas 11 exceeds supplied gas 10" ,
74+ 			wantErr :       errRemainingGasExceedsSuppliedGas ,
7375		},
7476		"zero_remaining_gas" : {
7577			envGas :        10 ,
@@ -103,11 +105,7 @@ func TestPrecompiledStatefulContract_Upgrade(t *testing.T) {
103105			input  :=  []byte ("unused" )
104106
105107			ret , err  :=  upgraded (env , input )
106- 			if  testCase .wantErr  ==  ""  {
107- 				require .NoError (t , err )
108- 			} else  {
109- 				require .EqualError (t , err , testCase .wantErr )
110- 			}
108+ 			require .ErrorIs (t , err , testCase .wantErr )
111109			assert .Equal (t , testCase .wantRet , ret , "bytes returned by upgraded contract" )
112110			assert .Equalf (t , testCase .wantGasUsed , env .gasUsed , "sum of %T.UseGas() calls" , env )
113111		})
0 commit comments