Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing linting errors #919

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions testutil/simapp/simapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
dbm "github.com/cometbft/cometbft-db"
tmdb "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
Expand Down Expand Up @@ -39,7 +38,7 @@ func New(t *testing.T) *stargazeapp.App {
t.Helper()

dir := t.TempDir()
db := tmdb.NewMemDB()
db := dbm.NewMemDB()
logger := log.NewNopLogger()
encoding := stargazeapp.MakeEncodingConfig()

Expand Down Expand Up @@ -98,7 +97,7 @@ var defaultConsensusParams = &tmproto.ConsensusParams{
}

func setup(withGenesis bool, invCheckPeriod uint, dir string) (*stargazeapp.App, stargazeapp.GenesisState) {
db := tmdb.NewMemDB()
db := dbm.NewMemDB()
encoding := stargazeapp.MakeEncodingConfig()
a := stargazeapp.NewStargazeApp(log.NewNopLogger(), db, nil, true,
map[int64]bool{}, dir, invCheckPeriod, encoding, simapp.EmptyAppOptions{}, stargazeapp.EmptyWasmOpts)
Expand Down Expand Up @@ -228,7 +227,7 @@ func genesisStateWithValSet(t *testing.T,
// the parameter 'expPass' against the result. A corresponding result is
// returned.
func SignCheckDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, _ tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, simulate bool, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
t.Helper()
Expand Down
23 changes: 14 additions & 9 deletions x/alloc/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type KeeperTestSuite struct {
func (suite *KeeperTestSuite) SetupTest() {
suite.app = simapp.New(suite.T())
suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "stargaze-1", Time: time.Now().UTC()})
suite.app.AllocKeeper.SetParams(suite.ctx, types.DefaultParams())
err := suite.app.AllocKeeper.SetParams(suite.ctx, types.DefaultParams())
suite.Require().NoError(err)
}

func TestKeeperTestSuite(t *testing.T) {
Expand Down Expand Up @@ -56,9 +57,10 @@ func (suite *KeeperTestSuite) TestZeroAllocation() {

params.DistributionProportions.NftIncentives = sdk.ZeroDec()

suite.app.AllocKeeper.SetParams(suite.ctx, params)
err := suite.app.AllocKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

err := allocKeeper.DistributeInflation(suite.ctx)
err = allocKeeper.DistributeInflation(suite.ctx)
suite.Require().NoError(err)
}

Expand Down Expand Up @@ -91,7 +93,8 @@ func (suite *KeeperTestSuite) TestDistribution() {
Weight: sdk.NewDec(1),
},
}
suite.app.AllocKeeper.SetParams(suite.ctx, params)
err := suite.app.AllocKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

feePool := suite.app.DistrKeeper.GetFeePool(suite.ctx)
feeCollector := suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName)
Expand All @@ -118,7 +121,7 @@ func (suite *KeeperTestSuite) TestDistribution() {
sdk.NewDec(0),
feePool.CommunityPool.AmountOf(denom))

err := allocKeeper.DistributeInflation(suite.ctx)
err = allocKeeper.DistributeInflation(suite.ctx)
suite.Require().NoError(err)

feeCollector = suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName)
Expand Down Expand Up @@ -168,7 +171,8 @@ func (suite *KeeperTestSuite) TestFairburnPool() {
Weight: sdk.NewDec(1),
},
}
allocKeeper.SetParams(suite.ctx, params)
err := allocKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)
fundAmount := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(100_000_000)))

fairBurnPool := suite.app.AccountKeeper.GetModuleAddress(types.FairburnPoolName)
Expand All @@ -177,7 +181,7 @@ func (suite *KeeperTestSuite) TestFairburnPool() {
// should be 0
suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, fairBurnPool, denom).IsZero())
suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, feeCollector, denom).IsZero())
err := allocKeeper.DistributeInflation(suite.ctx)
err = allocKeeper.DistributeInflation(suite.ctx)
suite.Require().NoError(err)

// should be 0
Expand Down Expand Up @@ -232,7 +236,8 @@ func (suite *KeeperTestSuite) TestDistributionWithSupplement() {
Weight: sdk.NewDec(1),
},
}
suite.app.AllocKeeper.SetParams(suite.ctx, params)
err := suite.app.AllocKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)
suite.Require().False(suite.app.AllocKeeper.GetParams(suite.ctx).SupplementAmount.IsZero())

feePool := suite.app.DistrKeeper.GetFeePool(suite.ctx)
Expand Down Expand Up @@ -268,7 +273,7 @@ func (suite *KeeperTestSuite) TestDistributionWithSupplement() {
sdk.NewDec(0),
feePool.CommunityPool.AmountOf(denom))

err := allocKeeper.DistributeInflation(suite.ctx)
err = allocKeeper.DistributeInflation(suite.ctx)
suite.Require().NoError(err)

feeCollector = suite.app.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName)
Expand Down
8 changes: 5 additions & 3 deletions x/cron/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func TestPromoteToPrivilegedContract(t *testing.T) {

params := types.DefaultParams()
params.AdminAddresses = []string{sender.String()}
keeper.SetParams(ctx, params)
err := keeper.SetParams(ctx, params)
require.NoError(t, err)

msg := types.MsgPromoteToPrivilegedContract{
Authority: sender.String(),
Expand Down Expand Up @@ -182,10 +183,11 @@ func TestDemoteFromPrivilegedContract(t *testing.T) {
sender := sample.AccAddress()
params := types.DefaultParams()
params.AdminAddresses = []string{sender.String()}
keeper.SetParams(ctx, params)
err := keeper.SetParams(ctx, params)
require.NoError(t, err)

contractAddr := "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"
err := keeper.SetPrivileged(ctx, sdk.MustAccAddressFromBech32(contractAddr))
err = keeper.SetPrivileged(ctx, sdk.MustAccAddressFromBech32(contractAddr))
require.NoError(t, err)

msg := types.MsgDemoteFromPrivilegedContract{
Expand Down
33 changes: 18 additions & 15 deletions x/globalfee/ante/fee_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ type storeCache struct {
var contractsCache = storeCache{contracts: make(map[string][]byte)}

func (s *AnteHandlerTestSuite) SetupTest() {
_, _, acc1_addr := getTestAccount()
_, _, acc2_addr := getTestAccount()
_, _, acc1Addr := getTestAccount()
_, _, acc2Addr := getTestAccount()
genAccounts := authtypes.GenesisAccounts{
&authtypes.BaseAccount{Address: acc1_addr.String()},
&authtypes.BaseAccount{Address: acc2_addr.String()},
&authtypes.BaseAccount{Address: acc1Addr.String()},
&authtypes.BaseAccount{Address: acc2Addr.String()},
}
genBalances := []banktypes.Balance{
{
Address: acc1_addr.String(),
Address: acc1Addr.String(),
Coins: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 5_000_000_000)),
},
{
Address: acc2_addr.String(),
Address: acc2Addr.String(),
Coins: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 5_000_000_000)),
},
}
Expand All @@ -75,7 +75,9 @@ func (s *AnteHandlerTestSuite) SetupTest() {
}

func (s *AnteHandlerTestSuite) SetupTestGlobalFeeStoreAndMinGasPrice(minGasPrice []sdk.DecCoin, globalFees sdk.DecCoins) (ante.FeeDecorator, sdk.AnteHandler) {
s.app.GlobalFeeKeeper.SetParams(s.ctx, types.Params{MinimumGasPrices: globalFees})
err := s.app.GlobalFeeKeeper.SetParams(s.ctx, types.Params{MinimumGasPrices: globalFees})
s.Require().NoError(err)

s.ctx = s.ctx.WithMinGasPrices(minGasPrice).WithIsCheckTx(true)

// build fee decorator
Expand All @@ -90,24 +92,25 @@ func (s *AnteHandlerTestSuite) SetupTestGlobalFeeStoreAndMinGasPrice(minGasPrice
func (s *AnteHandlerTestSuite) SetupWasmMsgServer() {
wasmParams := s.app.WasmKeeper.GetParams(s.ctx)
wasmParams.CodeUploadAccess = wasmtypes.AllowEverybody
s.app.WasmKeeper.SetParams(s.ctx, wasmParams)
err := s.app.WasmKeeper.SetParams(s.ctx, wasmParams)
s.Require().NoError(err)
s.msgServer = wasmkeeper.NewMsgServerImpl(&s.app.WasmKeeper)
}

func (s *AnteHandlerTestSuite) SetupContractWithCodeAuth(senderAddr string, contractBinary string, authMethods []string) string {
codeId, err := storeContract(s.ctx, s.msgServer, senderAddr, contractBinary)
codeID, err := storeContract(s.ctx, s.msgServer, senderAddr, contractBinary)
s.Require().NoError(err)

instantiageMsg := CounterInsantiateMsg{Count: 0}
instantiateMsgRaw, err := json.Marshal(&instantiageMsg)
s.Require().NoError(err)

initMsg := wasmtypes.MsgInstantiateContract{Sender: senderAddr, Admin: senderAddr, CodeID: codeId, Label: "Counter Contract", Msg: instantiateMsgRaw, Funds: sdk.NewCoins()}
initMsg := wasmtypes.MsgInstantiateContract{Sender: senderAddr, Admin: senderAddr, CodeID: codeID, Label: "Counter Contract", Msg: instantiateMsgRaw, Funds: sdk.NewCoins()}
instantiateRes, err := s.msgServer.InstantiateContract(sdk.WrapSDKContext(s.ctx), &initMsg)
s.Require().NoError(err)

err = s.app.GlobalFeeKeeper.SetCodeAuthorization(s.ctx, types.CodeAuthorization{
CodeID: codeId,
CodeID: codeID,
Methods: authMethods,
})
s.Require().NoError(err)
Expand All @@ -116,14 +119,14 @@ func (s *AnteHandlerTestSuite) SetupContractWithCodeAuth(senderAddr string, cont
}

func (s *AnteHandlerTestSuite) SetupContractWithContractAuth(senderAddr string, contractBinary string, authMethods []string) string {
codeId, err := storeContract(s.ctx, s.msgServer, senderAddr, contractBinary)
codeID, err := storeContract(s.ctx, s.msgServer, senderAddr, contractBinary)
s.Require().NoError(err)

instantiageMsg := CounterInsantiateMsg{Count: 0}
instantiateMsgRaw, err := json.Marshal(&instantiageMsg)
s.Require().NoError(err)

initMsg := wasmtypes.MsgInstantiateContract{Sender: senderAddr, Admin: senderAddr, CodeID: codeId, Label: "Counter Contract", Msg: instantiateMsgRaw, Funds: sdk.NewCoins()}
initMsg := wasmtypes.MsgInstantiateContract{Sender: senderAddr, Admin: senderAddr, CodeID: codeID, Label: "Counter Contract", Msg: instantiateMsgRaw, Funds: sdk.NewCoins()}
instantiateRes, err := s.msgServer.InstantiateContract(sdk.WrapSDKContext(s.ctx), &initMsg)
s.Require().NoError(err)

Expand All @@ -137,7 +140,7 @@ func (s *AnteHandlerTestSuite) SetupContractWithContractAuth(senderAddr string,
}

func (s *AnteHandlerTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
var sigsV2 []signing.SignatureV2
var sigsV2 []signing.SignatureV2 //nolint:golint,prealloc
for i, priv := range privs {
sigV2 := signing.SignatureV2{
PubKey: priv.PubKey(),
Expand Down Expand Up @@ -199,7 +202,7 @@ func storeContract(ctx sdk.Context, msgServer wasmtypes.MsgServer, creator strin
return res.CodeID, nil
}

func getTestAccount() (privateKey secp256k1.PrivKey, publicKey crypto.PubKey, accountAddress sdk.AccAddress) {
func getTestAccount() (privateKey secp256k1.PrivKey, publicKey crypto.PubKey, accountAddress sdk.AccAddress) { //nolint:golint,unparam
privateKey = secp256k1.GenPrivKey()
publicKey = privateKey.PubKey()
accountAddress = sdk.AccAddress(publicKey.Address())
Expand Down