From 833db7ff36f8c1c952fd6caca8902c97c9e8395e Mon Sep 17 00:00:00 2001 From: modernzju Date: Sun, 21 Jun 2026 00:55:11 +0800 Subject: [PATCH] Add boundary tests for IBC channel parameter validation Signed-off-by: modernzju --- x/wasm/ibc_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/x/wasm/ibc_test.go b/x/wasm/ibc_test.go index e0be67df4b..0e1feed795 100644 --- a/x/wasm/ibc_test.go +++ b/x/wasm/ibc_test.go @@ -178,6 +178,38 @@ func TestMapToWasmVMIBCPacket(t *testing.T) { } } +func TestValidateChannelParams(t *testing.T) { + specs := map[string]struct { + channelID string + expErr bool + }{ + "valid zero channel sequence": { + channelID: "channel-0", + }, + "valid max uint32 channel sequence": { + channelID: "channel-4294967295", + }, + "invalid channel sequence beyond uint32": { + channelID: "channel-4294967296", + expErr: true, + }, + "invalid channel ID format": { + channelID: "invalid-channel", + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + err := ValidateChannelParams(spec.channelID) + if spec.expErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} + func IBCPacketFixture(mutators ...func(p *channeltypes.Packet)) channeltypes.Packet { r := channeltypes.Packet{ Sequence: 1,