Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjunLi committed May 5, 2023
1 parent efedf36 commit ec2cf03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions testutil/keeper/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"testing"
"time"

"cosmossdk.io/log"
"cosmossdk.io/store"
Expand Down Expand Up @@ -161,6 +162,7 @@ func StorageKeeper(t testing.TB) (*keeper.Keeper, StorageDepKeepers, sdk.Context
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil, log.NewNopLogger())
ctx = ctx.WithBlockTime(time.Now())

// Initialize params
err := k.SetParams(ctx, types.DefaultParams())
Expand Down
2 changes: 1 addition & 1 deletion x/storage/keeper/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (k Keeper) GetObjectLockFee(ctx sdk.Context, primarySpAddress string, price
func (k Keeper) GetChargeSize(ctx sdk.Context, payloadSize uint64, ts int64) (size uint64, err error) {
params, err := k.GetParamsWithTs(ctx, ts)
if err != nil {
return size, fmt.Errorf("get charge size failed: %w", err)
return size, fmt.Errorf("get charge size failed, ts:%d, error: %w", ts, err)
}
minChargeSize := params.MinChargeSize
if payloadSize < minChargeSize {
Expand Down
4 changes: 2 additions & 2 deletions x/storage/keeper/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *IntegrationTestSuiteWithoutMock) SetupTest() {
}

func (s *IntegrationTestSuiteWithoutMock) TestCreateCreateBucket_Payment() {
ctx := s.ctx
ctx := s.ctx.WithBlockTime(time.Now())
// mock create bucket
ChargedReadQuota := uint64(1000)
bucket := types.BucketInfo{
Expand All @@ -101,7 +101,7 @@ func (s *IntegrationTestSuiteWithoutMock) TestCreateCreateBucket_Payment() {
bucket.BillingInfo.PriceTime = t2
object := types.ObjectInfo{
PayloadSize: 100,
CreateAt: t2,
CreateAt: ctx.BlockTime().Unix(),
}
err = s.keeper.LockStoreFee(ctx, &bucket, &object)
s.Require().NoError(err)
Expand Down

0 comments on commit ec2cf03

Please sign in to comment.