cosmos-sdk/x/ibc/04-channel/types/channel_test.go

33 lines
816 B
Go

package types_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
)
func TestCounterpartyValidateBasic(t *testing.T) {
testCases := []struct {
name string
counterparty types.Counterparty
expPass bool
}{
{"valid counterparty", types.Counterparty{"portidone", "channelidone"}, true},
{"invalid port id", types.Counterparty{"(InvalidPort)", "channelidone"}, false},
{"invalid channel id", types.Counterparty{"portidone", "(InvalidChannel)"}, false},
}
for i, tc := range testCases {
tc := tc
err := tc.counterparty.ValidateBasic()
if tc.expPass {
require.NoError(t, err, "valid test case %d failed: %s", i, tc.name)
} else {
require.Error(t, err, "invalid test case %d passed: %s", i, tc.name)
}
}
}