@@ -400,13 +400,25 @@ func TestSaturatingDecrement(t *testing.T) {
400400 }
401401
402402 // saturating decrement on kind
403- gas = ComputationGas (0 )
404- newGas = gas .SaturatingDecrement (ResourceKindComputation , 1 )
403+ gas = MultiGasFromPairs (
404+ Pair {ResourceKindComputation , 10 },
405+ Pair {ResourceKindStorageAccess , 10 },
406+ )
407+
408+ newGas = gas .SaturatingDecrement (ResourceKindComputation , 20 )
405409 if got , want := newGas .Get (ResourceKindComputation ), uint64 (0 ); got != want {
406- t .Errorf ("expected computation gas to clamp to zero : got %v, want %v" , got , want )
410+ t .Errorf ("unexpected comp gas: got %v, want %v" , got , want )
407411 }
408- if got , want := newGas .SingleGas (), uint64 (0 ); got != want {
409- t .Errorf ("expected total to clamp to zero: got %v, want %v" , got , want )
412+ if got , want := newGas .Get (ResourceKindStorageAccess ), uint64 (10 ); got != want {
413+ t .Errorf ("unexpected storage access gas: got %v, want %v" , got , want )
414+ }
415+ if got , want := newGas .SingleGas (), uint64 (10 ); got != want {
416+ t .Errorf ("unexpected total (should drop by 10 only): got %v, want %v" , got , want )
417+ }
418+
419+ if got , want := newGas .SingleGas (),
420+ newGas .Get (ResourceKindComputation )+ newGas .Get (ResourceKindStorageAccess ); got != want {
421+ t .Errorf ("total/sum mismatch: total=%v sum=%v" , got , want )
410422 }
411423
412424 // total-only decrement case
0 commit comments