-
Notifications
You must be signed in to change notification settings - Fork 0
/
keeper_test.go
112 lines (91 loc) · 3.13 KB
/
keeper_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package keeper_test
import (
"testing"
"time"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
"github.com/stretchr/testify/suite"
"github.com/ingenuity-build/quicksilver/app"
"github.com/ingenuity-build/quicksilver/utils"
icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
)
var testAddress = utils.GenerateAccAddressForTest().String()
func init() {
ibctesting.DefaultTestingAppInit = app.SetupTestingApp
}
// TestKeeperTestSuite runs all the tests within this package.
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}
func newQuicksilverPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort
path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort
return path
}
type KeeperTestSuite struct {
suite.Suite
coordinator *ibctesting.Coordinator
// testing chains used for convenience and readability
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
path *ibctesting.Path
}
func (s *KeeperTestSuite) GetQuicksilverApp(chain *ibctesting.TestChain) *app.Quicksilver {
app, ok := chain.App.(*app.Quicksilver)
if !ok {
panic("not quicksilver app")
}
return app
}
// SetupTest creates a coordinator with 2 test chains.
func (suite *KeeperTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) // initializes 2 test chains
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) // convenience and readability
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) // convenience and readability
suite.path = newQuicksilverPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(suite.path)
suite.coordinator.CurrentTime = time.Now().UTC()
suite.coordinator.UpdateTime()
suite.initTestZone()
}
func (suite *KeeperTestSuite) initTestZone() {
// test zone
zone := icstypes.Zone{
ConnectionId: suite.path.EndpointA.ConnectionID,
ChainId: suite.chainB.ChainID,
AccountPrefix: "bcosmos",
LocalDenom: "uqatom",
BaseDenom: "uatom",
ReturnToSender: false,
UnbondingEnabled: false,
LiquidityModule: true,
Decimals: 6,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)
// cosmos zone
zone = icstypes.Zone{
ConnectionId: "connection-77001",
ChainId: "cosmoshub-4",
AccountPrefix: "cosmos",
LocalDenom: "uqatom",
BaseDenom: "uatom",
ReturnToSender: false,
UnbondingEnabled: false,
LiquidityModule: true,
Decimals: 6,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)
// osmosis zone
zone = icstypes.Zone{
ConnectionId: "connection-77002",
ChainId: "osmosis-1",
AccountPrefix: "osmo",
LocalDenom: "uqosmo",
BaseDenom: "uosmo",
ReturnToSender: false,
UnbondingEnabled: false,
LiquidityModule: true,
Decimals: 6,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)
}