Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ttl33 committed Sep 25, 2024
1 parent 5cac752 commit 732d173
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions protocol/x/subaccounts/keeper/subaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6108,23 +6108,30 @@ func TestGetAllRelevantPerpetuals_Deterministic(t *testing.T) {
gasUsedAfter := ctx.GasMeter().GasConsumed()

gasUsed := uint64(0)
for range 100 { // run 100 times since it's highly unlikely gas usage is deterministic over 100 times if there's non-determinism.
// Run 100 times since it's highly unlikely gas usage is deterministic over 100 times if
// there's non-determinism.
for range 100 {
// divide by 2 so that the state read fails at least second to last time.
ctxWithLimitedGas := ctx.WithGasMeter(storetypes.NewGasMeter((gasUsedAfter - gasUsedBefore) / 2))

require.PanicsWithValue(
t,
storetypes.ErrorOutOfGas{Descriptor: "ReadFlat"},
func() {
keeper.GetAllRelevantPerpetuals(ctxWithLimitedGas, []types.Update{update})
_, _ = keeper.GetAllRelevantPerpetuals(ctxWithLimitedGas, []types.Update{update})
},
)

if gasUsed == 0 {
gasUsed = ctxWithLimitedGas.GasMeter().GasConsumed()
require.Greater(t, gasUsed, uint64(0))
} else {
require.Equal(t, gasUsed, ctxWithLimitedGas.GasMeter().GasConsumed(), "Gas usage when out of gas is not deterministic")
require.Equal(
t,
gasUsed,
ctxWithLimitedGas.GasMeter().GasConsumed(),
"Gas usage when out of gas is not deterministic",
)
}
}
})
Expand Down

0 comments on commit 732d173

Please sign in to comment.