Skip to content

Commit

Permalink
fix some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Jun 20, 2023
1 parent ce9888a commit 06b468e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
10 changes: 6 additions & 4 deletions x/storage/keeper/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func (s *TestSuite) TestGetObjectLockFee() {
params := paymenttypes.DefaultParams()
s.paymentKeeper.EXPECT().GetParams(gomock.Any()).
Return(params).AnyTimes()
s.paymentKeeper.EXPECT().GetVersionedParamsWithTs(gomock.Any(), gomock.Any()).
Return(params.VersionedParams, nil).AnyTimes()

// verify lock fee calculation
payloadSize := int64(10 * 1024 * 1024)
Expand Down Expand Up @@ -148,8 +150,8 @@ func (s *TestSuite) TestGetBucketBill() {
s.paymentKeeper.EXPECT().GetStoragePrice(gomock.Any(), gomock.Any()).
Return(price, nil).AnyTimes()
params := paymenttypes.DefaultParams()
s.paymentKeeper.EXPECT().GetParams(gomock.Any()).
Return(params).AnyTimes()
s.paymentKeeper.EXPECT().GetVersionedParamsWithTs(gomock.Any(), gomock.Any()).
Return(params.VersionedParams, nil).AnyTimes()

// empty bucket, zero read quota
bucketInfo := &types.BucketInfo{
Expand Down Expand Up @@ -186,7 +188,7 @@ func (s *TestSuite) TestGetBucketBill() {
readRate := price.ReadPrice.MulInt64(int64(bucketInfo.ChargedReadQuota)).TruncateInt()
s.Require().Equal(flows.Flows[0].ToAddress, gvgFamily.VirtualPaymentAddress)
s.Require().Equal(flows.Flows[0].Rate, readRate)
taxPoolRate := s.paymentKeeper.GetParams(s.ctx).VersionedParams.ValidatorTaxRate.MulInt(readRate).TruncateInt()
taxPoolRate := params.VersionedParams.ValidatorTaxRate.MulInt(readRate).TruncateInt()
s.Require().Equal(flows.Flows[1].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String())
s.Require().Equal(flows.Flows[1].Rate, taxPoolRate)

Expand Down Expand Up @@ -263,7 +265,7 @@ func (s *TestSuite) TestGetBucketBill() {
s.Require().Equal(flows.Flows[2].Rate, readRate.Add(primaryStoreRate))

totalRate := readRate.Add(primaryStoreRate).Add(gvg1StoreRate).Add(gvg2StoreRate)
taxPoolRate = s.paymentKeeper.GetParams(s.ctx).VersionedParams.ValidatorTaxRate.MulInt(totalRate).TruncateInt()
taxPoolRate = params.VersionedParams.ValidatorTaxRate.MulInt(totalRate).TruncateInt()
s.Require().Equal(flows.Flows[3].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String())
s.Require().Equal(flows.Flows[3].Rate, taxPoolRate)
}
2 changes: 1 addition & 1 deletion x/storage/types/message_complete_migrate_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (msg *MsgCompleteMigrateBucket) GetSignBytes() []byte {
}

func (msg *MsgCompleteMigrateBucket) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Operator)
_, err := sdk.AccAddressFromHexUnsafe(msg.Operator)
if err != nil {
return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
Expand Down
6 changes: 4 additions & 2 deletions x/storage/types/message_complete_migrate_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ func TestMsgCompleteMigrateBucket_ValidateBasic(t *testing.T) {
{
name: "invalid address",
msg: MsgCompleteMigrateBucket{
Operator: "invalid_address",
Operator: "invalid_address",
BucketName: "bucketname",
},
err: sdkerrors.ErrInvalidAddress,
}, {
name: "valid address",
msg: MsgCompleteMigrateBucket{
Operator: sample.AccAddress(),
Operator: sample.AccAddress(),
BucketName: "bucketname",
},
},
}
Expand Down
6 changes: 4 additions & 2 deletions x/storage/types/message_migrate_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ func TestMsgMigrateBucket_ValidateBasic(t *testing.T) {
{
name: "invalid address",
msg: MsgMigrateBucket{
Operator: "invalid_address",
Operator: "invalid_address",
BucketName: "bucketname",
},
err: sdkerrors.ErrInvalidAddress,
}, {
name: "valid address",
msg: MsgMigrateBucket{
Operator: sample.AccAddress(),
Operator: sample.AccAddress(),
BucketName: "bucketname",
},
},
}
Expand Down

0 comments on commit 06b468e

Please sign in to comment.