From f88b9b32d7d6b6eb27ed57fe32122724ef1b8ff1 Mon Sep 17 00:00:00 2001 From: Alyak Date: Wed, 18 Dec 2024 11:51:56 +0200 Subject: [PATCH] fix: use experror. (#7717) * fix: use experror. * chore: fix call to Equal. --------- Co-authored-by: DimitrisJim --- modules/core/02-client/types/msgs_test.go | 13 +++++++------ modules/light-clients/08-wasm/types/msgs_test.go | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index f47951c4b1e..6942379d57a 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -697,12 +697,12 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { // TestMsgRecoverClientGetSigners tests GetSigners for MsgRecoverClient func TestMsgRecoverClientGetSigners(t *testing.T) { testCases := []struct { - name string - address sdk.AccAddress - expPass bool + name string + address sdk.AccAddress + expError error }{ - {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), true}, - {"failure: nil address", nil, false}, + {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), nil}, + {"failure: nil address", nil, fmt.Errorf("empty address string is not allowed")}, } for _, tc := range testCases { @@ -712,11 +712,12 @@ func TestMsgRecoverClientGetSigners(t *testing.T) { } encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, ibc.AppModule{}) signers, _, err := encodingCfg.Codec.GetMsgSigners(&msg) - if tc.expPass { + if tc.expError == nil { require.NoError(t, err) require.Equal(t, tc.address.Bytes(), signers[0]) } else { require.Error(t, err) + require.Equal(t, err.Error(), tc.expError.Error()) } } } diff --git a/modules/light-clients/08-wasm/types/msgs_test.go b/modules/light-clients/08-wasm/types/msgs_test.go index 914b5391fd9..f7f377d3521 100644 --- a/modules/light-clients/08-wasm/types/msgs_test.go +++ b/modules/light-clients/08-wasm/types/msgs_test.go @@ -242,12 +242,12 @@ func (suite *TypesTestSuite) TestMsgRemoveChecksumGetSigners() { suite.Require().NoError(err) testCases := []struct { - name string - address sdk.AccAddress - expPass bool + name string + address sdk.AccAddress + expError error }{ - {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), true}, - {"failure: nil address", nil, false}, + {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), nil}, + {"failure: nil address", nil, fmt.Errorf("empty address string is not allowed")}, } for _, tc := range testCases { @@ -259,11 +259,12 @@ func (suite *TypesTestSuite) TestMsgRemoveChecksumGetSigners() { msg := types.NewMsgRemoveChecksum(address.String(), checksum) signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgSigners(msg) - if tc.expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(address.Bytes(), signers[0]) } else { suite.Require().Error(err) + suite.Require().Equal(err.Error(), tc.expError.Error()) } }) }