From a5c00bdf7b4a8edab58213c7c3157253d257734c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cessenmeoikia=E2=80=9D?= Date: Thu, 19 Dec 2024 22:44:23 +0700 Subject: [PATCH] no need to declare new variables --- .../controller/keeper/handshake_test.go | 10 +--- .../host/keeper/handshake_test.go | 3 +- .../host/keeper/relay_test.go | 6 +- .../host/types/msgs_test.go | 3 +- modules/apps/29-fee/ibc_middleware_test.go | 9 +-- modules/apps/29-fee/transfer_test.go | 3 +- modules/apps/callbacks/ibc_middleware_test.go | 3 +- .../apps/callbacks/types/callbacks_test.go | 3 +- modules/apps/transfer/ibc_module_test.go | 24 +++----- .../apps/transfer/keeper/msg_server_test.go | 3 +- modules/apps/transfer/keeper/relay_test.go | 18 ++---- .../apps/transfer/types/forwarding_test.go | 9 +-- modules/apps/transfer/types/msgs_test.go | 6 +- modules/apps/transfer/types/packet_test.go | 12 ++-- modules/apps/transfer/types/token_test.go | 6 +- .../core/02-client/keeper/grpc_query_test.go | 3 +- modules/core/02-client/keeper/keeper_test.go | 3 +- modules/core/02-client/types/msgs_test.go | 12 ++-- modules/core/04-channel/keeper/ante_test.go | 3 +- modules/core/04-channel/keeper/packet_test.go | 3 +- .../core/04-channel/keeper/upgrade_test.go | 18 ++---- modules/core/04-channel/types/msgs_test.go | 57 +++++++------------ modules/core/keeper/msg_server_test.go | 6 +- .../light_client_module_test.go | 27 +++------ .../07-tendermint/client_state_test.go | 3 +- .../07-tendermint/light_client_module_test.go | 21 +++---- .../07-tendermint/upgrade_test.go | 3 +- .../08-wasm/internal/types/store_test.go | 3 +- .../08-wasm/keeper/contract_keeper_test.go | 12 ++-- .../08-wasm/keeper/querier_test.go | 6 +- .../08-wasm/light_client_module_test.go | 21 +++---- .../light-clients/08-wasm/types/msgs_test.go | 3 +- 32 files changed, 107 insertions(+), 215 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 0f3a291ffdf..15e0dc7afb1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -298,8 +298,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel.Counterparty, channel.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(expectedVersion, version) } else { @@ -686,9 +685,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { version, ) - expPass := tc.expError == nil - - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(upgradeVersion, version) } else { @@ -857,8 +854,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, counterpartyVersion) } else { diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index f69752acbae..093abc927a5 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -597,8 +597,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointB.GetChannel().Version, version) } else { diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 15f89ca65ba..e2790b1dfe4 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -545,8 +545,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { txResponse, err := suite.chainB.GetSimApp().ICAHostKeeper.OnRecvPacket(suite.chainB.GetContext(), packet) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(txResponse) } else { @@ -874,8 +873,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { txResponse, err := suite.chainB.GetSimApp().ICAHostKeeper.OnRecvPacket(suite.chainB.GetContext(), packet) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(txResponse) } else { diff --git a/modules/apps/27-interchain-accounts/host/types/msgs_test.go b/modules/apps/27-interchain-accounts/host/types/msgs_test.go index 3a495b0d9c6..b353a143197 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs_test.go @@ -111,8 +111,7 @@ func TestMsgModuleQuerySafeValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) } else { require.Error(t, err) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 7a388ac1748..45a52283a02 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -1118,8 +1118,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeInit() { err := path.EndpointA.ChanUpgradeInit() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1231,8 +1230,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeTry() { err = path.EndpointB.ChanUpgradeTry() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1338,8 +1336,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeAck() { err = cbs.OnChanUpgradeAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyUpgrade.Fields.Version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go index aef236eb86e..a743d2f718f 100644 --- a/modules/apps/29-fee/transfer_test.go +++ b/modules/apps/29-fee/transfer_test.go @@ -139,8 +139,7 @@ func (suite *FeeTestSuite) TestTransferFeeUpgrade() { err = path.EndpointA.ChanUpgradeOpen() suite.Require().NoError(err) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { channelA := path.EndpointA.GetChannel() suite.Require().Equal(upgradeVersion, channelA.Version) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index a19d85900c2..00cd58bc20a 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -71,8 +71,7 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { s.Require().NotPanics(tc.instantiateFn, "unexpected panic: NewIBCMiddleware") } else { s.Require().PanicsWithError(tc.expError.Error(), tc.instantiateFn, "expected panic with error: ", tc.expError.Error()) diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index 735e7316ed3..82e73172fa0 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -549,8 +549,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { callbackData, err := types.GetCallbackData(packetData, version, transfertypes.PortID, remainingGas, uint64(1_000_000), callbackKey) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { s.Require().NoError(err, tc.name) s.Require().Equal(tc.expCallbackData, callbackData, tc.name) diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 6ff8ab21fee..b96a4e1e51d 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -101,8 +101,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterparty, channel.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(tc.expVersion, version) } else { @@ -186,8 +185,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { version, err := cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel.Counterparty, counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(tc.expVersion, version) } else { @@ -236,8 +234,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { err := cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointA.Counterparty.ChannelID, counterpartyVersion) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -472,8 +469,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), path.EndpointA.GetChannel().Version, packet, suite.chainA.SenderAccount.GetAddress()) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) escrowAddress := types.GetEscrowAddress(packet.GetSourcePort(), packet.GetSourceChannel()) @@ -545,8 +541,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeInit() { err := path.EndpointA.ChanUpgradeInit() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) upgrade := path.EndpointA.GetChannelUpgrade() suite.Require().Equal(upgradePath.EndpointA.ConnectionID, upgrade.Fields.ConnectionHops[0]) @@ -623,8 +618,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeTry() { counterpartyUpgrade.Fields.Ordering, counterpartyUpgrade.Fields.ConnectionHops, counterpartyUpgrade.Fields.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(types.V2, version) } else { @@ -688,8 +682,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeAck() { err = cbs.OnChanUpgradeAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.Version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -847,8 +840,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { packetData, version, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) v2PacketData, ok := packetData.(types.FungibleTokenPacketDataV2) diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 13b0d9369e4..a6530d8c6d6 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -183,8 +183,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { ), }.ToABCIEvents() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().NotEqual(res.Sequence, uint64(0)) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index ff3a0d03eab..b544ee0cf5d 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -279,8 +279,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(suite.chainA.GetContext(), msg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { @@ -466,8 +465,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, packetData) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) // Check denom metadata for of tokens received on chain B. @@ -593,8 +591,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { packet := channeltypes.NewPacket(packetData.GetBytes(), uint64(1), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0) err = suite.chainA.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainA.GetContext(), packet, packetData) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) _, found := suite.chainA.GetSimApp().BankKeeper.GetDenomMetaData(suite.chainA.GetContext(), sdk.DefaultBondDenom) @@ -809,8 +806,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { totalEscrow := suite.chainA.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainA.GetContext(), denom.IBCDenom()) suite.Require().Equal(expEscrowAmount, totalEscrow.Amount) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) postAcknowledgementBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) deltaAmount := postAcknowledgementBalance.Amount.Sub(preAcknowledgementBalance.Amount) @@ -1047,8 +1043,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { totalEscrow := suite.chainA.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainA.GetContext(), denom.IBCDenom()) suite.Require().Equal(expEscrowAmount, totalEscrow.Amount) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) amountParsed, ok := sdkmath.NewIntFromString(amount) suite.Require().True(ok) @@ -1230,8 +1225,7 @@ func (suite *KeeperTestSuite) TestPacketForwardsCompatibility() { // receive packet on chainA err = path.RelayPacket(packet) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expError.Error()) diff --git a/modules/apps/transfer/types/forwarding_test.go b/modules/apps/transfer/types/forwarding_test.go index e7dce4814e8..e1b0a102dbf 100644 --- a/modules/apps/transfer/types/forwarding_test.go +++ b/modules/apps/transfer/types/forwarding_test.go @@ -98,8 +98,7 @@ func TestForwarding_Validate(t *testing.T) { err := tc.forwarding.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -209,8 +208,7 @@ func TestForwardingPacketData_Validate(t *testing.T) { err := tc.forwarding.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -267,8 +265,7 @@ func TestValidateHop(t *testing.T) { err := tc.hop.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 7c2f070b353..2a1a943a000 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -97,8 +97,7 @@ func TestMsgTransferValidation(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -134,8 +133,7 @@ func TestMsgUpdateParamsValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 254cec03522..911402e7c7d 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -484,8 +484,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.packetData.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expErr.Error(), tc.name) @@ -767,8 +766,7 @@ func TestUnmarshalPacketData(t *testing.T) { packetData, err := types.UnmarshalPacketData(packetDataBz, version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.IsType(t, types.FungibleTokenPacketDataV2{}, packetData) } else { require.ErrorIs(t, err, tc.expError) @@ -821,8 +819,7 @@ func TestV2ForwardsCompatibilityFails(t *testing.T) { packetData, err := types.UnmarshalPacketData(packetDataBz, types.V2) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) require.NotEqual(t, types.FungibleTokenPacketDataV2{}, packetData) } else { @@ -938,8 +935,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { for _, tc := range testCases { actualV2Data, err := types.PacketDataV1ToV2(tc.v1Data) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, "test case: %s", tc.name) require.Equal(t, tc.v2Data, actualV2Data, "test case: %s", tc.name) } else { diff --git a/modules/apps/transfer/types/token_test.go b/modules/apps/transfer/types/token_test.go index f349765822b..929ba3b5f78 100644 --- a/modules/apps/transfer/types/token_test.go +++ b/modules/apps/transfer/types/token_test.go @@ -144,8 +144,7 @@ func TestValidate(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { err := tc.token.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expError.Error(), tc.name) @@ -193,8 +192,7 @@ func TestToCoin(t *testing.T) { require.Equal(t, tc.expCoin, coin, tc.name) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expError.Error(), tc.name) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index e84323d64d9..1abaa4a1d15 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -948,8 +948,7 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) res, err := queryServer.VerifyMembership(ctx, req) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().True(res.Success, "failed to verify membership proof") diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 9b230fec827..caba6fc0a8e 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -452,8 +452,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { actualTimestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientTimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(uint64(suite.chainB.LatestCommittedHeader.GetTime().UnixNano()), actualTimestamp) } else { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index f47951c4b1e..95574c05495 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -684,8 +684,7 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err, "valid case %s failed", tc.name) } else { suite.Require().Error(err, "invalid case %s passed", tc.name) @@ -800,8 +799,7 @@ func TestMsgIBCSoftwareUpgrade_GetSigners(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, ibc.AppModule{}) signers, _, err := encodingCfg.Codec.GetMsgSigners(msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) require.Equal(t, tc.address.Bytes(), signers[0]) } else { @@ -871,9 +869,8 @@ func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_ValidateBasic() { } err = msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } if tc.expError != nil { @@ -975,8 +972,7 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, ibc.AppModule{}) signers, _, err := encodingCfg.Codec.GetMsgSigners(&msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) require.Equal(t, tc.address.Bytes(), signers[0]) } else { diff --git a/modules/core/04-channel/keeper/ante_test.go b/modules/core/04-channel/keeper/ante_test.go index 4332788baaf..4de476a81f5 100644 --- a/modules/core/04-channel/keeper/ante_test.go +++ b/modules/core/04-channel/keeper/ante_test.go @@ -53,8 +53,7 @@ func (suite *KeeperTestSuite) TestRecvPacketReCheckTx() { err = suite.chainB.App.GetIBCKeeper().ChannelKeeper.RecvPacketReCheckTx(suite.chainB.GetContext(), packet) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 38fb54b2ad3..973b5d605e1 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -596,8 +596,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelVersion, err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.RecvPacket(suite.chainB.GetContext(), packet, proof, proofHeight) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, channelVersion, "channel version is incorrect") diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 8565f12a195..26ee0e22b6d 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -295,7 +295,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - expPass := tc.expError == nil path = ibctesting.NewPath(suite.chainA, suite.chainB) path.Setup() @@ -330,7 +329,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() { proofHeight, ) - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotEmpty(upgrade) suite.Require().Equal(proposedUpgrade.Fields, upgrade.Fields) @@ -782,8 +781,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { channelProof, upgradeProof, proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) channel := path.EndpointA.GetChannel() @@ -1132,8 +1130,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeConfirm() { channelProof, upgradeProof, proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.assertUpgradeError(err, tc.expError) @@ -1843,8 +1840,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeCancel() { err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeCancel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt, errorReceiptProof, proofHeight) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -2174,7 +2170,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - expPass := tc.expError == nil path = ibctesting.NewPath(suite.chainA, suite.chainB) path.Setup() @@ -2200,7 +2195,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { proofHeight, ) - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.assertUpgradeError(err, tc.expError) @@ -2686,8 +2681,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeCrossingHelloWithHistoricalProofs() proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotEmpty(upgrade) } else { diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index b789fe5f550..ba1f7e6f289 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -249,8 +249,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -421,8 +420,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTryValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -532,8 +530,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenAckValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -627,8 +624,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenConfirmValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -717,8 +713,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseInitValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -817,8 +812,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -874,8 +868,7 @@ func (suite *TypesTestSuite) TestMsgRecvPacketValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.NoError(err) } else { suite.Error(err) @@ -936,8 +929,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1008,8 +1000,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1070,8 +1061,7 @@ func (suite *TypesTestSuite) TestMsgAcknowledgementValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1154,8 +1144,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeInitValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1278,8 +1267,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTryValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1385,8 +1373,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeAckValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1506,8 +1493,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeConfirmValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1613,8 +1599,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeOpenValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1693,8 +1678,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1778,8 +1762,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeCancelValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1852,8 +1835,7 @@ func (suite *TypesTestSuite) TestMsgPruneAcknowledgementsValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -1907,8 +1889,7 @@ func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 205282687dd..645918c4c14 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -277,8 +277,7 @@ func (suite *KeeperTestSuite) TestRecoverClient() { _, err = suite.chainA.App.GetIBCKeeper().RecoverClient(suite.chainA.GetContext(), msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // Assert that client status is now Active @@ -2675,8 +2674,7 @@ func (suite *KeeperTestSuite) TestUpdateChannelParams() { suite.Run(tc.name, func() { suite.SetupTest() resp, err := suite.chainA.App.GetIBCKeeper().UpdateChannelParams(suite.chainA.GetContext(), tc.msg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(resp) p := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetParams(suite.chainA.GetContext()) diff --git a/modules/light-clients/06-solomachine/light_client_module_test.go b/modules/light-clients/06-solomachine/light_client_module_test.go index 08c6d1f2945..2141687a29c 100644 --- a/modules/light-clients/06-solomachine/light_client_module_test.go +++ b/modules/light-clients/06-solomachine/light_client_module_test.go @@ -203,8 +203,7 @@ func (suite *SoloMachineTestSuite) TestInitialize() { err = lightClientModule.Initialize(suite.chainA.GetContext(), clientID, clientStateBz, consStateBz) store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().True(store.Has(host.ClientStateKey())) } else { @@ -679,8 +678,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { 0, 0, proof, path, signBytes.Data, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { // Grab fresh client state after updates. cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), clientID) suite.Require().True(found) @@ -904,8 +902,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() { 0, 0, proof, path, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { // Grab fresh client state after updates. cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), clientID) suite.Require().True(found) @@ -1001,8 +998,7 @@ func (suite *SoloMachineTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(ctx, subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // assert that status of subject client is now Active @@ -1084,8 +1080,7 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { consensusHeights = lightClientModule.UpdateState(suite.chainA.GetContext(), clientID, clientMsg) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { updateStateFunc() clientStateBz := store.Get(host.ClientStateKey()) @@ -1174,8 +1169,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { foundMisbehaviour = lightClientModule.CheckForMisbehaviour(suite.chainA.GetContext(), clientID, clientMsg) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { foundMisbehaviourFunc() suite.Require().Equal(tc.foundMisbehaviour, foundMisbehaviour) @@ -1230,8 +1224,7 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { lightClientModule.UpdateStateOnMisbehaviour(suite.chainA.GetContext(), clientID, nil) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { updateOnMisbehaviourFunc() store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) @@ -1406,8 +1399,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -1652,8 +1644,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) diff --git a/modules/light-clients/07-tendermint/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go index 82aecf465da..1b962873a4c 100644 --- a/modules/light-clients/07-tendermint/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -126,8 +126,7 @@ func (suite *TendermintTestSuite) TestValidate() { suite.Run(tc.name, func() { err := tc.clientState.Validate() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) diff --git a/modules/light-clients/07-tendermint/light_client_module_test.go b/modules/light-clients/07-tendermint/light_client_module_test.go index 87119309949..5a44b6d0baa 100644 --- a/modules/light-clients/07-tendermint/light_client_module_test.go +++ b/modules/light-clients/07-tendermint/light_client_module_test.go @@ -103,8 +103,7 @@ func (suite *TendermintTestSuite) TestInitialize() { store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, "valid case returned an error") suite.Require().True(store.Has(host.ClientStateKey())) suite.Require().True(store.Has(host.ConsensusStateKey(suite.chainB.LatestCommittedHeader.GetHeight()))) @@ -162,8 +161,7 @@ func (suite *TendermintTestSuite) TestVerifyClientMessage() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), path.EndpointA.ClientID, header) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -515,8 +513,7 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { suite.chainA.GetContext(), testingpath.EndpointA.ClientID, proofHeight, delayTimePeriod, delayBlockPeriod, proof, path, value, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -741,8 +738,7 @@ func (suite *TendermintTestSuite) TestVerifyNonMembership() { proof, path, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -934,8 +930,7 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() { timestamp, err := lightClientModule.TimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) expectedTimestamp := uint64(expectedTimestamp.UnixNano()) @@ -1021,8 +1016,7 @@ func (suite *TendermintTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(ctx, subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // assert that status of subject client is now Active @@ -1184,8 +1178,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgradeAndUpdateState() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) expClientState := path.EndpointA.GetClientState() diff --git a/modules/light-clients/07-tendermint/upgrade_test.go b/modules/light-clients/07-tendermint/upgrade_test.go index ea653cba82e..5fcda9454d3 100644 --- a/modules/light-clients/07-tendermint/upgrade_test.go +++ b/modules/light-clients/07-tendermint/upgrade_test.go @@ -583,8 +583,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name) clientState, ok := suite.chainA.GetClientState(path.EndpointA.ClientID).(*ibctm.ClientState) diff --git a/modules/light-clients/08-wasm/internal/types/store_test.go b/modules/light-clients/08-wasm/internal/types/store_test.go index 7234e70bb07..b063acbe0b2 100644 --- a/modules/light-clients/08-wasm/internal/types/store_test.go +++ b/modules/light-clients/08-wasm/internal/types/store_test.go @@ -417,8 +417,7 @@ func (suite *TypesTestSuite) TestNewClientRecoveryStore() { suite.Run(tc.name, func() { tc.malleate() - expPass := !tc.expPanic - if expPass { + if !tc.expPanic { suite.Require().NotPanics(func() { internaltypes.NewClientRecoveryStore(subjectStore, substituteStore) }) diff --git a/modules/light-clients/08-wasm/keeper/contract_keeper_test.go b/modules/light-clients/08-wasm/keeper/contract_keeper_test.go index 86e213aef79..c22ffd4a378 100644 --- a/modules/light-clients/08-wasm/keeper/contract_keeper_test.go +++ b/modules/light-clients/08-wasm/keeper/contract_keeper_test.go @@ -179,8 +179,7 @@ func (suite *KeeperTestSuite) TestWasmInstantiate() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper err := wasmClientKeeper.WasmInstantiate(suite.chainA.GetContext(), defaultWasmClientID, clientStore, &types.ClientState{Checksum: checksum}, initMsg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -318,8 +317,7 @@ func (suite *KeeperTestSuite) TestWasmMigrate() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper err = wasmClientKeeper.WasmMigrate(suite.chainA.GetContext(), clientStore, &types.ClientState{}, defaultWasmClientID, []byte("{}")) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -396,8 +394,7 @@ func (suite *KeeperTestSuite) TestWasmQuery() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, wasmClientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { @@ -552,8 +549,7 @@ func (suite *KeeperTestSuite) TestWasmSudo() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper res, err := wasmClientKeeper.WasmSudo(suite.chainA.GetContext(), endpoint.ClientID, clientStore, wasmClientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { diff --git a/modules/light-clients/08-wasm/keeper/querier_test.go b/modules/light-clients/08-wasm/keeper/querier_test.go index e9362fb24f4..e1b31efe032 100644 --- a/modules/light-clients/08-wasm/keeper/querier_test.go +++ b/modules/light-clients/08-wasm/keeper/querier_test.go @@ -119,8 +119,7 @@ func (suite *KeeperTestSuite) TestCustomQuery() { res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, clientState, types.QueryMsg{Status: &types.StatusMsg{}}) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().Nil(err) suite.Require().NotNil(res) } else { @@ -330,8 +329,7 @@ func (suite *KeeperTestSuite) TestStargateQuery() { // due to test case: "success: verify membership query" res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, clientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { diff --git a/modules/light-clients/08-wasm/light_client_module_test.go b/modules/light-clients/08-wasm/light_client_module_test.go index 53979978335..43ae4027ae4 100644 --- a/modules/light-clients/08-wasm/light_client_module_test.go +++ b/modules/light-clients/08-wasm/light_client_module_test.go @@ -223,8 +223,7 @@ func (suite *WasmTestSuite) TestTimestampAtHeight() { timestamp, err := lightClientModule.TimestampAtHeight(suite.chainA.GetContext(), clientID, height) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().Equal(expectedTimestamp, timestamp) } else { @@ -351,8 +350,7 @@ func (suite *WasmTestSuite) TestInitialize() { err = lightClientModule.Initialize(suite.chainA.GetContext(), clientID, clientStateBz, consensusStateBz) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expError.Error()) @@ -495,8 +493,7 @@ func (suite *WasmTestSuite) TestVerifyMembership() { err = lightClientModule.VerifyMembership(suite.chainA.GetContext(), clientID, proofHeight, 0, 0, proof, path, value) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) suite.Require().NoError(err) @@ -661,8 +658,7 @@ func (suite *WasmTestSuite) TestVerifyNonMembership() { err = lightClientModule.VerifyNonMembership(suite.chainA.GetContext(), clientID, proofHeight, 0, 0, proof, path) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) suite.Require().NoError(err) @@ -772,8 +768,7 @@ func (suite *WasmTestSuite) TestVerifyClientMessage() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -933,8 +928,7 @@ func (suite *WasmTestSuite) TestVerifyUpgradeAndUpdateState() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // verify new client state and consensus state @@ -1530,8 +1524,7 @@ func (suite *WasmTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(suite.chainA.GetContext(), subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) subjectClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), subjectClientID) diff --git a/modules/light-clients/08-wasm/types/msgs_test.go b/modules/light-clients/08-wasm/types/msgs_test.go index 914b5391fd9..40e8df5f5d5 100644 --- a/modules/light-clients/08-wasm/types/msgs_test.go +++ b/modules/light-clients/08-wasm/types/msgs_test.go @@ -150,8 +150,7 @@ func TestMsgMigrateContractValidateBasic(t *testing.T) { tc := tc err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expErr, tc.name)