-
Notifications
You must be signed in to change notification settings - Fork 685
/
Copy pathaccount_test.go
68 lines (59 loc) · 1.76 KB
/
account_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package keeper_test
import (
"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/testing"
)
func (suite *KeeperTestSuite) TestInitInterchainAccount() {
var (
owner string
path *ibctesting.Path
err error
)
testCases := []struct {
name string
malleate func()
expPass bool
}{
{
"success", func() {}, true,
},
/*
// TODO: https://github.com/cosmos/ibc-go/issues/288
{
"port is already bound", func() {
// mock init interchain account
portID := suite.chainA.GetSimApp().ICAKeeper.GeneratePortId(owner, path.EndpointA.ConnectionID)
suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID)
}, false,
},
*/
{
"fails to generate port-id", func() {
owner = ""
}, false,
},
{
"MsgChanOpenInit fails - channel is already active", func() {
portID, err := types.GeneratePortID(owner, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID)
suite.Require().NoError(err)
suite.chainA.GetSimApp().ICAKeeper.SetActiveChannel(suite.chainA.GetContext(), portID, path.EndpointA.ChannelID)
}, false,
},
}
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupTest() // reset
owner = "owner" // must be explicitly changed
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)
tc.malleate() // explicitly change fields in channel and testChannel
err = suite.chainA.GetSimApp().ICAKeeper.InitInterchainAccount(suite.chainA.GetContext(), path.EndpointA.ConnectionID, path.EndpointB.ConnectionID, owner)
if tc.expPass {
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
})
}
}