Skip to content

Commit

Permalink
Update connection and channel to use types_test package name (cosmos#…
Browse files Browse the repository at this point in the history
…6395)

* convert connection types test pacakge name

* convert channel types test package name

Co-authored-by: Alexander Bezobchuk <[email protected]>
  • Loading branch information
colin-axner and alexanderbez authored Jun 11, 2020
1 parent 82afd52 commit affe726
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 244 deletions.
27 changes: 14 additions & 13 deletions x/ibc/03-connection/types/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package types
package types_test

import (
"testing"

"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"
)

Expand All @@ -18,37 +19,37 @@ var (
func TestConnectionValidateBasic(t *testing.T) {
testCases := []struct {
name string
connection ConnectionEnd
connection types.ConnectionEnd
expPass bool
}{
{
"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,
},
{
"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,
},
{
"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,
},
{
"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,
},
{
"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,
},
{
"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,
},
}
Expand All @@ -68,13 +69,13 @@ func TestConnectionValidateBasic(t *testing.T) {
func TestCounterpartyValidateBasic(t *testing.T) {
testCases := []struct {
name string
counterparty Counterparty
counterparty types.Counterparty
expPass bool
}{
{"valid counterparty", Counterparty{clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true},
{"invalid client id", Counterparty{"(InvalidClient)", connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
{"invalid connection id", Counterparty{clientID, "(InvalidConnection)", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
{"invalid prefix", Counterparty{clientID, connectionID2, emptyPrefix}, false},
{"valid counterparty", types.Counterparty{clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true},
{"invalid client id", types.Counterparty{"(InvalidClient)", connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
{"invalid connection id", types.Counterparty{clientID, "(InvalidConnection)", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false},
{"invalid prefix", types.Counterparty{clientID, connectionID2, emptyPrefix}, false},
}

for i, tc := range testCases {
Expand Down
39 changes: 20 additions & 19 deletions x/ibc/03-connection/types/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package types
package types_test

import (
"testing"

"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"
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
)
Expand All @@ -13,57 +14,57 @@ func TestValidateGenesis(t *testing.T) {

testCases := []struct {
name string
genState GenesisState
genState types.GenesisState
expPass bool
}{
{
name: "default",
genState: DefaultGenesisState(),
genState: types.DefaultGenesisState(),
expPass: true,
},
{
name: "valid genesis",
genState: NewGenesisState(
[]ConnectionEnd{
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
genState: types.NewGenesisState(
[]types.ConnectionEnd{
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)}},
},
),
expPass: true,
},
{
name: "invalid connection",
genState: NewGenesisState(
[]ConnectionEnd{
NewConnectionEnd(INIT, connectionID, "(CLIENTIDONE)", Counterparty{clientID, connectionID, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
genState: types.NewGenesisState(
[]types.ConnectionEnd{
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)}},
},
),
expPass: false,
},
{
name: "invalid client id",
genState: NewGenesisState(
[]ConnectionEnd{
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
genState: types.NewGenesisState(
[]types.ConnectionEnd{
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)}},
},
),
expPass: false,
},
{
name: "invalid path",
genState: NewGenesisState(
[]ConnectionEnd{
NewConnectionEnd(INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
genState: types.NewGenesisState(
[]types.ConnectionEnd{
types.NewConnectionEnd(types.INIT, connectionID, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}),
},
[]ConnectionPaths{
[]types.ConnectionPaths{
{clientID, []string{connectionID}},
},
),
Expand Down
83 changes: 42 additions & 41 deletions x/ibc/03-connection/types/msgs_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types
package types_test

import (
"fmt"
Expand All @@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/rootmulti"
storetypes "github.com/cosmos/cosmos-sdk/store/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"
)

Expand Down Expand Up @@ -56,18 +57,18 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() {
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")

testMsgs := []*MsgConnectionOpenInit{
NewMsgConnectionOpenInit("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, signer),
NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer),
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer),
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "test/conn1", prefix, signer),
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", emptyPrefix, signer),
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, nil),
NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, signer),
testMsgs := []*types.MsgConnectionOpenInit{
types.NewMsgConnectionOpenInit("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, signer),
types.NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer),
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer),
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "test/conn1", prefix, signer),
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", emptyPrefix, signer),
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, nil),
types.NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, signer),
}

var testCases = []struct {
msg *MsgConnectionOpenInit
msg *types.MsgConnectionOpenInit
expPass bool
errMsg string
}{
Expand All @@ -94,23 +95,23 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey"))
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")

testMsgs := []*MsgConnectionOpenTry{
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),
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),
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),
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),
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),
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),
testMsgs := []*types.MsgConnectionOpenTry{
types.NewMsgConnectionOpenTry("test/conn1", "clienttotesta", "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),
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", 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),
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", emptyPrefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer),
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{}, suite.proof, suite.proof, 10, 10, signer),
types.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"}, suite.proof, emptyProof, 10, 10, signer),
types.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, 10, 0, signer),
types.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, signer),
}

var testCases = []struct {
msg *MsgConnectionOpenTry
msg *types.MsgConnectionOpenTry
expPass bool
errMsg string
}{
Expand Down Expand Up @@ -141,18 +142,18 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")

testMsgs := []*MsgConnectionOpenAck{
NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 0, 10, "1.0.0", signer),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 0, "1.0.0", signer),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "", signer),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", nil),
NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
testMsgs := []*types.MsgConnectionOpenAck{
types.NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
types.NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 0, 10, "1.0.0", signer),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 0, "1.0.0", signer),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "", signer),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", nil),
types.NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", signer),
}
var testCases = []struct {
msg *MsgConnectionOpenAck
msg *types.MsgConnectionOpenAck
expPass bool
errMsg string
}{
Expand All @@ -179,16 +180,16 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht")

testMsgs := []*MsgConnectionOpenConfirm{
NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer),
NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer),
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer),
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil),
NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer),
testMsgs := []*types.MsgConnectionOpenConfirm{
types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer),
types.NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer),
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer),
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil),
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer),
}

var testCases = []struct {
msg *MsgConnectionOpenConfirm
msg *types.MsgConnectionOpenConfirm
expPass bool
errMsg string
}{
Expand Down
12 changes: 7 additions & 5 deletions x/ibc/04-channel/types/channel_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package types
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 Counterparty
counterparty types.Counterparty
expPass bool
}{
{"valid counterparty", Counterparty{"portidone", "channelidone"}, true},
{"invalid port id", Counterparty{"(InvalidPort)", "channelidone"}, false},
{"invalid channel id", Counterparty{"portidone", "(InvalidChannel)"}, false},
{"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 {
Expand Down
Loading

0 comments on commit affe726

Please sign in to comment.