-
Notifications
You must be signed in to change notification settings - Fork 75
/
test_helpers.go
510 lines (410 loc) · 19.6 KB
/
test_helpers.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
package testutil
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path"
"testing"
"time"
tmrand "github.com/cometbft/cometbft/libs/rand"
"github.com/neutron-org/neutron/v4/utils"
"github.com/neutron-org/neutron/v4/app/config"
"cosmossdk.io/log"
cometbfttypes "github.com/cometbft/cometbft/abci/types"
db2 "github.com/cosmos/cosmos-db"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
icssimapp "github.com/cosmos/interchain-security/v5/testutil/ibc_testing"
"github.com/stretchr/testify/suite"
appparams "github.com/neutron-org/neutron/v4/app/params"
tokenfactorytypes "github.com/neutron-org/neutron/v4/x/tokenfactory/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
appProvider "github.com/cosmos/interchain-security/v5/app/provider"
e2e "github.com/cosmos/interchain-security/v5/testutil/integration"
"github.com/neutron-org/neutron/v4/app"
ictxstypes "github.com/neutron-org/neutron/v4/x/interchaintxs/types"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
cmttypes "github.com/cometbft/cometbft/types"
)
var (
// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "neutron17dtl0mjt3t77kpuhg2edqzjpszulwhgzcdvagh"
TestInterchainID = "owner_id"
// provider-consumer connection takes connection-0
ConnectionOne = "connection-1"
// TestVersion defines a reusable interchainaccounts version string for testing purposes
TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
ControllerConnectionId: ConnectionOne,
HostConnectionId: ConnectionOne,
Encoding: icatypes.EncodingProtobuf,
TxType: icatypes.TxTypeSDKMultiMsg,
}))
)
func init() {
// ibctesting.DefaultTestingAppInit = SetupTestingApp()
config.GetDefaultConfig()
// Disable cache since enabled cache triggers test errors when `AccAddress.String()`
// gets called before setting neutron bech32 prefix
sdk.SetAddrCacheEnabled(false)
}
type IBCConnectionTestSuite struct {
suite.Suite
Coordinator *ibctesting.Coordinator
// testing chains used for convenience and readability
ChainProvider *ibctesting.TestChain
ChainA *ibctesting.TestChain
ChainB *ibctesting.TestChain
ProviderApp e2e.ProviderApp
ChainAApp e2e.ConsumerApp
ChainBApp e2e.ConsumerApp
CCVPathA *ibctesting.Path
CCVPathB *ibctesting.Path
Path *ibctesting.Path
TransferPath *ibctesting.Path
}
func GetTestConsumerAdditionProp(chain *ibctesting.TestChain) *providertypes.ConsumerAdditionProposal { //nolint:staticcheck
prop := providertypes.NewConsumerAdditionProposal(
chain.ChainID,
"description",
chain.ChainID,
chain.LastHeader.GetHeight().(clienttypes.Height),
[]byte("gen_hash"),
[]byte("bin_hash"),
time.Now(),
ccv.DefaultConsumerRedistributeFrac,
ccv.DefaultBlocksPerDistributionTransmission,
"channel-0",
ccv.DefaultHistoricalEntries,
ccv.DefaultCCVTimeoutPeriod,
ccv.DefaultTransferTimeoutPeriod,
ccv.DefaultConsumerUnbondingPeriod,
).(*providertypes.ConsumerAdditionProposal) //nolint:staticcheck
return prop
}
func (suite *IBCConnectionTestSuite) SetupTest() {
// we need to redefine this variable to make tests work cause we use untrn as default bond denom in neutron
sdk.DefaultBondDenom = appparams.DefaultDenom
suite.Coordinator = NewProviderConsumerCoordinator(suite.T())
suite.ChainProvider = suite.Coordinator.GetChain(ibctesting.GetChainID(1))
suite.ChainA = suite.Coordinator.GetChain(ibctesting.GetChainID(2))
suite.ChainB = suite.Coordinator.GetChain(ibctesting.GetChainID(3))
suite.ProviderApp = suite.ChainProvider.App.(*appProvider.App)
suite.ChainAApp = suite.ChainA.App.(*app.App)
suite.ChainBApp = suite.ChainB.App.(*app.App)
providerKeeper := suite.ProviderApp.GetProviderKeeper()
consumerKeeperA := suite.ChainAApp.GetConsumerKeeper()
consumerKeeperB := suite.ChainBApp.GetConsumerKeeper()
// valsets must match
providerValUpdates := cmttypes.TM2PB.ValidatorUpdates(suite.ChainProvider.Vals)
consumerAValUpdates := cmttypes.TM2PB.ValidatorUpdates(suite.ChainA.Vals)
consumerBValUpdates := cmttypes.TM2PB.ValidatorUpdates(suite.ChainB.Vals)
suite.Require().True(len(providerValUpdates) == len(consumerAValUpdates), "initial valset not matching")
suite.Require().True(len(providerValUpdates) == len(consumerBValUpdates), "initial valset not matching")
for i := 0; i < len(providerValUpdates); i++ {
addr1, _ := ccv.TMCryptoPublicKeyToConsAddr(providerValUpdates[i].PubKey)
addr2, _ := ccv.TMCryptoPublicKeyToConsAddr(consumerAValUpdates[i].PubKey)
addr3, _ := ccv.TMCryptoPublicKeyToConsAddr(consumerBValUpdates[i].PubKey)
suite.Require().True(bytes.Equal(addr1, addr2), "validator mismatch")
suite.Require().True(bytes.Equal(addr1, addr3), "validator mismatch")
}
ct := suite.ChainProvider.GetContext()
// move chains to the next block
suite.ChainProvider.NextBlock()
suite.ChainA.NextBlock()
suite.ChainB.NextBlock()
// create consumer client on provider chain and set as consumer client for consumer chainID in provider keeper.
prop1 := GetTestConsumerAdditionProp(suite.ChainA)
err := providerKeeper.CreateConsumerClient(
ct,
prop1,
)
suite.Require().NoError(err)
prop2 := GetTestConsumerAdditionProp(suite.ChainB)
err = providerKeeper.CreateConsumerClient(
ct,
prop2,
)
suite.Require().NoError(err)
// move provider to next block to commit the state
suite.ChainProvider.NextBlock()
// initialize the consumer chain with the genesis state stored on the provider
consumerGenesisA, found := providerKeeper.GetConsumerGenesis(
suite.ChainProvider.GetContext(),
suite.ChainA.ChainID,
)
suite.Require().True(found, "consumer genesis not found")
genesisStateA := consumertypes.GenesisState{
Params: consumerGenesisA.Params,
Provider: consumerGenesisA.Provider,
NewChain: consumerGenesisA.NewChain,
}
consumerKeeperA.InitGenesis(suite.ChainA.GetContext(), &genesisStateA)
// initialize the consumer chain with the genesis state stored on the provider
consumerGenesisB, found := providerKeeper.GetConsumerGenesis(
suite.ChainProvider.GetContext(),
suite.ChainB.ChainID,
)
suite.Require().True(found, "consumer genesis not found")
genesisStateB := consumertypes.GenesisState{
Params: consumerGenesisB.Params,
Provider: consumerGenesisB.Provider,
NewChain: consumerGenesisB.NewChain,
}
consumerKeeperB.InitGenesis(suite.ChainB.GetContext(), &genesisStateB)
// create paths for the CCV channel
suite.CCVPathA = ibctesting.NewPath(suite.ChainA, suite.ChainProvider)
suite.CCVPathB = ibctesting.NewPath(suite.ChainB, suite.ChainProvider)
SetupCCVPath(suite.CCVPathA, suite)
SetupCCVPath(suite.CCVPathB, suite)
suite.SetupCCVChannels()
suite.Path = NewICAPath(suite.ChainA, suite.ChainB, suite.ChainProvider)
suite.Coordinator.SetupConnections(suite.Path)
}
func (suite *IBCConnectionTestSuite) ConfigureTransferChannel() {
suite.TransferPath = NewTransferPath(suite.ChainA, suite.ChainB, suite.ChainProvider)
suite.Coordinator.SetupConnections(suite.TransferPath)
err := SetupTransferPath(suite.TransferPath)
suite.Require().NoError(err)
}
func (suite *IBCConnectionTestSuite) FundAcc(acc sdk.AccAddress, amounts sdk.Coins) {
bankKeeper := suite.GetNeutronZoneApp(suite.ChainA).BankKeeper
err := bankKeeper.MintCoins(suite.ChainA.GetContext(), tokenfactorytypes.ModuleName, amounts)
suite.Require().NoError(err)
err = bankKeeper.SendCoinsFromModuleToAccount(suite.ChainA.GetContext(), tokenfactorytypes.ModuleName, acc, amounts)
suite.Require().NoError(err)
}
// update CCV path with correct info
func SetupCCVPath(path *ibctesting.Path, suite *IBCConnectionTestSuite) {
// - set provider endpoint's clientID
consumerClient, found := suite.ProviderApp.GetProviderKeeper().GetConsumerClientId(
suite.ChainProvider.GetContext(),
path.EndpointA.Chain.ChainID,
)
suite.Require().True(found, "consumer client not found")
path.EndpointB.ClientID = consumerClient
// - set consumer endpoint's clientID
consumerKeeper := path.EndpointA.Chain.App.(*app.App).GetConsumerKeeper()
providerClient, found := consumerKeeper.GetProviderClientID(path.EndpointA.Chain.GetContext())
suite.Require().True(found, "provider client not found")
path.EndpointA.ClientID = providerClient
// - client config
trustingPeriodFraction := suite.ProviderApp.GetProviderKeeper().GetTrustingPeriodFraction(suite.ChainProvider.GetContext())
providerUnbondingPeriod, err := suite.ProviderApp.GetTestStakingKeeper().UnbondingTime(suite.ChainProvider.GetContext())
suite.Require().NoError(err)
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = providerUnbondingPeriod
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(providerUnbondingPeriod, trustingPeriodFraction)
consumerUnbondingPeriod := consumerKeeper.GetUnbondingPeriod(path.EndpointA.Chain.GetContext())
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriod
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(consumerUnbondingPeriod, trustingPeriodFraction)
// - channel config
path.EndpointA.ChannelConfig.PortID = ccv.ConsumerPortID
path.EndpointB.ChannelConfig.PortID = ccv.ProviderPortID
path.EndpointA.ChannelConfig.Version = ccv.Version
path.EndpointB.ChannelConfig.Version = ccv.Version
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
}
func (suite *IBCConnectionTestSuite) SetupCCVChannels() {
paths := []*ibctesting.Path{suite.CCVPathA, suite.CCVPathB}
for _, path := range paths {
suite.Coordinator.CreateConnections(path)
err := path.EndpointA.ChanOpenInit()
suite.Require().NoError(err)
err = path.EndpointB.ChanOpenTry()
suite.Require().NoError(err)
err = path.EndpointA.ChanOpenAck()
suite.Require().NoError(err)
err = path.EndpointB.ChanOpenConfirm()
suite.Require().NoError(err)
err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
}
}
func testHomeDir(chainID string) string {
projectRoot := utils.RootDir()
return path.Join(projectRoot, ".testchains", chainID)
}
// NewCoordinator initializes Coordinator with interchain security dummy provider and 2 neutron consumer chains
func NewProviderConsumerCoordinator(t *testing.T) *ibctesting.Coordinator {
coordinator := ibctesting.NewCoordinator(t, 0)
chainID := ibctesting.GetChainID(1)
ibctesting.DefaultTestingAppInit = icssimapp.ProviderAppIniter
coordinator.Chains[chainID] = ibctesting.NewTestChain(t, coordinator, chainID)
providerChain := coordinator.GetChain(chainID)
_ = config.GetDefaultConfig()
sdk.SetAddrCacheEnabled(false)
chainID = ibctesting.GetChainID(2)
ibctesting.DefaultTestingAppInit = SetupTestingApp(cmttypes.TM2PB.ValidatorUpdates(providerChain.Vals))
coordinator.Chains[chainID] = ibctesting.NewTestChainWithValSet(t, coordinator,
chainID, providerChain.Vals, providerChain.Signers)
chainID = ibctesting.GetChainID(3)
coordinator.Chains[chainID] = ibctesting.NewTestChainWithValSet(t, coordinator,
chainID, providerChain.Vals, providerChain.Signers)
return coordinator
}
func (suite *IBCConnectionTestSuite) GetNeutronZoneApp(chain *ibctesting.TestChain) *app.App {
testApp, ok := chain.App.(*app.App)
if !ok {
panic("not NeutronZone app")
}
return testApp
}
func (suite *IBCConnectionTestSuite) StoreTestCode(ctx sdk.Context, addr sdk.AccAddress, path string) uint64 {
// wasm file built with https://github.com/neutron-org/neutron-sdk/tree/main/contracts/reflect
// wasm file built with https://github.com/neutron-org/neutron-dev-contracts/tree/feat/ica-register-fee-update/contracts/neutron_interchain_txs
wasmCode, err := os.ReadFile(path)
suite.Require().NoError(err)
codeID, _, err := keeper.NewDefaultPermissionKeeper(suite.GetNeutronZoneApp(suite.ChainA).WasmKeeper).Create(ctx, addr, wasmCode, &wasmtypes.AccessConfig{Permission: wasmtypes.AccessTypeEverybody})
suite.Require().NoError(err)
return codeID
}
func (suite *IBCConnectionTestSuite) InstantiateTestContract(ctx sdk.Context, funder sdk.AccAddress, codeID uint64) sdk.AccAddress {
initMsgBz := []byte("{}")
contractKeeper := keeper.NewDefaultPermissionKeeper(suite.GetNeutronZoneApp(suite.ChainA).WasmKeeper)
addr, _, err := contractKeeper.Instantiate(ctx, codeID, funder, funder, initMsgBz, "demo contract", nil)
suite.Require().NoError(err)
return addr
}
func NewICAPath(chainA, chainB, chainProvider *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointA.ChannelConfig.Version = TestVersion
path.EndpointB.ChannelConfig.Version = TestVersion
trustingPeriodFraction := chainProvider.App.(*appProvider.App).GetProviderKeeper().GetTrustingPeriodFraction(chainProvider.GetContext())
consumerUnbondingPeriodA := path.EndpointA.Chain.App.(*app.App).GetConsumerKeeper().GetUnbondingPeriod(path.EndpointA.Chain.GetContext())
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriodA
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(consumerUnbondingPeriodA, trustingPeriodFraction)
consumerUnbondingPeriodB := path.EndpointB.Chain.App.(*app.App).GetConsumerKeeper().GetUnbondingPeriod(path.EndpointB.Chain.GetContext())
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriodB
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(consumerUnbondingPeriodB, trustingPeriodFraction)
return path
}
// SetupICAPath invokes the InterchainAccounts entrypoint and subsequent channel handshake handlers
func SetupICAPath(path *ibctesting.Path, owner string) error {
if err := RegisterInterchainAccount(path.EndpointA, owner); err != nil {
return err
}
if err := path.EndpointB.ChanOpenTry(); err != nil {
return err
}
if err := path.EndpointA.ChanOpenAck(); err != nil {
return err
}
return path.EndpointB.ChanOpenConfirm()
}
// RegisterInterchainAccount is a helper function for starting the channel handshake
func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
icaOwner, _ := ictxstypes.NewICAOwner(owner, TestInterchainID)
portID, err := icatypes.NewControllerPortID(icaOwner.String())
if err != nil {
return err
}
ctx := endpoint.Chain.GetContext()
channelSequence := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(ctx)
a, ok := endpoint.Chain.App.(*app.App)
if !ok {
return fmt.Errorf("not NeutronZoneApp")
}
// TODO(pr0n00gler): are we sure it's okay?
if err := a.ICAControllerKeeper.RegisterInterchainAccount(ctx, endpoint.ConnectionID, icaOwner.String(), ""); err != nil {
return err
}
// commit state changes for proof verification
endpoint.Chain.NextBlock()
// update port/channel ids
endpoint.ChannelID = channeltypes.FormatChannelIdentifier(channelSequence)
endpoint.ChannelConfig.PortID = portID
return nil
}
// SetupTestingApp initializes the IBC-go testing application
func SetupTestingApp(initValUpdates []cometbfttypes.ValidatorUpdate) func() (ibctesting.TestingApp, map[string]json.RawMessage) {
return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
encoding := app.MakeEncodingConfig()
db := db2.NewMemDB()
homePath := testHomeDir("testchain-" + tmrand.NewRand().Str(6))
testApp := app.New(
log.NewNopLogger(),
db,
nil,
false,
map[int64]bool{},
homePath,
0,
encoding,
sims.EmptyAppOptions{},
nil,
)
// we need to set up a TestInitChainer where we can redefine MaxBlockGas in ConsensusParamsKeeper
testApp.SetInitChainer(testApp.TestInitChainer)
// and then we manually init baseapp and load states
testApp.LoadLatest()
genesisState := app.NewDefaultGenesisState(testApp.AppCodec())
// TODO: why isn't it in the `testApp.TestInitChainer`?
// NOTE ibc-go/v7/testing.SetupWithGenesisValSet requires a staking module
// genesisState or it panics. Feed a minimum one.
genesisState[stakingtypes.ModuleName] = encoding.Marshaler.MustMarshalJSON(
&stakingtypes.GenesisState{
Params: stakingtypes.Params{BondDenom: sdk.DefaultBondDenom},
},
)
var consumerGenesis ccv.ConsumerGenesisState
encoding.Marshaler.MustUnmarshalJSON(genesisState[consumertypes.ModuleName], &consumerGenesis)
consumerGenesis.Provider.InitialValSet = initValUpdates
consumerGenesis.Params.Enabled = true
genesisState[consumertypes.ModuleName] = encoding.Marshaler.MustMarshalJSON(&consumerGenesis)
return testApp, genesisState
}
}
// SetupValSetAppIniter is a simple wrapper for ICS e2e tests to satisfy interface
func SetupValSetAppIniter(initValUpdates []cometbfttypes.ValidatorUpdate) icssimapp.AppIniter {
return SetupTestingApp(initValUpdates)
}
func NewTransferPath(chainA, chainB, chainProvider *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = types.PortID
path.EndpointB.ChannelConfig.PortID = types.PortID
path.EndpointA.ChannelConfig.Order = channeltypes.UNORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.UNORDERED
path.EndpointA.ChannelConfig.Version = types.Version
path.EndpointB.ChannelConfig.Version = types.Version
trustingPeriodFraction := chainProvider.App.(*appProvider.App).GetProviderKeeper().GetTrustingPeriodFraction(chainProvider.GetContext())
consumerUnbondingPeriodA := path.EndpointA.Chain.App.(*app.App).GetConsumerKeeper().GetUnbondingPeriod(path.EndpointA.Chain.GetContext())
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriodA
path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(consumerUnbondingPeriodA, trustingPeriodFraction)
consumerUnbondingPeriodB := path.EndpointB.Chain.App.(*app.App).GetConsumerKeeper().GetUnbondingPeriod(path.EndpointB.Chain.GetContext())
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriodB
path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod, _ = ccv.CalculateTrustPeriod(consumerUnbondingPeriodB, trustingPeriodFraction)
return path
}
// SetupTransferPath
func SetupTransferPath(path *ibctesting.Path) error {
channelSequence := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(path.EndpointA.Chain.GetContext())
channelSequenceB := path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(path.EndpointB.Chain.GetContext())
// update port/channel ids
path.EndpointA.ChannelID = channeltypes.FormatChannelIdentifier(channelSequence)
path.EndpointB.ChannelID = channeltypes.FormatChannelIdentifier(channelSequenceB)
if err := path.EndpointA.ChanOpenInit(); err != nil {
return err
}
if err := path.EndpointB.ChanOpenTry(); err != nil {
return err
}
if err := path.EndpointA.ChanOpenAck(); err != nil {
return err
}
return path.EndpointB.ChanOpenConfirm()
}