Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Mar 19, 2024
1 parent 3ece47c commit ccad95c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions x/dex/keeper/limit_order_expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/neutron-org/neutron/v3/x/dex/keeper"
Expand Down Expand Up @@ -102,7 +103,7 @@ func (s *DexTestSuite) TestPurgeExpiredLimitOrders() {
keeper := s.App.DexKeeper
now := time.Now().UTC()
ctx := s.Ctx.WithBlockTime(now)
ctx = ctx.WithBlockGasMeter(sdk.NewGasMeter(1000000))
ctx = ctx.WithBlockGasMeter(storetypes.NewGasMeter(1000000))

yesterday := now.AddDate(0, 0, -1)
tomorrow := now.AddDate(0, 0, 1)
Expand Down Expand Up @@ -144,7 +145,7 @@ func (s *DexTestSuite) TestPurgeExpiredLimitOrdersAtBlockGasLimit() {
now := time.Now().UTC()
ctx := s.Ctx.WithBlockTime(now)
gasLimit := 1000000
ctx = ctx.WithBlockGasMeter(sdk.NewGasMeter(uint64(gasLimit)))
ctx = ctx.WithBlockGasMeter(storetypes.NewGasMeter(uint64(gasLimit)))
timeRequiredToPurgeOneNonJIT := 35000
gasUsed := gasLimit - types.GoodTilPurgeGasBuffer - timeRequiredToPurgeOneNonJIT

Expand All @@ -160,7 +161,7 @@ func (s *DexTestSuite) TestPurgeExpiredLimitOrdersAtBlockGasLimit() {
createLimitOrderExpirationAndTranches(&keeper, ctx, expTimes)

// IF blockGasMeter is nearing the GoodTilPurgeBuffer
ctx = ctx.WithGasMeter(sdk.NewGasMeter(uint64(gasLimit)))
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(uint64(gasLimit)))
ctx.BlockGasMeter().ConsumeGas(uint64(gasUsed), "stub block gas usage")

// WHEN PurgeExpiredLimitOrders is run
Expand All @@ -182,7 +183,7 @@ func (s *DexTestSuite) TestPurgeExpiredLimitOrdersAtBlockGasLimitOnlyJIT() {
now := time.Now().UTC()
ctx := s.Ctx.WithBlockTime(now)
gasLimt := 1000000
ctx = ctx.WithBlockGasMeter(sdk.NewGasMeter(uint64(gasLimt)))
ctx = ctx.WithBlockGasMeter(storetypes.NewGasMeter(uint64(gasLimt)))
gasUsed := gasLimt - types.GoodTilPurgeGasBuffer - 30000

expTimes := []time.Time{
Expand All @@ -196,7 +197,7 @@ func (s *DexTestSuite) TestPurgeExpiredLimitOrdersAtBlockGasLimitOnlyJIT() {
}

createLimitOrderExpirationAndTranches(&keeper, ctx, expTimes)
ctx = ctx.WithGasMeter(sdk.NewGasMeter(100000))
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(100000))
ctx.BlockGasMeter().ConsumeGas(uint64(gasUsed), "stub block gas usage")
keeper.PurgeExpiredLimitOrders(ctx, now)

Expand Down

0 comments on commit ccad95c

Please sign in to comment.