-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cap-gas-save
- Loading branch information
Showing
4 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
modules/apps/27-interchain-accounts/controller/types/codec_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" | ||
|
||
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" | ||
) | ||
|
||
func TestCodecTypeRegistration(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
typeURL string | ||
expPass bool | ||
}{ | ||
{ | ||
"success: MsgRegisterInterchainAccount", | ||
sdk.MsgTypeURL(&types.MsgRegisterInterchainAccount{}), | ||
true, | ||
}, | ||
{ | ||
"success: MsgSendTx", | ||
sdk.MsgTypeURL(&types.MsgSendTx{}), | ||
true, | ||
}, | ||
{ | ||
"success: MsgUpdateParams", | ||
sdk.MsgTypeURL(&types.MsgUpdateParams{}), | ||
true, | ||
}, | ||
{ | ||
"type not registered on codec", | ||
"ibc.invalid.MsgTypeURL", | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) | ||
msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) | ||
|
||
if tc.expPass { | ||
require.NotNil(t, msg) | ||
require.NoError(t, err) | ||
} else { | ||
require.Nil(t, msg) | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
modules/apps/27-interchain-accounts/host/types/codec_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" | ||
|
||
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" | ||
) | ||
|
||
func TestCodecTypeRegistration(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
typeURL string | ||
expPass bool | ||
}{ | ||
{ | ||
"success: MsgUpdateParams", | ||
sdk.MsgTypeURL(&types.MsgUpdateParams{}), | ||
true, | ||
}, | ||
{ | ||
"type not registered on codec", | ||
"ibc.invalid.MsgTypeURL", | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) | ||
msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) | ||
|
||
if tc.expPass { | ||
require.NotNil(t, msg) | ||
require.NoError(t, err) | ||
} else { | ||
require.Nil(t, msg) | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" | ||
|
||
fee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" | ||
) | ||
|
||
func TestCodecTypeRegistration(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
typeURL string | ||
expPass bool | ||
}{ | ||
{ | ||
"success: MsgPayPacketFee", | ||
sdk.MsgTypeURL(&types.MsgPayPacketFee{}), | ||
true, | ||
}, | ||
{ | ||
"success: MsgPayPacketFeeAsync", | ||
sdk.MsgTypeURL(&types.MsgPayPacketFeeAsync{}), | ||
true, | ||
}, | ||
{ | ||
"success: MsgRegisterPayee", | ||
sdk.MsgTypeURL(&types.MsgRegisterPayee{}), | ||
true, | ||
}, | ||
{ | ||
"success: MsgRegisterCounterpartyPayee", | ||
sdk.MsgTypeURL(&types.MsgRegisterCounterpartyPayee{}), | ||
true, | ||
}, | ||
{ | ||
"type not registered on codec", | ||
"ibc.invalid.MsgTypeURL", | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
encodingCfg := moduletestutil.MakeTestEncodingConfig(fee.AppModuleBasic{}) | ||
msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) | ||
|
||
if tc.expPass { | ||
require.NotNil(t, msg) | ||
require.NoError(t, err) | ||
} else { | ||
require.Nil(t, msg) | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters