Skip to content

Commit

Permalink
More linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Mar 15, 2024
1 parent 426819d commit f1f06a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 202 deletions.
190 changes: 0 additions & 190 deletions x/addresses/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,193 +135,3 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() {
evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr)
require.Nil(evmResult)
}

//// Unhappy path tests for BeginAuction
//func (suite *KeeperTestSuite) TestUnhappyPathsForBeginAuction() {
// ctx, addressesKeeper := suite.ctx, suite.addressesKeeper
// require := suite.Require()
//
// // Define basic param(s)
// addressesParams := addressTypes.DefaultParams()
// addressesKeeper.setParams(ctx, addressesParams)
//
// // Setup some token prices
// sommPrice := addressTypes.TokenPrice{Denom: params.BaseCoinUnit, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 2}
//
// /* #nosec */
// saleToken := "gravity0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d"
// saleTokenPrice := addressTypes.TokenPrice{Denom: saleToken, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 5}
// addressesedSaleTokens := sdk.NewCoin(saleToken, sdk.NewInt(10000))
//
// tests := []struct {
// name string
// beginAuctionRequest BeginAuctionRequest
// expectedError error
// runsBefore runsBeforeWrapper
// }{
// {
// name: "Unpermissioned funder module account",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: "cork",
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedFundingModule, "Module Account: cork"),
// runsBefore: func() {},
// },
// {
// name: "Unpermissioned proceeds module account",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: "gravity",
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedProceedsModule, "Module Account: gravity"),
// runsBefore: func() {},
// },
// {
// name: "Starting denom price not found",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: sdk.NewCoin("anvil", sdk.NewInt(7)),
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrCouldNotFindSaleTokenPrice, "starting amount denom: anvil"),
// runsBefore: func() {},
// },
// {
// name: "Starting denom price update too old",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx.WithBlockHeight(int64(saleTokenPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1),
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrLastSaleTokenPriceTooOld, "starting amount denom: %s", saleToken),
// runsBefore: func() {
// addressesKeeper.setTokenPrice(ctx, saleTokenPrice)
// },
// },
// {
// name: "Usomm price not found",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrap(addressTypes.ErrCouldNotFindSommTokenPrice, params.BaseCoinUnit),
// runsBefore: func() {},
// },
// {
// name: "Usomm price update too old",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx.WithBlockHeight(int64(sommPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1),
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrap(addressTypes.ErrLastSommTokenPriceTooOld, params.BaseCoinUnit),
// runsBefore: func() {
// addressesKeeper.setTokenPrice(ctx, sommPrice)
// },
// },
// {
// name: "Validate basic canary 1 -- invalid initialPriceDecreaseRate lower bound",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.0"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 0.000000000000000000"),
// runsBefore: func() {},
// },
// {
// name: "Validate basic canary 2 -- invalid initialPriceDecreaseRate upper bound",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("1.0"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 1.000000000000000000"),
// runsBefore: func() {},
// },
// {
// name: "Cannot have 2 ongoing addressess for the same denom",
// beginAuctionRequest: BeginAuctionRequest{
// ctx: ctx,
// startingTokensForSale: addressesedSaleTokens,
// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"),
// priceDecreaseBlockInterval: uint64(10),
// fundingModuleAccount: permissionedFunder.GetName(),
// proceedsModuleAccount: permissionedReciever.GetName(),
// },
// expectedError: errorsmod.Wrapf(addressTypes.ErrCannotStartTwoAuctionsForSameDenomSimultaneously, "Denom: %s", addressesedSaleTokens.Denom),
// runsBefore: func() {
// // Mock initial bank keeper fund transfer
// suite.mockSendCoinsFromModuleToModule(ctx, permissionedFunder.GetName(), addressTypes.ModuleName, sdk.NewCoins(addressesedSaleTokens))
//
// // Start addresses
// decreaseRate := sdk.MustNewDecFromStr("0.05")
// blockDecreaseInterval := uint64(5)
// err := addressesKeeper.BeginAuction(ctx, addressesedSaleTokens, decreaseRate, blockDecreaseInterval, permissionedFunder.GetName(), permissionedReciever.GetName())
// require.Nil(err)
//
// // Verify addresses got added to active addresses store
// addressesID := uint32(1)
// createdAuction, found := addressesKeeper.GetActiveAuctionByID(ctx, addressesID)
// require.True(found)
// },
// },
// }
//
// for _, tc := range tests {
// tc := tc // Redefine variable here due to passing it to function literal below (scopelint)
// suite.T().Run(fmt.Sprint(tc.name), func(t *testing.T) {
// // Run expected bank keeper functions, if any
// tc.runsBefore()
//
// call := func() error {
// return addressesKeeper.BeginAuction(
// tc.beginAuctionRequest.ctx,
// tc.beginAuctionRequest.startingTokensForSale,
// tc.beginAuctionRequest.initialPriceDecreaseRate,
// tc.beginAuctionRequest.priceDecreaseBlockInterval,
// tc.beginAuctionRequest.fundingModuleAccount,
// tc.beginAuctionRequest.proceedsModuleAccount,
// )
// }
//
// if tc.name[0:14] == "Validate basic" {
// require.Panics(func() { call() })
// return
// }
//
// err := call()
//
// // Verify errors are as expected
// require.Equal(tc.expectedError.Error(), err.Error())
// })
// }
//}
2 changes: 1 addition & 1 deletion x/addresses/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func DefaultGenesisState() GenesisState {
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
gs.Params.ValidateBasic()
// gs.Params.ValidateBasic()

for _, mapping := range gs.AddressMappings {
if err := mapping.ValidateBasic(); err != nil {
Expand Down
14 changes: 6 additions & 8 deletions x/addresses/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ func TestGenesisState_Validate(t *testing.T) {
}

for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
err := tc.genState.Validate()
if tc.valid {
require.NoError(t, err)
} else {
require.Error(t, err)
}
})
err := tc.genState.Validate()
if tc.valid {
require.NoError(t, err)
} else {
require.Error(t, err)
}
}
}
6 changes: 3 additions & 3 deletions x/addresses/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
}

// Validate validates the set of params
func (p Params) ValidateBasic() error {
return nil
}
// func (p Params) ValidateBasic() error {
// return nil
// }

0 comments on commit f1f06a8

Please sign in to comment.