From 989dcd03aac094c1d6cf8ed7c4af0e56e25a265c Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 27 Jul 2022 18:46:38 +0700 Subject: [PATCH] gofumpt for v2.2.x (#1738) --- modules/apps/transfer/keeper/grpc_query.go | 2 - .../apps/transfer/keeper/grpc_query_test.go | 1 - modules/apps/transfer/keeper/keeper.go | 1 - .../apps/transfer/keeper/mbt_relay_test.go | 2 +- modules/apps/transfer/keeper/relay.go | 1 - modules/apps/transfer/keeper/relay_test.go | 84 ++++++++++++------- modules/apps/transfer/module_test.go | 6 -- .../apps/transfer/simulation/genesis_test.go | 1 - modules/apps/transfer/types/ack_test.go | 1 - modules/apps/transfer/types/coin.go | 1 - modules/core/02-client/keeper/client.go | 3 +- modules/core/02-client/keeper/client_test.go | 3 - modules/core/02-client/keeper/grpc_query.go | 2 - .../core/02-client/keeper/grpc_query_test.go | 31 ++++--- .../core/02-client/keeper/proposal_test.go | 4 +- modules/core/02-client/legacy/v100/genesis.go | 2 - .../02-client/legacy/v100/genesis_test.go | 3 - .../core/02-client/proposal_handler_test.go | 1 - modules/core/02-client/types/client_test.go | 4 +- modules/core/02-client/types/codec_test.go | 1 - modules/core/02-client/types/encoding_test.go | 2 - modules/core/02-client/types/genesis.go | 1 - modules/core/02-client/types/height_test.go | 1 - modules/core/02-client/types/msgs.go | 4 +- modules/core/02-client/types/msgs_test.go | 2 - modules/core/02-client/types/proposal_test.go | 2 - .../core/03-connection/client/utils/utils.go | 2 - .../core/03-connection/keeper/grpc_query.go | 2 - .../03-connection/keeper/grpc_query_test.go | 12 ++- .../03-connection/keeper/handshake_test.go | 2 - .../core/03-connection/keeper/keeper_test.go | 1 - modules/core/03-connection/types/codec.go | 14 ++-- .../core/03-connection/types/genesis_test.go | 1 - modules/core/03-connection/types/msgs_test.go | 9 +- .../core/03-connection/types/version_test.go | 1 - modules/core/04-channel/client/utils/utils.go | 2 - modules/core/04-channel/keeper/grpc_query.go | 8 +- .../core/04-channel/keeper/grpc_query_test.go | 21 +++-- modules/core/04-channel/keeper/packet_test.go | 2 - .../core/04-channel/keeper/timeout_test.go | 1 - .../core/05-port/keeper/grpc_query_test.go | 2 - .../core/23-commitment/types/merkle_test.go | 2 - modules/core/ante/ante.go | 1 - modules/core/keeper/keeper.go | 8 +- modules/core/keeper/keeper_test.go | 5 -- modules/core/keeper/msg_server.go | 8 +- modules/core/keeper/msg_server_test.go | 3 - .../06-solomachine/types/client_state_test.go | 3 - .../06-solomachine/types/codec_test.go | 4 - .../types/consensus_state_test.go | 1 - .../types/misbehaviour_handle.go | 3 - .../types/misbehaviour_handle_test.go | 1 - .../06-solomachine/types/misbehaviour_test.go | 1 - .../06-solomachine/types/proof.go | 3 +- .../06-solomachine/types/proposal_handle.go | 1 - .../06-solomachine/types/update_test.go | 1 - .../07-tendermint/types/client_state_test.go | 5 +- .../types/consensus_state_test.go | 36 +++++--- .../07-tendermint/types/header_test.go | 4 +- .../types/misbehaviour_handle.go | 1 - .../types/proposal_handle_test.go | 8 +- .../07-tendermint/types/store.go | 1 - .../07-tendermint/types/upgrade_test.go | 4 +- .../09-localhost/types/client_state_test.go | 3 - .../09-localhost/types/localhost_test.go | 4 +- testing/chain.go | 6 +- testing/coordinator.go | 2 - testing/endpoint.go | 5 +- testing/simapp/app.go | 3 +- testing/simapp/params/amino.go | 1 + testing/simapp/params/proto.go | 1 + testing/simapp/sim_test.go | 6 +- testing/simapp/simd/cmd/genaccounts_test.go | 3 +- testing/simapp/simd/cmd/root.go | 4 +- testing/simapp/simd/cmd/testnet.go | 9 +- testing/simapp/state.go | 1 - testing/simapp/test_helpers.go | 1 - testing/simapp/utils.go | 4 +- 78 files changed, 175 insertions(+), 228 deletions(-) diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index dddca4a24f3..a0b79063cbb 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -24,7 +24,6 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) } hash, err := types.ParseHexHash(strings.TrimPrefix(req.Hash, "ibc/")) - if err != nil { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", hash.String(), err)) } @@ -63,7 +62,6 @@ func (q Keeper) DenomTraces(c context.Context, req *types.QueryDenomTracesReques traces = append(traces, result) return nil }) - if err != nil { return nil, err } diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index ece18be1b06..b20bff092ed 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -155,7 +155,6 @@ func (suite *KeeperTestSuite) TestQueryParams() { } func (suite *KeeperTestSuite) TestQueryDenomHash() { - reqTrace := types.DenomTrace{ Path: "transfer/channelToA/transfer/channelToB", BaseDenom: "uatom", diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index f0533aa2e51..c3654d3f722 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -34,7 +34,6 @@ func NewKeeper( channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, ) Keeper { - // ensure ibc transfer module account is set if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic("the IBC transfer module account has not been set") diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index fb22f29dfc4..6c983014cb2 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { panic(fmt.Errorf("Failed to read model-based test files: %w", err)) } for _, file_info := range files { - var tlaTestCases = []TlaOnRecvPacketTestCase{} + tlaTestCases := []TlaOnRecvPacketTestCase{} if !strings.HasSuffix(file_info.Name(), ".json") { continue } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 0d8b2747ad0..790e4868e32 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -58,7 +58,6 @@ func (k Keeper) SendTransfer( timeoutHeight clienttypes.Height, timeoutTimestamp uint64, ) error { - if !k.GetSendEnabled(ctx) { return types.ErrSendDisabled } diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index f220fba1be2..0992987f43e 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -28,25 +28,32 @@ func (suite *KeeperTestSuite) TestSendTransfer() { sendFromSource bool expPass bool }{ - {"successful transfer from source chain", + { + "successful transfer from source chain", func() { suite.coordinator.CreateTransferChannels(path) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, true}, - {"successful transfer with coin from counterparty chain", + }, true, true, + }, + { + "successful transfer with coin from counterparty chain", func() { // send coin from chainA back to chainB suite.coordinator.CreateTransferChannels(path) amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom, sdk.NewInt(100)) - }, false, true}, - {"source channel not found", + }, false, true, + }, + { + "source channel not found", func() { // channel references wrong ID suite.coordinator.CreateTransferChannels(path) path.EndpointA.ChannelID = ibctesting.InvalidID amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, - {"next seq send not found", + }, true, false, + }, + { + "next seq send not found", func() { path.EndpointA.ChannelID = "channel-0" path.EndpointB.ChannelID = "channel-0" @@ -58,22 +65,28 @@ func (suite *KeeperTestSuite) TestSendTransfer() { ) suite.chainA.CreateChannelCapability(suite.chainA.GetSimApp().ScopedIBCMockKeeper, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, // createOutgoingPacket tests // - source chain - {"send coin failed", + { + "send coin failed", func() { suite.coordinator.CreateTransferChannels(path) amount = sdk.NewCoin("randomdenom", sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, // - receiving chain - {"send from module account failed", + { + "send from module account failed", func() { suite.coordinator.CreateTransferChannels(path) amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, " randomdenom", sdk.NewInt(100)) - }, false, false}, - {"channel capability not found", + }, false, false, + }, + { + "channel capability not found", func() { suite.coordinator.CreateTransferChannels(path) cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -81,7 +94,8 @@ func (suite *KeeperTestSuite) TestSendTransfer() { // Release channel capability suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, } for _, tc := range testCases { @@ -265,18 +279,22 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) }, false, true}, - {"unsuccessful refund from source", failedAck, + { + "unsuccessful refund from source", failedAck, func() { trace = types.ParseDenomTrace(sdk.DefaultBondDenom) - }, false, false}, - {"successful refund from with coin from external chain", failedAck, + }, false, false, + }, + { + "successful refund from with coin from external chain", failedAck, func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, false, true}, + }, false, true, + }, } for _, tc := range testCases { @@ -331,36 +349,46 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { malleate func() expPass bool }{ - {"successful timeout from sender as source chain", + { + "successful timeout from sender as source chain", func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(sdk.DefaultBondDenom) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, true}, - {"successful timeout from external chain", + }, true, + }, + { + "successful timeout from external chain", func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, true}, - {"no balance for coin denom", + }, true, + }, + { + "no balance for coin denom", func() { trace = types.ParseDenomTrace("bitcoin") - }, false}, - {"unescrow failed", + }, false, + }, + { + "unescrow failed", func() { trace = types.ParseDenomTrace(sdk.DefaultBondDenom) - }, false}, - {"mint failed", + }, false, + }, + { + "mint failed", func() { trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) amount = sdk.OneInt() sender = "invalid address" - }, false}, + }, false, + }, } for _, tc := range testCases { diff --git a/modules/apps/transfer/module_test.go b/modules/apps/transfer/module_test.go index f12707ad43b..fc522735ddb 100644 --- a/modules/apps/transfer/module_test.go +++ b/modules/apps/transfer/module_test.go @@ -22,7 +22,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -92,7 +91,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { } else { suite.Require().Error(err) } - }) } } @@ -110,7 +108,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -187,7 +184,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { } else { suite.Require().Error(err) } - }) } } @@ -200,7 +196,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -237,7 +232,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { } else { suite.Require().Error(err) } - }) } } diff --git a/modules/apps/transfer/simulation/genesis_test.go b/modules/apps/transfer/simulation/genesis_test.go index ff68cb4dac6..faf3be0c7bb 100644 --- a/modules/apps/transfer/simulation/genesis_test.go +++ b/modules/apps/transfer/simulation/genesis_test.go @@ -43,7 +43,6 @@ func TestRandomizedGenState(t *testing.T) { require.True(t, ibcTransferGenesis.Params.SendEnabled) require.True(t, ibcTransferGenesis.Params.ReceiveEnabled) require.Len(t, ibcTransferGenesis.DenomTraces, 0) - } // TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. diff --git a/modules/apps/transfer/types/ack_test.go b/modules/apps/transfer/types/ack_test.go index 96214a84ea9..825115a2e98 100644 --- a/modules/apps/transfer/types/ack_test.go +++ b/modules/apps/transfer/types/ack_test.go @@ -97,5 +97,4 @@ func (suite *TypesTestSuite) TestAcknowledgementError() { suite.Require().Equal(ack, ackSameABCICode) suite.Require().NotEqual(ack, ackDifferentABCICode) - } diff --git a/modules/apps/transfer/types/coin.go b/modules/apps/transfer/types/coin.go index a3491e2bf09..d6329541103 100644 --- a/modules/apps/transfer/types/coin.go +++ b/modules/apps/transfer/types/coin.go @@ -27,7 +27,6 @@ func ReceiverChainIsSource(sourcePort, sourceChannel, denom string) bool { voucherPrefix := GetDenomPrefix(sourcePort, sourceChannel) return strings.HasPrefix(denom, voucherPrefix) - } // GetDenomPrefix returns the receiving denomination prefix diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index dbd626e5063..ccca589b7ef 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -153,7 +153,8 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H // UpgradeClient upgrades the client to a new client state if this new client was committed to // by the old client at the specified upgrade height func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState, - proofUpgradeClient, proofUpgradeConsState []byte) error { + proofUpgradeClient, proofUpgradeConsState []byte, +) error { clientState, found := k.GetClientState(ctx, clientID) if !found { return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID) diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 66c95f456a7..45d9d35f62c 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -418,7 +418,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { suite.Require().Error(err, "verify upgrade passed on invalid case: %s", tc.name) } } - } func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { @@ -695,8 +694,6 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { suite.Require().NoError(err) suite.Require().Equal(header, emittedHeader) } - } suite.Require().True(contains) - } diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 3909b34ddfc..eb16a3e7b25 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -83,7 +83,6 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ clientStates = append(clientStates, identifiedClient) return nil }) - if err != nil { return nil, err } @@ -177,7 +176,6 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat consensusStates = append(consensusStates, types.NewConsensusStateWithHeight(height, consensusState)) return true, nil }) - if err != nil { return nil, err } diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 33b97cc1db1..82045420553 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -28,19 +28,22 @@ func (suite *KeeperTestSuite) TestQueryClientState() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, false, }, - {"invalid clientID", + { + "invalid clientID", func() { req = &types.QueryClientStateRequest{} }, false, }, - {"client not found", + { + "client not found", func() { req = &types.QueryClientStateRequest{ ClientId: testClientID, @@ -100,7 +103,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, @@ -190,7 +194,8 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, @@ -396,9 +401,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { } func (suite *KeeperTestSuite) TestQueryClientStatus() { - var ( - req *types.QueryClientStatusRequest - ) + var req *types.QueryClientStatusRequest testCases := []struct { msg string @@ -406,19 +409,22 @@ func (suite *KeeperTestSuite) TestQueryClientStatus() { expPass bool expStatus string }{ - {"req is nil", + { + "req is nil", func() { req = nil }, false, "", }, - {"invalid clientID", + { + "invalid clientID", func() { req = &types.QueryClientStatusRequest{} }, false, "", }, - {"client not found", + { + "client not found", func() { req = &types.QueryClientStatusRequest{ ClientId: ibctesting.InvalidID, @@ -503,7 +509,8 @@ func (suite *KeeperTestSuite) TestQueryUpgradedConsensusStates() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, diff --git a/modules/core/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index a9062ea2ead..4eaa9a64cbd 100644 --- a/modules/core/02-client/keeper/proposal_test.go +++ b/modules/core/02-client/keeper/proposal_test.go @@ -153,7 +153,6 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { } }) } - } func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { @@ -205,7 +204,7 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { suite.Run(tc.name, func() { suite.SetupTest() // reset - oldPlan.Height = 0 //reset + oldPlan.Height = 0 // reset path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) @@ -275,5 +274,4 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { } }) } - } diff --git a/modules/core/02-client/legacy/v100/genesis.go b/modules/core/02-client/legacy/v100/genesis.go index 0f514c0e799..56b5a7b31b9 100644 --- a/modules/core/02-client/legacy/v100/genesis.go +++ b/modules/core/02-client/legacy/v100/genesis.go @@ -123,13 +123,11 @@ func MigrateGenesis(cdc codec.BinaryCodec, clientGenState *types.GenesisState, g Key: ibctmtypes.IterationKey(height), Value: host.ConsensusStateKey(height), }) - } } } } - } // if we have metadata for unexipred consensus states, add it to consensusMetadata diff --git a/modules/core/02-client/legacy/v100/genesis_test.go b/modules/core/02-client/legacy/v100/genesis_test.go index 109a97715ce..43258415cb6 100644 --- a/modules/core/02-client/legacy/v100/genesis_test.go +++ b/modules/core/02-client/legacy/v100/genesis_test.go @@ -254,7 +254,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(height, consensusState.Height) } } - } for _, client := range migrated.ClientsMetadata { if client.ClientId == path1.EndpointA.ClientID { @@ -275,7 +274,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(height, consensusState.Height) } } - } for _, client := range migrated.ClientsMetadata { if client.ClientId == path2.EndpointA.ClientID { @@ -285,7 +283,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(ibctmtypes.IterationKey(height), metadata.Key) } } - } } bz, err := clientCtx.JSONCodec.MarshalJSON(&expectedClientGenState) diff --git a/modules/core/02-client/proposal_handler_test.go b/modules/core/02-client/proposal_handler_test.go index 1b6649552b1..ff54f9bb3af 100644 --- a/modules/core/02-client/proposal_handler_test.go +++ b/modules/core/02-client/proposal_handler_test.go @@ -83,5 +83,4 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() { } }) } - } diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 7d558d2edcb..474428b60a2 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -10,9 +10,7 @@ import ( ) func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() { - var ( - cswh types.ConsensusStateWithHeight - ) + var cswh types.ConsensusStateWithHeight testCases := []struct { name string diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index ced8979d2eb..4e9352e1f88 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -17,7 +17,6 @@ type caseAny struct { } func (suite *TypesTestSuite) TestPackClientState() { - testCases := []struct { name string clientState exported.ClientState diff --git a/modules/core/02-client/types/encoding_test.go b/modules/core/02-client/types/encoding_test.go index 9102da93a16..982812df171 100644 --- a/modules/core/02-client/types/encoding_test.go +++ b/modules/core/02-client/types/encoding_test.go @@ -6,7 +6,6 @@ import ( ) func (suite *TypesTestSuite) TestMarshalHeader() { - cdc := suite.chainA.App.AppCodec() h := &ibctmtypes.Header{ TrustedHeight: types.NewHeight(4, 100), @@ -26,5 +25,4 @@ func (suite *TypesTestSuite) TestMarshalHeader() { invalidHeader, err := types.UnmarshalHeader(cdc, []byte("invalid bytes")) suite.Require().Error(err) suite.Require().Nil(invalidHeader) - } diff --git a/modules/core/02-client/types/genesis.go b/modules/core/02-client/types/genesis.go index c366e2cafbe..7632ea128ed 100644 --- a/modules/core/02-client/types/genesis.go +++ b/modules/core/02-client/types/genesis.go @@ -195,7 +195,6 @@ func (gs GenesisState) Validate() error { if err := gm.Validate(); err != nil { return fmt.Errorf("invalid client metadata %v clientID %s index %d: %w", gm, clientMetadata.ClientId, i, err) } - } } diff --git a/modules/core/02-client/types/height_test.go b/modules/core/02-client/types/height_test.go index 08450f63ab7..4e3836f95ff 100644 --- a/modules/core/02-client/types/height_test.go +++ b/modules/core/02-client/types/height_test.go @@ -123,7 +123,6 @@ func TestParseChainID(t *testing.T) { revision := types.ParseChainID(tc.chainID) require.Equal(t, tc.revision, revision, "case %d returns incorrect revision", i) } - } func TestSetRevisionNumber(t *testing.T) { diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index 9eba4171b6c..d2a75086d14 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -33,7 +33,6 @@ var ( func NewMsgCreateClient( clientState exported.ClientState, consensusState exported.ConsensusState, signer string, ) (*MsgCreateClient, error) { - anyClientState, err := PackClientState(clientState) if err != nil { return nil, err @@ -153,7 +152,8 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err // NewMsgUpgradeClient creates a new MsgUpgradeClient instance // nolint: interfacer func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, consState exported.ConsensusState, - proofUpgradeClient, proofUpgradeConsState []byte, signer string) (*MsgUpgradeClient, error) { + proofUpgradeClient, proofUpgradeConsState []byte, signer string, +) (*MsgUpgradeClient, error) { anyClient, err := PackClientState(clientState) if err != nil { return nil, err diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index aa2bbf48dfc..0b4cff6636a 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -211,7 +211,6 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() { "tendermint client", func() { msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) - }, }, } @@ -496,7 +495,6 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) - }, }, } diff --git a/modules/core/02-client/types/proposal_test.go b/modules/core/02-client/types/proposal_test.go index fbf862a25fb..6291992a5dc 100644 --- a/modules/core/02-client/types/proposal_test.go +++ b/modules/core/02-client/types/proposal_test.go @@ -117,7 +117,6 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() { "fails validate abstract - empty title", func() { proposal, err = types.NewUpgradeProposal("", ibctesting.Description, plan, cs) suite.Require().NoError(err) - }, false, }, { @@ -199,7 +198,6 @@ func (suite *TypesTestSuite) TestMarshalUpgradeProposal() { // unpack client state _, err = types.UnpackClientState(newUp.UpgradedClientState) suite.Require().NoError(err) - } func (suite *TypesTestSuite) TestUpgradeString() { diff --git a/modules/core/03-connection/client/utils/utils.go b/modules/core/03-connection/client/utils/utils.go index 637b835ebdb..71013618765 100644 --- a/modules/core/03-connection/client/utils/utils.go +++ b/modules/core/03-connection/client/utils/utils.go @@ -105,7 +105,6 @@ func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*typ func QueryConnectionClientState( clientCtx client.Context, connectionID string, prove bool, ) (*types.QueryConnectionClientStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryConnectionClientStateRequest{ ConnectionId: connectionID, @@ -140,7 +139,6 @@ func QueryConnectionClientState( func QueryConnectionConsensusState( clientCtx client.Context, connectionID string, height clienttypes.Height, prove bool, ) (*types.QueryConnectionConsensusStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryConnectionConsensusStateRequest{ ConnectionId: connectionID, diff --git a/modules/core/03-connection/keeper/grpc_query.go b/modules/core/03-connection/keeper/grpc_query.go index 0f0b56cee26..bf2529d6850 100644 --- a/modules/core/03-connection/keeper/grpc_query.go +++ b/modules/core/03-connection/keeper/grpc_query.go @@ -68,7 +68,6 @@ func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsReques connections = append(connections, &identifiedConnection) return nil }) - if err != nil { return nil, err } @@ -137,7 +136,6 @@ func (q Keeper) ConnectionClientState(c context.Context, req *types.QueryConnect height := clienttypes.GetSelfHeight(ctx) return types.NewQueryConnectionClientStateResponse(identifiedClientState, nil, height), nil - } // ConnectionConsensusState implements the Query/ConnectionConsensusState gRPC method diff --git a/modules/core/03-connection/keeper/grpc_query_test.go b/modules/core/03-connection/keeper/grpc_query_test.go index 767cc6efc00..01b169f4e03 100644 --- a/modules/core/03-connection/keeper/grpc_query_test.go +++ b/modules/core/03-connection/keeper/grpc_query_test.go @@ -29,13 +29,15 @@ func (suite *KeeperTestSuite) TestQueryConnection() { }, false, }, - {"invalid connectionID", + { + "invalid connectionID", func() { req = &types.QueryConnectionRequest{} }, false, }, - {"connection not found", + { + "connection not found", func() { req = &types.QueryConnectionRequest{ ConnectionId: ibctesting.InvalidID, @@ -185,13 +187,15 @@ func (suite *KeeperTestSuite) TestQueryClientConnections() { }, false, }, - {"invalid connectionID", + { + "invalid connectionID", func() { req = &types.QueryClientConnectionsRequest{} }, false, }, - {"connection not found", + { + "connection not found", func() { req = &types.QueryClientConnectionsRequest{ ClientId: ibctesting.InvalidID, diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index dfcfb959fe6..348d851ad66 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -370,7 +370,6 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { tmClient.ChainId = "wrongchainid" suite.chainB.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainB.GetContext(), path.EndpointB.ClientID, tmClient) - }, false}, {"consensus height >= latest height", func() { err := path.EndpointA.ConnOpenInit() @@ -554,7 +553,6 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { err = path.EndpointB.ConnOpenTry() suite.Require().NoError(err) - }, false}, } diff --git a/modules/core/03-connection/keeper/keeper_test.go b/modules/core/03-connection/keeper/keeper_test.go index 9482d47e8a8..beeef6c7550 100644 --- a/modules/core/03-connection/keeper/keeper_test.go +++ b/modules/core/03-connection/keeper/keeper_test.go @@ -45,7 +45,6 @@ func (suite *KeeperTestSuite) TestSetAndGetConnection() { } func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) diff --git a/modules/core/03-connection/types/codec.go b/modules/core/03-connection/types/codec.go index 90292d004f6..44b441039af 100644 --- a/modules/core/03-connection/types/codec.go +++ b/modules/core/03-connection/types/codec.go @@ -37,11 +37,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -var ( - // SubModuleCdc references the global x/ibc/core/03-connection module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to x/ibc/core/03-connection and - // defined at the application level. - SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) -) +// SubModuleCdc references the global x/ibc/core/03-connection module codec. Note, the codec should +// ONLY be used in certain instances of tests and for JSON encoding. +// +// The actual codec used for serialization should be provided to x/ibc/core/03-connection and +// defined at the application level. +var SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) diff --git a/modules/core/03-connection/types/genesis_test.go b/modules/core/03-connection/types/genesis_test.go index 8fa61bba4c6..ee558d20e42 100644 --- a/modules/core/03-connection/types/genesis_test.go +++ b/modules/core/03-connection/types/genesis_test.go @@ -11,7 +11,6 @@ import ( ) func TestValidateGenesis(t *testing.T) { - testCases := []struct { name string genState types.GenesisState diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index ec5e79efc9b..7bfdadca001 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -69,7 +69,6 @@ func (suite *MsgTestSuite) SetupTest() { suite.Require().NoError(err) suite.proof = proof - } func TestMsgTestSuite(t *testing.T) { @@ -82,7 +81,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { // will be used in protocol. var version *types.Version - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenInit expPass bool @@ -125,7 +124,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenTry expPass bool @@ -177,7 +176,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { ) connectionID := "connection-0" - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenAck expPass bool @@ -216,7 +215,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, signer), } - var testCases = []struct { + testCases := []struct { msg *types.MsgConnectionOpenConfirm expPass bool errMsg string diff --git a/modules/core/03-connection/types/version_test.go b/modules/core/03-connection/types/version_test.go index d8cb122252b..5dafee5790d 100644 --- a/modules/core/03-connection/types/version_test.go +++ b/modules/core/03-connection/types/version_test.go @@ -141,7 +141,6 @@ func TestVerifyProposedVersion(t *testing.T) { require.Error(t, err, "test case %d: %s", i, tc.name) } } - } func TestVerifySupportedFeature(t *testing.T) { diff --git a/modules/core/04-channel/client/utils/utils.go b/modules/core/04-channel/client/utils/utils.go index 76b18898a62..6297afdd386 100644 --- a/modules/core/04-channel/client/utils/utils.go +++ b/modules/core/04-channel/client/utils/utils.go @@ -63,7 +63,6 @@ func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*type func QueryChannelClientState( clientCtx client.Context, portID, channelID string, prove bool, ) (*types.QueryChannelClientStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryChannelClientStateRequest{ PortId: portID, @@ -98,7 +97,6 @@ func QueryChannelClientState( func QueryChannelConsensusState( clientCtx client.Context, portID, channelID string, height clienttypes.Height, prove bool, ) (*types.QueryChannelConsensusStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryChannelConsensusStateRequest{ PortId: portID, diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index 64a281eaa8f..0b5b61e3399 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -69,7 +69,6 @@ func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*t channels = append(channels, &identifiedChannel) return nil }) - if err != nil { return nil, err } @@ -118,7 +117,6 @@ func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection channels = append(channels, &identifiedChannel) return nil }) - if err != nil { return nil, err } @@ -252,7 +250,6 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi commitments = append(commitments, &commitment) return nil }) - if err != nil { return nil, err } @@ -361,7 +358,6 @@ func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket return nil }) - if err != nil { return nil, err } @@ -401,7 +397,7 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP ctx := sdk.UnwrapSDKContext(c) - var unreceivedSequences = []uint64{} + unreceivedSequences := []uint64{} for i, seq := range req.PacketCommitmentSequences { if seq == 0 { @@ -450,7 +446,7 @@ func (q Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcks ctx := sdk.UnwrapSDKContext(c) - var unreceivedSequences = []uint64{} + unreceivedSequences := []uint64{} for i, seq := range req.PacketAckSequences { if seq == 0 { diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 9fdce2b14a1..9b79fbb71b6 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -50,7 +50,8 @@ func (suite *KeeperTestSuite) TestQueryChannel() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryChannelRequest{ PortId: "test-port-id", @@ -627,7 +628,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketCommitmentRequest{ PortId: "test-port-id", @@ -637,7 +639,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryPacketCommitmentRequest{ PortId: "test-port-id", @@ -818,7 +821,8 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketReceiptRequest{ PortId: "test-port-id", @@ -922,7 +926,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketAcknowledgementRequest{ PortId: "test-port-id", @@ -932,7 +937,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryPacketAcknowledgementRequest{ PortId: "test-port-id", @@ -1399,7 +1405,8 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryNextSequenceReceiveRequest{ PortId: "test-port-id", diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index a34d48b42df..ea63b729865 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -220,7 +220,6 @@ func (suite *KeeperTestSuite) TestSendPacket() { } }) } - } // TestRecvPacket test RecvPacket on chainB. Since packet commitment verification will always @@ -487,7 +486,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } }) } - } func (suite *KeeperTestSuite) TestWriteAcknowledgement() { diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index d54177d2b4d..cf716744e30 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -430,5 +430,4 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { } }) } - } diff --git a/modules/core/05-port/keeper/grpc_query_test.go b/modules/core/05-port/keeper/grpc_query_test.go index 87e0caccbbb..c89a0bddab9 100644 --- a/modules/core/05-port/keeper/grpc_query_test.go +++ b/modules/core/05-port/keeper/grpc_query_test.go @@ -49,7 +49,6 @@ func (suite *KeeperTestSuite) TestAppVersion() { { "version negotiation failure", func() { - expVersion = mock.Version req = &types.QueryAppVersionRequest{ @@ -66,7 +65,6 @@ func (suite *KeeperTestSuite) TestAppVersion() { { "success", func() { - expVersion = mock.Version req = &types.QueryAppVersionRequest{ diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index 28724f11f7f..75f8c03648d 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -72,7 +72,6 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { } }) } - } func (suite *MerkleTestSuite) TestVerifyNonMembership() { @@ -136,7 +135,6 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { } }) } - } func TestApplyPrefix(t *testing.T) { diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index 3eccfbc058a..a735634f442 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -60,7 +60,6 @@ func (ad AnteDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne // even if they get batched with redundant packet messages. return next(ctx, tx, simulate) } - } // only return error if all packet messages are redundant diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index f2128d10284..293849ccc11 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -51,12 +51,12 @@ func NewKeeper( // panic if any of the keepers passed in is empty if reflect.ValueOf(stakingKeeper).IsZero() { panic(fmt.Errorf("cannot initialize IBC keeper: empty staking keeper")) - } - + } + if reflect.ValueOf(upgradeKeeper).IsZero() { panic(fmt.Errorf("cannot initialize IBC keeper: empty upgrade keeper")) - } - + } + if reflect.DeepEqual(capabilitykeeper.ScopedKeeper{}, scopedKeeper) { panic(fmt.Errorf("cannot initialize IBC keeper: empty scoped keeper")) } diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index 360e6b9ff12..0aa0f4458b0 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -84,20 +84,17 @@ func (suite *KeeperTestSuite) TestNewKeeper() { emptyStakingKeeper := stakingkeeper.Keeper{} stakingKeeper = emptyStakingKeeper - }, false}, {"failure: empty mock staking keeper", func() { // use a different implementation of clienttypes.StakingKeeper emptyMockStakingKeeper := MockStakingKeeper{} stakingKeeper = emptyMockStakingKeeper - }, false}, {"failure: empty upgrade keeper", func() { emptyUpgradeKeeper := upgradekeeper.Keeper{} upgradeKeeper = emptyUpgradeKeeper - }, false}, {"failure: empty scoped keeper", func() { emptyScopedKeeper := capabilitykeeper.ScopedKeeper{} @@ -117,7 +114,6 @@ func (suite *KeeperTestSuite) TestNewKeeper() { suite.SetupTest() suite.Run(tc.name, func() { - stakingKeeper = suite.chainA.GetSimApp().StakingKeeper upgradeKeeper = suite.chainA.GetSimApp().UpgradeKeeper scopedKeeper = suite.chainA.GetSimApp().ScopedIBCKeeper @@ -133,7 +129,6 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeper, ) } - }) } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 326e9ce9721..39597df9f0e 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -15,9 +15,11 @@ import ( coretypes "github.com/cosmos/ibc-go/v2/modules/core/types" ) -var _ clienttypes.MsgServer = Keeper{} -var _ connectiontypes.MsgServer = Keeper{} -var _ channeltypes.MsgServer = Keeper{} +var ( + _ clienttypes.MsgServer = Keeper{} + _ connectiontypes.MsgServer = Keeper{} + _ channeltypes.MsgServer = Keeper{} +) // CreateClient defines a rpc handler method for MsgCreateClient. func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index f8fbece3e16..d18ae044d8e 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -415,7 +415,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { path.EndpointA.UpdateClient() packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) - }, true}, {"channel does not exist", func() { // any non-nil value of packet is valid @@ -645,7 +644,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { { name: "successful upgrade", setup: func() { - upgradedClient = ibctmtypes.NewClientState(newChainId, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // Call ZeroCustomFields on upgraded clients to clear any client-chosen parameters in test-case upgradedClient upgradedClient = upgradedClient.ZeroCustomFields() @@ -686,7 +684,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { { name: "VerifyUpgrade fails", setup: func() { - upgradedClient = ibctmtypes.NewClientState(newChainId, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // Call ZeroCustomFields on upgraded clients to clear any client-chosen parameters in test-case upgradedClient upgradedClient = upgradedClient.ZeroCustomFields() diff --git a/modules/light-clients/06-solomachine/types/client_state_test.go b/modules/light-clients/06-solomachine/types/client_state_test.go index 3d52cf5f488..84f994ab2d4 100644 --- a/modules/light-clients/06-solomachine/types/client_state_test.go +++ b/modules/light-clients/06-solomachine/types/client_state_test.go @@ -82,7 +82,6 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() { tc := tc suite.Run(tc.name, func() { - err := tc.clientState.Validate() if tc.expPass { @@ -238,7 +237,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { tc := tc suite.Run(tc.name, func() { - var expSeq uint64 if tc.clientState.ConsensusState != nil { expSeq = tc.clientState.Sequence + 1 @@ -359,7 +357,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { tc := tc suite.Run(tc.name, func() { - var expSeq uint64 if tc.clientState.ConsensusState != nil { expSeq = tc.clientState.Sequence + 1 diff --git a/modules/light-clients/06-solomachine/types/codec_test.go b/modules/light-clients/06-solomachine/types/codec_test.go index 4a47045dc46..9e8a0cd35c9 100644 --- a/modules/light-clients/06-solomachine/types/codec_test.go +++ b/modules/light-clients/06-solomachine/types/codec_test.go @@ -55,7 +55,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { path := solomachine.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) data, err = types.ConsensusStateDataBytes(cdc, path, solomachine.ConsensusState()) suite.Require().NoError(err) - }, true, }, { @@ -73,7 +72,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { data, err = types.ConnectionStateDataBytes(cdc, path, conn) suite.Require().NoError(err) - }, true, }, { @@ -104,7 +102,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { data, err = types.ConnectionStateDataBytes(cdc, path, conn) suite.Require().NoError(err) - }, false, }, { @@ -186,5 +183,4 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { }) } } - } diff --git a/modules/light-clients/06-solomachine/types/consensus_state_test.go b/modules/light-clients/06-solomachine/types/consensus_state_test.go index 2a9fd37f581..bff1ed47974 100644 --- a/modules/light-clients/06-solomachine/types/consensus_state_test.go +++ b/modules/light-clients/06-solomachine/types/consensus_state_test.go @@ -61,7 +61,6 @@ func (suite *SoloMachineTestSuite) TestConsensusStateValidateBasic() { tc := tc suite.Run(tc.name, func() { - err := tc.consensusState.ValidateBasic() if tc.expPass { diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go b/modules/light-clients/06-solomachine/types/misbehaviour_handle.go index 1fef3c9978a..537d935a2fe 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_handle.go @@ -20,7 +20,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( clientStore sdk.KVStore, misbehaviour exported.Misbehaviour, ) (exported.ClientState, error) { - soloMisbehaviour, ok := misbehaviour.(*Misbehaviour) if !ok { return nil, sdkerrors.Wrapf( @@ -50,7 +49,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // over the provided data and that the data is valid. The data is valid if it can be // unmarshaled into the specified data type. func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misbehaviour *Misbehaviour, sigAndData *SignatureAndData) error { - // do not check misbehaviour timestamp since we want to allow processing of past misbehaviour // ensure data can be unmarshaled to the specified data type @@ -84,5 +82,4 @@ func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misb } return nil - } diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go b/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go index e370ac392b3..7d2f3687db4 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go @@ -227,7 +227,6 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() { m.SignatureTwo.Data = msg misbehaviour = m - }, false, }, diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_test.go b/modules/light-clients/06-solomachine/types/misbehaviour_test.go index 2d4f155468f..657f2c2e49f 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_test.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_test.go @@ -113,7 +113,6 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() { tc := tc suite.Run(tc.name, func() { - misbehaviour := solomachine.CreateMisbehaviour() tc.malleateMisbehaviour(misbehaviour) diff --git a/modules/light-clients/06-solomachine/types/proof.go b/modules/light-clients/06-solomachine/types/proof.go index 396ddd815ea..35a2d5c1cc6 100644 --- a/modules/light-clients/06-solomachine/types/proof.go +++ b/modules/light-clients/06-solomachine/types/proof.go @@ -54,7 +54,8 @@ func MisbehaviourSignBytes( sequence, timestamp uint64, diversifier string, dataType DataType, - data []byte) ([]byte, error) { + data []byte, +) ([]byte, error) { signBytes := &SignBytes{ Sequence: sequence, Timestamp: timestamp, diff --git a/modules/light-clients/06-solomachine/types/proposal_handle.go b/modules/light-clients/06-solomachine/types/proposal_handle.go index 057c82ec2bf..56f52b8c957 100644 --- a/modules/light-clients/06-solomachine/types/proposal_handle.go +++ b/modules/light-clients/06-solomachine/types/proposal_handle.go @@ -21,7 +21,6 @@ func (cs ClientState) CheckSubstituteAndUpdateState( ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore, _ sdk.KVStore, substituteClient exported.ClientState, ) (exported.ClientState, error) { - if !cs.AllowUpdateAfterProposal { return nil, sdkerrors.Wrapf( clienttypes.ErrUpdateClientFailed, diff --git a/modules/light-clients/06-solomachine/types/update_test.go b/modules/light-clients/06-solomachine/types/update_test.go index c07263af262..6b8fd4a93b6 100644 --- a/modules/light-clients/06-solomachine/types/update_test.go +++ b/modules/light-clients/06-solomachine/types/update_test.go @@ -121,7 +121,6 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { clientState = cs header = h - }, false, }, diff --git a/modules/light-clients/07-tendermint/types/client_state_test.go b/modules/light-clients/07-tendermint/types/client_state_test.go index 4e05f038de3..384a2098fa9 100644 --- a/modules/light-clients/07-tendermint/types/client_state_test.go +++ b/modules/light-clients/07-tendermint/types/client_state_test.go @@ -27,9 +27,7 @@ const ( fiftyOneCharChainID = "123456789012345678901234567890123456789012345678901" ) -var ( - invalidProof = []byte("invalid proof") -) +var invalidProof = []byte("invalid proof") func (suite *TendermintTestSuite) TestStatus() { var ( @@ -166,7 +164,6 @@ func (suite *TendermintTestSuite) TestValidate() { } func (suite *TendermintTestSuite) TestInitialize() { - testCases := []struct { name string consensusState exported.ConsensusState diff --git a/modules/light-clients/07-tendermint/types/consensus_state_test.go b/modules/light-clients/07-tendermint/types/consensus_state_test.go index 6b89865345c..ec3bb489e9c 100644 --- a/modules/light-clients/07-tendermint/types/consensus_state_test.go +++ b/modules/light-clients/07-tendermint/types/consensus_state_test.go @@ -14,49 +14,61 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { consensusState *types.ConsensusState expectPass bool }{ - {"success", + { + "success", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, - true}, - {"success with sentinel", + true, + }, + { + "success with sentinel", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte(types.SentinelRoot)), NextValidatorsHash: suite.valsHash, }, - true}, - {"root is nil", + true, + }, + { + "root is nil", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, - false}, - {"root is empty", + false, + }, + { + "root is empty", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, - false}, - {"nextvalshash is invalid", + false, + }, + { + "nextvalshash is invalid", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: []byte("hi"), }, - false}, + false, + }, - {"timestamp is zero", + { + "timestamp is zero", &types.ConsensusState{ Timestamp: time.Time{}, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, - false}, + false, + }, } for i, tc := range testCases { diff --git a/modules/light-clients/07-tendermint/types/header_test.go b/modules/light-clients/07-tendermint/types/header_test.go index ba792c2136c..5da3db7a5cc 100644 --- a/modules/light-clients/07-tendermint/types/header_test.go +++ b/modules/light-clients/07-tendermint/types/header_test.go @@ -21,9 +21,7 @@ func (suite *TendermintTestSuite) TestGetTime() { } func (suite *TendermintTestSuite) TestHeaderValidateBasic() { - var ( - header *types.Header - ) + var header *types.Header testCases := []struct { name string malleate func() diff --git a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go b/modules/light-clients/07-tendermint/types/misbehaviour_handle.go index 2e77f18c55e..5d929b83420 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/types/misbehaviour_handle.go @@ -101,7 +101,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( func checkMisbehaviourHeader( clientState *ClientState, consState *ConsensusState, header *Header, currentTimestamp time.Time, ) error { - tmTrustedValset, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { return sdkerrors.Wrap(err, "trusted validator set is not tendermint validator set type") diff --git a/modules/light-clients/07-tendermint/types/proposal_handle_test.go b/modules/light-clients/07-tendermint/types/proposal_handle_test.go index 1549f8a5490..79b3cf21166 100644 --- a/modules/light-clients/07-tendermint/types/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/types/proposal_handle_test.go @@ -9,9 +9,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v2/testing" ) -var ( - frozenHeight = clienttypes.NewHeight(0, 1) -) +var frozenHeight = clienttypes.NewHeight(0, 1) func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { var ( @@ -43,7 +41,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset subjectPath := ibctesting.NewPath(suite.chainA, suite.chainB) substitutePath = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -217,7 +214,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { // a client are each tested to ensure that unexpiry headers cannot update // a client when a unfreezing header is required. suite.Run(tc.name, func() { - // start by testing unexpiring the client suite.SetupTest() // reset @@ -303,7 +299,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { suite.Require().Error(err) suite.Require().Nil(updatedClient) } - }) } } @@ -365,7 +360,6 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { tc.malleate() suite.Require().Equal(tc.expPass, types.IsMatchingClientState(*subjectClientState, *substituteClientState)) - }) } } diff --git a/modules/light-clients/07-tendermint/types/store.go b/modules/light-clients/07-tendermint/types/store.go index 6ee21abfc28..4ca62a1ec00 100644 --- a/modules/light-clients/07-tendermint/types/store.go +++ b/modules/light-clients/07-tendermint/types/store.go @@ -95,7 +95,6 @@ func IterateConsensusMetadata(store sdk.KVStore, cb func(key, val []byte) bool) if len(keySplit) != 3 { // ignore all consensus state keys continue - } if keySplit[2] != "processedTime" && keySplit[2] != "processedHeight" { diff --git a/modules/light-clients/07-tendermint/types/upgrade_test.go b/modules/light-clients/07-tendermint/types/upgrade_test.go index 9a89e8fafaf..b45c3cf4e56 100644 --- a/modules/light-clients/07-tendermint/types/upgrade_test.go +++ b/modules/light-clients/07-tendermint/types/upgrade_test.go @@ -10,9 +10,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v2/testing" ) -var ( - newChainId = "newChainId-1" -) +var newChainId = "newChainId-1" func (suite *TendermintTestSuite) TestVerifyUpgrade() { var ( diff --git a/modules/light-clients/09-localhost/types/client_state_test.go b/modules/light-clients/09-localhost/types/client_state_test.go index 0cb1b46e340..0b40983ade9 100644 --- a/modules/light-clients/09-localhost/types/client_state_test.go +++ b/modules/light-clients/09-localhost/types/client_state_test.go @@ -149,7 +149,6 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() { } }) } - } func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { @@ -290,7 +289,6 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set(host.ChannelKey(testPortID, testChannelID), []byte("channel")) - }, channel: ch1, expPass: false, @@ -302,7 +300,6 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { bz, err := suite.cdc.Marshal(&ch2) suite.Require().NoError(err) suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz) - }, channel: ch1, expPass: false, diff --git a/modules/light-clients/09-localhost/types/localhost_test.go b/modules/light-clients/09-localhost/types/localhost_test.go index e0da290bd80..b7915500ff4 100644 --- a/modules/light-clients/09-localhost/types/localhost_test.go +++ b/modules/light-clients/09-localhost/types/localhost_test.go @@ -17,9 +17,7 @@ const ( height = 4 ) -var ( - clientHeight = clienttypes.NewHeight(0, 10) -) +var clientHeight = clienttypes.NewHeight(0, 10) type LocalhostTestSuite struct { suite.Suite diff --git a/testing/chain.go b/testing/chain.go index ac63935b8ef..309e3350827 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -237,7 +237,6 @@ func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { // number and updates the TestChain's headers. It returns the result and error if one // occurred. func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { - // ensure the chain has the latest time chain.Coordinator.UpdateTimeForChain(chain) @@ -357,7 +356,6 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa header.TrustedValidators = trustedVals return header, nil - } // ExpireClient fast forwards the chain's block time by the provided amount of time which will @@ -451,8 +449,8 @@ func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.Bl // sorting of ValidatorSet. // The sorting is first by .VotingPower (descending), with secondary index of .Address (ascending). func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator, - altVal, suiteVal *tmtypes.Validator) []tmtypes.PrivValidator { - + altVal, suiteVal *tmtypes.Validator, +) []tmtypes.PrivValidator { switch { case altVal.VotingPower > suiteVal.VotingPower: return []tmtypes.PrivValidator{altPrivVal, suitePrivVal} diff --git a/testing/coordinator.go b/testing/coordinator.go index c7a5d6edfd1..12951c9a6d8 100644 --- a/testing/coordinator.go +++ b/testing/coordinator.go @@ -56,7 +56,6 @@ func (coord *Coordinator) IncrementTime() { func (coord *Coordinator) IncrementTimeBy(increment time.Duration) { coord.CurrentTime = coord.CurrentTime.Add(increment).UTC() coord.UpdateTime() - } // UpdateTime updates all clocks for the TestChains to the current global time. @@ -106,7 +105,6 @@ func (coord *Coordinator) SetupConnections(path *Path) { // are returned within a TestConnection struct. The function expects the connections to be // successfully opened otherwise testing will fail. func (coord *Coordinator) CreateConnections(path *Path) { - err := path.EndpointA.ConnOpenInit() require.NoError(coord.t, err) diff --git a/testing/endpoint.go b/testing/endpoint.go index 73dbc949da5..5baeabe98ca 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -131,9 +131,7 @@ func (endpoint *Endpoint) UpdateClient() (err error) { // ensure counterparty has committed state endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) - var ( - header exported.Header - ) + var header exported.Header switch endpoint.ClientConfig.GetClientType() { case exported.Tendermint: @@ -154,7 +152,6 @@ func (endpoint *Endpoint) UpdateClient() (err error) { require.NoError(endpoint.Chain.t, err) return endpoint.Chain.sendMsgs(msg) - } // ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint. diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 157d85ccc2f..b163cd6021f 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -216,7 +216,6 @@ func NewSimApp( homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { - appCodec := encodingConfig.Marshaler legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -345,7 +344,7 @@ func NewSimApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. diff --git a/testing/simapp/params/amino.go b/testing/simapp/params/amino.go index 440c29f817e..0d43dd1eb8f 100644 --- a/testing/simapp/params/amino.go +++ b/testing/simapp/params/amino.go @@ -1,3 +1,4 @@ +//go:build test_amino // +build test_amino package params diff --git a/testing/simapp/params/proto.go b/testing/simapp/params/proto.go index 04aa524b900..a752d107907 100644 --- a/testing/simapp/params/proto.go +++ b/testing/simapp/params/proto.go @@ -1,3 +1,4 @@ +//go:build !test_amino // +build !test_amino package params diff --git a/testing/simapp/sim_test.go b/testing/simapp/sim_test.go index 7812dd470c6..3cd9430d3cd 100644 --- a/testing/simapp/sim_test.go +++ b/testing/simapp/sim_test.go @@ -163,11 +163,13 @@ func TestAppImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, - {app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], + { + app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], [][]byte{ stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, stakingtypes.HistoricalInfoKey, - }}, // ordering may change but it doesn't matter + }, + }, // ordering may change but it doesn't matter {app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}}, {app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}}, {app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}}, diff --git a/testing/simapp/simd/cmd/genaccounts_test.go b/testing/simapp/simd/cmd/genaccounts_test.go index c63fb4baaef..0f6e9cb741a 100644 --- a/testing/simapp/simd/cmd/genaccounts_test.go +++ b/testing/simapp/simd/cmd/genaccounts_test.go @@ -73,7 +73,8 @@ func TestAddGenesisAccountCmd(t *testing.T) { cmd.SetArgs([]string{ tc.addr, tc.denom, - fmt.Sprintf("--%s=home", flags.FlagHome)}) + fmt.Sprintf("--%s=home", flags.FlagHome), + }) if tc.expectErr { require.Error(t, cmd.ExecuteContext(ctx)) diff --git a/testing/simapp/simd/cmd/root.go b/testing/simapp/simd/cmd/root.go index 2253b6ecd82..f027d3dda0a 100644 --- a/testing/simapp/simd/cmd/root.go +++ b/testing/simapp/simd/cmd/root.go @@ -279,8 +279,8 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a // and exports state. func (a appCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { - + appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { var simApp *simapp.SimApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { diff --git a/testing/simapp/simd/cmd/testnet.go b/testing/simapp/simd/cmd/testnet.go index d188253a632..68c1e79f7de 100644 --- a/testing/simapp/simd/cmd/testnet.go +++ b/testing/simapp/simd/cmd/testnet.go @@ -94,7 +94,7 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 // Initialize the testnet func InitTestnet( @@ -113,7 +113,6 @@ func InitTestnet( algoStr string, numValidators int, ) error { - if chainID == "" { chainID = "chain-" + tmrand.NewRand().Str(6) } @@ -270,7 +269,6 @@ func initGenFiles( genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.JSONCodec) // set the accounts in the genesis state @@ -317,7 +315,6 @@ func collectGenFiles( nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { - var appState json.RawMessage genTime := tmtime.Now() @@ -386,12 +383,12 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = tmos.WriteFile(file, contents, 0644) + err = tmos.WriteFile(file, contents, 0o644) if err != nil { return err } diff --git a/testing/simapp/state.go b/testing/simapp/state.go index 7dea332368a..250c67920b1 100644 --- a/testing/simapp/state.go +++ b/testing/simapp/state.go @@ -28,7 +28,6 @@ import ( func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config, ) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) { - if FlagGenesisTimeValue == 0 { genesisTimestamp = simtypes.RandTimestamp(r) } else { diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 0773465501c..e221a44d14e 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -238,7 +238,6 @@ func SignAndDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - tx, err := helpers.GenTx( txCfg, msgs, diff --git a/testing/simapp/utils.go b/testing/simapp/utils.go index 7bfb087c9ff..190d3e0b778 100644 --- a/testing/simapp/utils.go +++ b/testing/simapp/utils.go @@ -84,7 +84,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0600); err != nil { + if err := ioutil.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0o600); err != nil { return err } } @@ -96,7 +96,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0600); err != nil { + if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0o600); err != nil { return err } }