diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index d512c90f..7bfcbd9e 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -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()) -// }) -// } -//} diff --git a/x/addresses/types/genesis.go b/x/addresses/types/genesis.go index cd40dc80..370b5f07 100644 --- a/x/addresses/types/genesis.go +++ b/x/addresses/types/genesis.go @@ -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 { diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index 354428ff..8a14134b 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -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) + } } } diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go index 7cfc4e7f..e61c8c15 100644 --- a/x/addresses/types/params.go +++ b/x/addresses/types/params.go @@ -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 +// }