Update connection and channel to use types_test package name (#6395)
* convert connection types test pacakge name * convert channel types test package name Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
parent
82afd52981
commit
affe7265cb
|
@ -1,10 +1,11 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,37 +19,37 @@ var (
|
||||||
func TestConnectionValidateBasic(t *testing.T) {
|
func TestConnectionValidateBasic(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
connection ConnectionEnd
|
connection types.ConnectionEnd
|
||||||
expPass bool
|
expPass bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid connection",
|
"valid connection",
|
||||||
ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
types.ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid connection id",
|
"invalid connection id",
|
||||||
ConnectionEnd{"(connectionIDONE)", clientID, []string{"1.0.0"}, INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
types.ConnectionEnd{"(connectionIDONE)", clientID, []string{"1.0.0"}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid client id",
|
"invalid client id",
|
||||||
ConnectionEnd{connectionID, "(clientID1)", []string{"1.0.0"}, INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
types.ConnectionEnd{connectionID, "(clientID1)", []string{"1.0.0"}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"empty versions",
|
"empty versions",
|
||||||
ConnectionEnd{connectionID, clientID, nil, INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
types.ConnectionEnd{connectionID, clientID, nil, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid version",
|
"invalid version",
|
||||||
ConnectionEnd{connectionID, clientID, []string{""}, INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
types.ConnectionEnd{connectionID, clientID, []string{""}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid counterparty",
|
"invalid counterparty",
|
||||||
ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, INIT, Counterparty{clientID2, connectionID2, emptyPrefix}},
|
types.ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, types.INIT, types.Counterparty{clientID2, connectionID2, emptyPrefix}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -68,13 +69,13 @@ func TestConnectionValidateBasic(t *testing.T) {
|
||||||
func TestCounterpartyValidateBasic(t *testing.T) {
|
func TestCounterpartyValidateBasic(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
counterparty Counterparty
|
counterparty types.Counterparty
|
||||||
expPass bool
|
expPass bool
|
||||||
}{
|
}{
|
||||||
{"valid counterparty", Counterparty{clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true},
|
{"valid counterparty", types.Counterparty{clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true},
|
||||||
{"invalid client id", Counterparty{"(InvalidClient)", connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
|
{"invalid client id", types.Counterparty{"(InvalidClient)", connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
|
||||||
{"invalid connection id", Counterparty{clientID, "(InvalidConnection)", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
|
{"invalid connection id", types.Counterparty{clientID, "(InvalidConnection)", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
|
||||||
{"invalid prefix", Counterparty{clientID, connectionID2, emptyPrefix}, false},
|
{"invalid prefix", types.Counterparty{clientID, connectionID2, emptyPrefix}, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||||
)
|
)
|
||||||
|
@ -13,21 +14,21 @@ func TestValidateGenesis(t *testing.T) {
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
genState GenesisState
|
genState types.GenesisState
|
||||||
expPass bool
|
expPass bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
genState: DefaultGenesisState(),
|
genState: types.DefaultGenesisState(),
|
||||||
expPass: true,
|
expPass: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid genesis",
|
name: "valid genesis",
|
||||||
genState: NewGenesisState(
|
genState: types.NewGenesisState(
|
||||||
[]ConnectionEnd{
|
[]types.ConnectionEnd{
|
||||||
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
types.NewConnectionEnd(types.INIT, connectionID, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
||||||
},
|
},
|
||||||
[]ConnectionPaths{
|
[]types.ConnectionPaths{
|
||||||
{clientID, []string{host.ConnectionPath(connectionID)}},
|
{clientID, []string{host.ConnectionPath(connectionID)}},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -35,11 +36,11 @@ func TestValidateGenesis(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid connection",
|
name: "invalid connection",
|
||||||
genState: NewGenesisState(
|
genState: types.NewGenesisState(
|
||||||
[]ConnectionEnd{
|
[]types.ConnectionEnd{
|
||||||
NewConnectionEnd(INIT, connectionID, "(CLIENTIDONE)", Counterparty{clientID, connectionID, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
types.NewConnectionEnd(types.INIT, connectionID, "(CLIENTIDONE)", types.Counterparty{clientID, connectionID, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
||||||
},
|
},
|
||||||
[]ConnectionPaths{
|
[]types.ConnectionPaths{
|
||||||
{clientID, []string{host.ConnectionPath(connectionID)}},
|
{clientID, []string{host.ConnectionPath(connectionID)}},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -47,11 +48,11 @@ func TestValidateGenesis(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid client id",
|
name: "invalid client id",
|
||||||
genState: NewGenesisState(
|
genState: types.NewGenesisState(
|
||||||
[]ConnectionEnd{
|
[]types.ConnectionEnd{
|
||||||
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
types.NewConnectionEnd(types.INIT, connectionID, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
||||||
},
|
},
|
||||||
[]ConnectionPaths{
|
[]types.ConnectionPaths{
|
||||||
{"(CLIENTIDONE)", []string{host.ConnectionPath(connectionID)}},
|
{"(CLIENTIDONE)", []string{host.ConnectionPath(connectionID)}},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -59,11 +60,11 @@ func TestValidateGenesis(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid path",
|
name: "invalid path",
|
||||||
genState: NewGenesisState(
|
genState: types.NewGenesisState(
|
||||||
[]ConnectionEnd{
|
[]types.ConnectionEnd{
|
||||||
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
types.NewConnectionEnd(types.INIT, connectionID, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
|
||||||
},
|
},
|
||||||
[]ConnectionPaths{
|
[]types.ConnectionPaths{
|
||||||
{clientID, []string{connectionID}},
|
{clientID, []string{connectionID}},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,18 +57,18 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() {
|
||||||
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
|
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
|
||||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||||
|
|
||||||
testMsgs := []*MsgConnectionOpenInit{
|
testMsgs := []*types.MsgConnectionOpenInit{
|
||||||
NewMsgConnectionOpenInit("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, signer),
|
types.NewMsgConnectionOpenInit("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, signer),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer),
|
types.NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer),
|
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "test/conn1", prefix, signer),
|
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "test/conn1", prefix, signer),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", emptyPrefix, signer),
|
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", emptyPrefix, signer),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, nil),
|
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, nil),
|
||||||
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, signer),
|
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, signer),
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
msg *MsgConnectionOpenInit
|
msg *types.MsgConnectionOpenInit
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -94,23 +95,23 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||||
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
|
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
|
||||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||||
|
|
||||||
testMsgs := []*MsgConnectionOpenTry{
|
testMsgs := []*types.MsgConnectionOpenTry{
|
||||||
NewMsgConnectionOpenTry("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "test/conn1", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "test/conn1", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", emptyPrefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", emptyPrefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, emptyProof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, emptyProof, suite.proof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, emptyProof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, emptyProof, 10, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 0, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 0, 10, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 0, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 0, signer),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, nil),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, nil),
|
||||||
NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
msg *MsgConnectionOpenTry
|
msg *types.MsgConnectionOpenTry
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -141,18 +142,18 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||||
func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||||
|
|
||||||
testMsgs := []*MsgConnectionOpenAck{
|
testMsgs := []*types.MsgConnectionOpenAck{
|
||||||
NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 0, 10, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 0, 10, "1.0.0", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 0, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 0, "1.0.0", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "", signer),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", nil),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", nil),
|
||||||
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
|
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
|
||||||
}
|
}
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
msg *MsgConnectionOpenAck
|
msg *types.MsgConnectionOpenAck
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -179,16 +180,16 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||||
func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
|
func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
|
||||||
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")
|
||||||
|
|
||||||
testMsgs := []*MsgConnectionOpenConfirm{
|
testMsgs := []*types.MsgConnectionOpenConfirm{
|
||||||
NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer),
|
types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer),
|
||||||
NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer),
|
types.NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer),
|
||||||
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer),
|
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer),
|
||||||
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil),
|
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil),
|
||||||
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer),
|
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer),
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
msg *MsgConnectionOpenConfirm
|
msg *types.MsgConnectionOpenConfirm
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCounterpartyValidateBasic(t *testing.T) {
|
func TestCounterpartyValidateBasic(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
counterparty Counterparty
|
counterparty types.Counterparty
|
||||||
expPass bool
|
expPass bool
|
||||||
}{
|
}{
|
||||||
{"valid counterparty", Counterparty{"portidone", "channelidone"}, true},
|
{"valid counterparty", types.Counterparty{"portidone", "channelidone"}, true},
|
||||||
{"invalid port id", Counterparty{"(InvalidPort)", "channelidone"}, false},
|
{"invalid port id", types.Counterparty{"(InvalidPort)", "channelidone"}, false},
|
||||||
{"invalid channel id", Counterparty{"portidone", "(InvalidChannel)"}, false},
|
{"invalid channel id", types.Counterparty{"portidone", "(InvalidChannel)"}, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -14,63 +16,63 @@ const (
|
||||||
testChannel1 = "firstchannel"
|
testChannel1 = "firstchannel"
|
||||||
testChannel2 = "secondchannel"
|
testChannel2 = "secondchannel"
|
||||||
|
|
||||||
testChannelOrder = ORDERED
|
testChannelOrder = types.ORDERED
|
||||||
testChannelVersion = "1.0"
|
testChannelVersion = "1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestValidateGenesis(t *testing.T) {
|
func TestValidateGenesis(t *testing.T) {
|
||||||
counterparty1 := NewCounterparty(testPort1, testChannel1)
|
counterparty1 := types.NewCounterparty(testPort1, testChannel1)
|
||||||
counterparty2 := NewCounterparty(testPort2, testChannel2)
|
counterparty2 := types.NewCounterparty(testPort2, testChannel2)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
genState GenesisState
|
genState types.GenesisState
|
||||||
expPass bool
|
expPass bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
genState: DefaultGenesisState(),
|
genState: types.DefaultGenesisState(),
|
||||||
expPass: true,
|
expPass: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid genesis",
|
name: "valid genesis",
|
||||||
genState: NewGenesisState(
|
genState: types.NewGenesisState(
|
||||||
[]IdentifiedChannel{
|
[]types.IdentifiedChannel{
|
||||||
NewIdentifiedChannel(
|
types.NewIdentifiedChannel(
|
||||||
testPort1, testChannel1, NewChannel(
|
testPort1, testChannel1, types.NewChannel(
|
||||||
INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion,
|
types.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
NewIdentifiedChannel(
|
types.NewIdentifiedChannel(
|
||||||
testPort2, testChannel2, NewChannel(
|
testPort2, testChannel2, types.NewChannel(
|
||||||
INIT, testChannelOrder, counterparty1, []string{testConnectionIDA}, testChannelVersion,
|
types.INIT, testChannelOrder, counterparty1, []string{testConnectionIDA}, testChannelVersion,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
[]PacketAckCommitment{
|
[]types.PacketAckCommitment{
|
||||||
NewPacketAckCommitment(testPort2, testChannel2, 1, []byte("ack")),
|
types.NewPacketAckCommitment(testPort2, testChannel2, 1, []byte("ack")),
|
||||||
},
|
},
|
||||||
[]PacketAckCommitment{
|
[]types.PacketAckCommitment{
|
||||||
NewPacketAckCommitment(testPort1, testChannel1, 1, []byte("commit_hash")),
|
types.NewPacketAckCommitment(testPort1, testChannel1, 1, []byte("commit_hash")),
|
||||||
},
|
},
|
||||||
[]PacketSequence{
|
[]types.PacketSequence{
|
||||||
NewPacketSequence(testPort1, testChannel1, 1),
|
types.NewPacketSequence(testPort1, testChannel1, 1),
|
||||||
},
|
},
|
||||||
[]PacketSequence{
|
[]types.PacketSequence{
|
||||||
NewPacketSequence(testPort2, testChannel2, 1),
|
types.NewPacketSequence(testPort2, testChannel2, 1),
|
||||||
},
|
},
|
||||||
[]PacketSequence{
|
[]types.PacketSequence{
|
||||||
NewPacketSequence(testPort2, testChannel2, 1),
|
types.NewPacketSequence(testPort2, testChannel2, 1),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
expPass: true,
|
expPass: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid channel",
|
name: "invalid channel",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
Channels: []IdentifiedChannel{
|
Channels: []types.IdentifiedChannel{
|
||||||
NewIdentifiedChannel(
|
types.NewIdentifiedChannel(
|
||||||
testPort1, "(testChannel1)", NewChannel(
|
testPort1, "(testChannel1)", types.NewChannel(
|
||||||
INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion,
|
types.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -79,54 +81,54 @@ func TestValidateGenesis(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid ack",
|
name: "invalid ack",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
Acknowledgements: []PacketAckCommitment{
|
Acknowledgements: []types.PacketAckCommitment{
|
||||||
NewPacketAckCommitment(testPort2, testChannel2, 1, nil),
|
types.NewPacketAckCommitment(testPort2, testChannel2, 1, nil),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid commitment",
|
name: "invalid commitment",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
Commitments: []PacketAckCommitment{
|
Commitments: []types.PacketAckCommitment{
|
||||||
NewPacketAckCommitment(testPort1, testChannel1, 1, nil),
|
types.NewPacketAckCommitment(testPort1, testChannel1, 1, nil),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid send seq",
|
name: "invalid send seq",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
SendSequences: []PacketSequence{
|
SendSequences: []types.PacketSequence{
|
||||||
NewPacketSequence(testPort1, testChannel1, 0),
|
types.NewPacketSequence(testPort1, testChannel1, 0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid recv seq",
|
name: "invalid recv seq",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
RecvSequences: []PacketSequence{
|
RecvSequences: []types.PacketSequence{
|
||||||
NewPacketSequence(testPort1, "(testChannel1)", 1),
|
types.NewPacketSequence(testPort1, "(testChannel1)", 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid recv seq 2",
|
name: "invalid recv seq 2",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
RecvSequences: []PacketSequence{
|
RecvSequences: []types.PacketSequence{
|
||||||
NewPacketSequence("(testPort1)", testChannel1, 1),
|
types.NewPacketSequence("(testPort1)", testChannel1, 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid ack seq",
|
name: "invalid ack seq",
|
||||||
genState: GenesisState{
|
genState: types.GenesisState{
|
||||||
AckSequences: []PacketSequence{
|
AckSequences: []types.PacketSequence{
|
||||||
NewPacketSequence(testPort1, "(testChannel1)", 1),
|
types.NewPacketSequence(testPort1, "(testChannel1)", 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expPass: false,
|
expPass: false,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||||
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
|
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
|
||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||||
)
|
)
|
||||||
|
@ -79,26 +80,26 @@ func TestMsgTestSuite(t *testing.T) {
|
||||||
|
|
||||||
// TestMsgChannelOpenInit tests ValidateBasic for MsgChannelOpenInit
|
// TestMsgChannelOpenInit tests ValidateBasic for MsgChannelOpenInit
|
||||||
func (suite *MsgTestSuite) TestMsgChannelOpenInit() {
|
func (suite *MsgTestSuite) TestMsgChannelOpenInit() {
|
||||||
testMsgs := []*MsgChannelOpenInit{
|
testMsgs := []*types.MsgChannelOpenInit{
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg
|
||||||
NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id
|
types.NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id
|
||||||
NewMsgChannelOpenInit(invalidLongPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long port id
|
types.NewMsgChannelOpenInit(invalidLongPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long port id
|
||||||
NewMsgChannelOpenInit(invalidPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // port id contains non-alpha
|
types.NewMsgChannelOpenInit(invalidPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // port id contains non-alpha
|
||||||
NewMsgChannelOpenInit("testportid", invalidShortChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short channel id
|
types.NewMsgChannelOpenInit("testportid", invalidShortChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short channel id
|
||||||
NewMsgChannelOpenInit("testportid", invalidLongChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long channel id
|
types.NewMsgChannelOpenInit("testportid", invalidLongChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long channel id
|
||||||
NewMsgChannelOpenInit("testportid", invalidChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // channel id contains non-alpha
|
types.NewMsgChannelOpenInit("testportid", invalidChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", addr), // channel id contains non-alpha
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", Order(3), connHops, "testcpport", "testcpchannel", addr), // invalid channel order
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.Order(3), connHops, "testcpport", "testcpchannel", addr), // invalid channel order
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ORDERED, invalidConnHops, "testcpport", "testcpchannel", addr), // connection hops more than 1
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.ORDERED, invalidConnHops, "testcpport", "testcpchannel", addr), // connection hops more than 1
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", addr), // too short connection id
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", addr), // too short connection id
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", addr), // too long connection id
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", addr), // too long connection id
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", addr), // connection id contains non-alpha
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", addr), // connection id contains non-alpha
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "", UNORDERED, connHops, "testcpport", "testcpchannel", addr), // empty channel version
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "", types.UNORDERED, connHops, "testcpport", "testcpchannel", addr), // empty channel version
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", UNORDERED, connHops, invalidPort, "testcpchannel", addr), // invalid counterparty port id
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.UNORDERED, connHops, invalidPort, "testcpchannel", addr), // invalid counterparty port id
|
||||||
NewMsgChannelOpenInit("testportid", "testchannel", "1.0", UNORDERED, connHops, "testcpport", invalidChannel, addr), // invalid counterparty channel id
|
types.NewMsgChannelOpenInit("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", invalidChannel, addr), // invalid counterparty channel id
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelOpenInit
|
msg *types.MsgChannelOpenInit
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -131,28 +132,28 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() {
|
||||||
|
|
||||||
// TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry
|
// TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry
|
||||||
func (suite *MsgTestSuite) TestMsgChannelOpenTry() {
|
func (suite *MsgTestSuite) TestMsgChannelOpenTry() {
|
||||||
testMsgs := []*MsgChannelOpenTry{
|
testMsgs := []*types.MsgChannelOpenTry{
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg
|
||||||
NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id
|
types.NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id
|
||||||
NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id
|
types.NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id
|
||||||
NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha
|
types.NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha
|
||||||
NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short channel id
|
types.NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short channel id
|
||||||
NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long channel id
|
types.NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long channel id
|
||||||
NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // channel id contains non-alpha
|
types.NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // channel id contains non-alpha
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 1, addr), // empty counterparty version
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 1, addr), // empty counterparty version
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, addr), // suite.proof height is zero
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, addr), // suite.proof height is zero
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // invalid channel order
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // invalid channel order
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection hops more than 1
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection hops more than 1
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short connection id
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short connection id
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long connection id
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long connection id
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection id contains non-alpha
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection id contains non-alpha
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "", UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id
|
||||||
NewMsgChannelOpenTry("testportid", "testchannel", "1.0", UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id
|
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelOpenTry
|
msg *types.MsgChannelOpenTry
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -187,21 +188,21 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() {
|
||||||
|
|
||||||
// TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck
|
// TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck
|
||||||
func (suite *MsgTestSuite) TestMsgChannelOpenAck() {
|
func (suite *MsgTestSuite) TestMsgChannelOpenAck() {
|
||||||
testMsgs := []*MsgChannelOpenAck{
|
testMsgs := []*types.MsgChannelOpenAck{
|
||||||
NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg
|
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg
|
||||||
NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id
|
types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id
|
||||||
NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id
|
types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id
|
||||||
NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha
|
types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha
|
||||||
NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 1, addr), // too short channel id
|
types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 1, addr), // too short channel id
|
||||||
NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id
|
types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id
|
||||||
NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha
|
types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha
|
||||||
NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version
|
types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version
|
||||||
NewMsgChannelOpenAck("testportid", "testchannel", "1.0", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
||||||
NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero
|
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelOpenAck
|
msg *types.MsgChannelOpenAck
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -229,20 +230,20 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() {
|
||||||
|
|
||||||
// TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm
|
// TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm
|
||||||
func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() {
|
func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() {
|
||||||
testMsgs := []*MsgChannelOpenConfirm{
|
testMsgs := []*types.MsgChannelOpenConfirm{
|
||||||
NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg
|
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg
|
||||||
NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id
|
types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id
|
||||||
NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id
|
types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id
|
||||||
NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha
|
types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha
|
||||||
NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id
|
types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id
|
||||||
NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id
|
types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id
|
||||||
NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha
|
types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha
|
||||||
NewMsgChannelOpenConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
types.NewMsgChannelOpenConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
||||||
NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero
|
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelOpenConfirm
|
msg *types.MsgChannelOpenConfirm
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -269,18 +270,18 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() {
|
||||||
|
|
||||||
// TestMsgChannelCloseInit tests ValidateBasic for MsgChannelCloseInit
|
// TestMsgChannelCloseInit tests ValidateBasic for MsgChannelCloseInit
|
||||||
func (suite *MsgTestSuite) TestMsgChannelCloseInit() {
|
func (suite *MsgTestSuite) TestMsgChannelCloseInit() {
|
||||||
testMsgs := []*MsgChannelCloseInit{
|
testMsgs := []*types.MsgChannelCloseInit{
|
||||||
NewMsgChannelCloseInit("testportid", "testchannel", addr), // valid msg
|
types.NewMsgChannelCloseInit("testportid", "testchannel", addr), // valid msg
|
||||||
NewMsgChannelCloseInit(invalidShortPort, "testchannel", addr), // too short port id
|
types.NewMsgChannelCloseInit(invalidShortPort, "testchannel", addr), // too short port id
|
||||||
NewMsgChannelCloseInit(invalidLongPort, "testchannel", addr), // too long port id
|
types.NewMsgChannelCloseInit(invalidLongPort, "testchannel", addr), // too long port id
|
||||||
NewMsgChannelCloseInit(invalidPort, "testchannel", addr), // port id contains non-alpha
|
types.NewMsgChannelCloseInit(invalidPort, "testchannel", addr), // port id contains non-alpha
|
||||||
NewMsgChannelCloseInit("testportid", invalidShortChannel, addr), // too short channel id
|
types.NewMsgChannelCloseInit("testportid", invalidShortChannel, addr), // too short channel id
|
||||||
NewMsgChannelCloseInit("testportid", invalidLongChannel, addr), // too long channel id
|
types.NewMsgChannelCloseInit("testportid", invalidLongChannel, addr), // too long channel id
|
||||||
NewMsgChannelCloseInit("testportid", invalidChannel, addr), // channel id contains non-alpha
|
types.NewMsgChannelCloseInit("testportid", invalidChannel, addr), // channel id contains non-alpha
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelCloseInit
|
msg *types.MsgChannelCloseInit
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -305,20 +306,20 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() {
|
||||||
|
|
||||||
// TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm
|
// TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm
|
||||||
func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() {
|
func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() {
|
||||||
testMsgs := []*MsgChannelCloseConfirm{
|
testMsgs := []*types.MsgChannelCloseConfirm{
|
||||||
NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg
|
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg
|
||||||
NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id
|
types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id
|
||||||
NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id
|
types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id
|
||||||
NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha
|
types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha
|
||||||
NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id
|
types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id
|
||||||
NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id
|
types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id
|
||||||
NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha
|
types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha
|
||||||
NewMsgChannelCloseConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
types.NewMsgChannelCloseConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof
|
||||||
NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero
|
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgChannelCloseConfirm
|
msg *types.MsgChannelCloseConfirm
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -352,8 +353,8 @@ var (
|
||||||
unknownPacketData = []byte("unknown")
|
unknownPacketData = []byte("unknown")
|
||||||
invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
||||||
|
|
||||||
packet = NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
||||||
unknownPacket = NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
unknownPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
||||||
invalidAck = invalidAckData
|
invalidAck = invalidAckData
|
||||||
|
|
||||||
emptyProof = commitmenttypes.MerkleProof{Proof: nil}
|
emptyProof = commitmenttypes.MerkleProof{Proof: nil}
|
||||||
|
@ -371,23 +372,23 @@ var (
|
||||||
|
|
||||||
// TestMsgPacketType tests Type for MsgPacket
|
// TestMsgPacketType tests Type for MsgPacket
|
||||||
func TestMsgPacketType(t *testing.T) {
|
func TestMsgPacketType(t *testing.T) {
|
||||||
msg := NewMsgPacket(packet, proof, 1, addr1)
|
msg := types.NewMsgPacket(packet, proof, 1, addr1)
|
||||||
|
|
||||||
require.Equal(t, []byte("testdata"), msg.Packet.GetData())
|
require.Equal(t, []byte("testdata"), msg.Packet.GetData())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestMsgPacketValidation tests ValidateBasic for MsgPacket
|
// TestMsgPacketValidation tests ValidateBasic for MsgPacket
|
||||||
func TestMsgPacketValidation(t *testing.T) {
|
func TestMsgPacketValidation(t *testing.T) {
|
||||||
testMsgs := []*MsgPacket{
|
testMsgs := []*types.MsgPacket{
|
||||||
NewMsgPacket(packet, proof, 1, addr1), // valid msg
|
types.NewMsgPacket(packet, proof, 1, addr1), // valid msg
|
||||||
NewMsgPacket(packet, proof, 0, addr1), // proof height is zero
|
types.NewMsgPacket(packet, proof, 0, addr1), // proof height is zero
|
||||||
NewMsgPacket(packet, invalidProofs2, 1, addr1), // proof contain empty proof
|
types.NewMsgPacket(packet, invalidProofs2, 1, addr1), // proof contain empty proof
|
||||||
NewMsgPacket(packet, proof, 1, emptyAddr), // missing signer address
|
types.NewMsgPacket(packet, proof, 1, emptyAddr), // missing signer address
|
||||||
NewMsgPacket(unknownPacket, proof, 1, addr1), // unknown packet
|
types.NewMsgPacket(unknownPacket, proof, 1, addr1), // unknown packet
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgPacket
|
msg *types.MsgPacket
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -410,7 +411,7 @@ func TestMsgPacketValidation(t *testing.T) {
|
||||||
|
|
||||||
// TestMsgPacketGetSignBytes tests GetSignBytes for MsgPacket
|
// TestMsgPacketGetSignBytes tests GetSignBytes for MsgPacket
|
||||||
func TestMsgPacketGetSignBytes(t *testing.T) {
|
func TestMsgPacketGetSignBytes(t *testing.T) {
|
||||||
msg := NewMsgPacket(packet, proof, 1, addr1)
|
msg := types.NewMsgPacket(packet, proof, 1, addr1)
|
||||||
res := msg.GetSignBytes()
|
res := msg.GetSignBytes()
|
||||||
|
|
||||||
expected := fmt.Sprintf(
|
expected := fmt.Sprintf(
|
||||||
|
@ -422,7 +423,7 @@ func TestMsgPacketGetSignBytes(t *testing.T) {
|
||||||
|
|
||||||
// TestMsgPacketGetSigners tests GetSigners for MsgPacket
|
// TestMsgPacketGetSigners tests GetSigners for MsgPacket
|
||||||
func TestMsgPacketGetSigners(t *testing.T) {
|
func TestMsgPacketGetSigners(t *testing.T) {
|
||||||
msg := NewMsgPacket(packet, proof, 1, addr1)
|
msg := types.NewMsgPacket(packet, proof, 1, addr1)
|
||||||
res := msg.GetSigners()
|
res := msg.GetSigners()
|
||||||
|
|
||||||
expected := "[746573746164647231]"
|
expected := "[746573746164647231]"
|
||||||
|
@ -431,16 +432,16 @@ func TestMsgPacketGetSigners(t *testing.T) {
|
||||||
|
|
||||||
// TestMsgTimeout tests ValidateBasic for MsgTimeout
|
// TestMsgTimeout tests ValidateBasic for MsgTimeout
|
||||||
func (suite *MsgTestSuite) TestMsgTimeout() {
|
func (suite *MsgTestSuite) TestMsgTimeout() {
|
||||||
testMsgs := []*MsgTimeout{
|
testMsgs := []*types.MsgTimeout{
|
||||||
NewMsgTimeout(packet, 1, proof, 1, addr),
|
types.NewMsgTimeout(packet, 1, proof, 1, addr),
|
||||||
NewMsgTimeout(packet, 1, proof, 0, addr),
|
types.NewMsgTimeout(packet, 1, proof, 0, addr),
|
||||||
NewMsgTimeout(packet, 1, proof, 1, emptyAddr),
|
types.NewMsgTimeout(packet, 1, proof, 1, emptyAddr),
|
||||||
NewMsgTimeout(packet, 1, emptyProof, 1, addr),
|
types.NewMsgTimeout(packet, 1, emptyProof, 1, addr),
|
||||||
NewMsgTimeout(unknownPacket, 1, proof, 1, addr),
|
types.NewMsgTimeout(unknownPacket, 1, proof, 1, addr),
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgTimeout
|
msg *types.MsgTimeout
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
@ -463,17 +464,17 @@ func (suite *MsgTestSuite) TestMsgTimeout() {
|
||||||
|
|
||||||
// TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement
|
// TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement
|
||||||
func (suite *MsgTestSuite) TestMsgAcknowledgement() {
|
func (suite *MsgTestSuite) TestMsgAcknowledgement() {
|
||||||
testMsgs := []*MsgAcknowledgement{
|
testMsgs := []*types.MsgAcknowledgement{
|
||||||
NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, addr),
|
types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, addr),
|
||||||
NewMsgAcknowledgement(packet, packet.GetData(), proof, 0, addr),
|
types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 0, addr),
|
||||||
NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, emptyAddr),
|
types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, emptyAddr),
|
||||||
NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 1, addr),
|
types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 1, addr),
|
||||||
NewMsgAcknowledgement(unknownPacket, packet.GetData(), proof, 1, addr),
|
types.NewMsgAcknowledgement(unknownPacket, packet.GetData(), proof, 1, addr),
|
||||||
NewMsgAcknowledgement(packet, invalidAck, proof, 1, addr),
|
types.NewMsgAcknowledgement(packet, invalidAck, proof, 1, addr),
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg *MsgAcknowledgement
|
msg *types.MsgAcknowledgement
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
package types
|
package types_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPacketValidateBasic(t *testing.T) {
|
func TestPacketValidateBasic(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
packet Packet
|
packet types.Packet
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
{types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
||||||
{NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"},
|
{types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"},
|
||||||
{NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"},
|
{types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"},
|
||||||
{NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"},
|
{types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"},
|
{types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"},
|
{types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, disabledTimeout), false, "disabled both timeout height and timestamp"},
|
{types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, disabledTimeout), false, "disabled both timeout height and timestamp"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"},
|
{types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, disabledTimeout), true, "disabled timeout timestamp, valid timeout height"},
|
{types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, disabledTimeout), true, "disabled timeout timestamp, valid timeout height"},
|
||||||
{NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
{types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
|
|
Loading…
Reference in New Issue