/
testsuite.go
531 lines (437 loc) · 21.1 KB
/
testsuite.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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
package testsuite
import (
"context"
"errors"
"fmt"
"os"
"path"
"strings"
dockerclient "github.com/docker/docker/client"
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
test "github.com/strangelove-ventures/interchaintest/v8/testutil"
testifysuite "github.com/stretchr/testify/suite"
"go.uber.org/zap"
sdkmath "cosmossdk.io/math"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/ibc-go/e2e/internal/directories"
"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/testsuite/diagnostics"
"github.com/cosmos/ibc-go/e2e/testsuite/query"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
const (
// ChainARelayerName is the name given to the relayer wallet on ChainA
ChainARelayerName = "rlyA"
// ChainBRelayerName is the name given to the relayer wallet on ChainB
ChainBRelayerName = "rlyB"
// DefaultGasValue is the default gas value used to configure tx.Factory
DefaultGasValue = 500_000_0000
)
// E2ETestSuite has methods and functionality which can be shared among all test suites.
type E2ETestSuite struct {
testifysuite.Suite
// proposalIDs keeps track of the active proposal ID for each chain.
proposalIDs map[string]uint64
paths map[string]pathPair
relayers relayer.Map
logger *zap.Logger
DockerClient *dockerclient.Client
network string
startRelayerFn func(relayer ibc.Relayer)
// pathNameIndex is the latest index to be used for generating paths
pathNameIndex int64
}
// pathPair is a pairing of two chains which will be used in a test.
type pathPair struct {
chainA, chainB ibc.Chain
}
// newPath returns a path built from the given chains.
func newPath(chainA, chainB ibc.Chain) pathPair {
return pathPair{
chainA: chainA,
chainB: chainB,
}
}
func (s *E2ETestSuite) SetupTest() {
s.configureGenesisDebugExport()
}
// configureGenesisDebugExport sets, if needed, env variables to enable exporting of Genesis debug files.
func (s *E2ETestSuite) configureGenesisDebugExport() {
tc := LoadConfig()
t := s.T()
cfg := tc.DebugConfig.GenesisDebug
if !cfg.DumpGenesisDebugInfo {
return
}
// Set the export path.
exportPath := cfg.ExportFilePath
// If no path is provided, use the default (e2e/diagnostics/genesis.json).
if exportPath == "" {
e2eDir, err := directories.E2E(t)
s.Require().NoError(err, "can't get e2edir")
exportPath = path.Join(e2eDir, directories.DefaultGenesisExportPath)
}
if !path.IsAbs(exportPath) {
wd, err := os.Getwd()
s.Require().NoError(err, "can't get working directory")
exportPath = path.Join(wd, exportPath)
}
// This env variables are set by the interchain test code:
// https://github.com/strangelove-ventures/interchaintest/blob/7aa0fd6487f76238ab44231fdaebc34627bc5990/chain/cosmos/cosmos_chain.go#L1007-L1008
t.Setenv("EXPORT_GENESIS_FILE_PATH", exportPath)
chainName := tc.GetGenesisChainName()
chainIdx, err := tc.GetChainIndex(chainName)
s.Require().NoError(err)
// Interchaintest adds a suffix (https://github.com/strangelove-ventures/interchaintest/blob/a3f4c7bcccf1925ffa6dc793a298f15497919a38/chainspec.go#L125)
// to the chain name, so we need to do the same.
genesisChainName := fmt.Sprintf("%s-%d", chainName, chainIdx+1)
t.Setenv("EXPORT_GENESIS_CHAIN", genesisChainName)
}
// GetRelayerUsers returns two ibc.Wallet instances which can be used for the relayer users
// on the two chains.
func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...ChainOptionConfiguration) (ibc.Wallet, ibc.Wallet) {
chainA, chainB := s.GetChains(chainOpts...)
chainAAccountBytes, err := chainA.GetAddress(ctx, ChainARelayerName)
s.Require().NoError(err)
chainBAccountBytes, err := chainB.GetAddress(ctx, ChainBRelayerName)
s.Require().NoError(err)
chainARelayerUser := cosmos.NewWallet(ChainARelayerName, chainAAccountBytes, "", chainA.Config())
chainBRelayerUser := cosmos.NewWallet(ChainBRelayerName, chainBAccountBytes, "", chainB.Config())
if s.relayers == nil {
s.relayers = make(relayer.Map)
}
s.relayers.AddRelayer(s.T().Name(), chainARelayerUser)
s.relayers.AddRelayer(s.T().Name(), chainBRelayerUser)
return chainARelayerUser, chainBRelayerUser
}
// SetupChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel
// using the given channel options. The relayer returned by this function has not yet started. It should be started
// with E2ETestSuite.StartRelayer if needed.
// This should be called at the start of every test, unless fine grained control is required.
func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts func(*ibc.CreateChannelOptions), chainSpecOpts ...ChainOptionConfiguration) (ibc.Relayer, ibc.ChannelOutput) {
chainA, chainB := s.GetChains(chainSpecOpts...)
r := s.ConfigureRelayer(ctx, chainA, chainB, channelOpts)
chainAChannels, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
s.Require().NoError(err)
return r, chainAChannels[len(chainAChannels)-1]
}
func (s *E2ETestSuite) ConfigureRelayer(ctx context.Context, chainA, chainB ibc.Chain, channelOpts func(*ibc.CreateChannelOptions), buildOptions ...func(options *interchaintest.InterchainBuildOptions)) ibc.Relayer {
r := relayer.New(s.T(), *LoadConfig().GetActiveRelayerConfig(), s.logger, s.DockerClient, s.network)
pathName := s.generatePathName()
channelOptions := ibc.DefaultChannelOpts()
if channelOpts != nil {
channelOpts(&channelOptions)
}
ic := interchaintest.NewInterchain().
AddChain(chainA).
AddChain(chainB).
AddRelayer(r, "r").
AddLink(interchaintest.InterchainLink{
Chain1: chainA,
Chain2: chainB,
Relayer: r,
Path: pathName,
CreateChannelOpts: channelOptions,
})
buildOpts := interchaintest.InterchainBuildOptions{
TestName: s.T().Name(),
Client: s.DockerClient,
NetworkID: s.network,
}
for _, opt := range buildOptions {
opt(&buildOpts)
}
eRep := s.GetRelayerExecReporter()
s.Require().NoError(ic.Build(ctx, eRep, buildOpts))
s.startRelayerFn = func(relayer ibc.Relayer) {
err := relayer.StartRelayer(ctx, eRep, pathName)
s.Require().NoError(err, fmt.Sprintf("failed to start relayer: %s", err))
// wait for relayer to start.
s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks")
}
return r
}
// SetupSingleChain creates and returns a single CosmosChain for usage in e2e tests.
// This is useful for testing single chain functionality when performing coordinated upgrades as well as testing localhost ibc client functionality.
// TODO: Actually setup a single chain. Seeing panic: runtime error: index out of range [0] with length 0 when using a single chain.
// issue: https://github.com/strangelove-ventures/interchaintest/issues/401
func (s *E2ETestSuite) SetupSingleChain(ctx context.Context) ibc.Chain {
chainA, chainB := s.GetChains()
ic := interchaintest.NewInterchain().AddChain(chainA).AddChain(chainB)
eRep := s.GetRelayerExecReporter()
s.Require().NoError(ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{
TestName: s.T().Name(),
Client: s.DockerClient,
NetworkID: s.network,
SkipPathCreation: true,
}))
return chainA
}
// generatePathName generates the path name using the test suites name
func (s *E2ETestSuite) generatePathName() string {
pathName := s.GetPathName(s.pathNameIndex)
s.pathNameIndex++
return pathName
}
// GetPathName returns the name of a path at a specific index. This can be used in tests
// when the path name is required.
func (s *E2ETestSuite) GetPathName(idx int64) string {
pathName := fmt.Sprintf("%s-path-%d", s.T().Name(), idx)
return strings.ReplaceAll(pathName, "/", "-")
}
// generatePath generates the path name using the test suites name
func (s *E2ETestSuite) generatePath(ctx context.Context, ibcrelayer ibc.Relayer) string {
chainA, chainB := s.GetChains()
chainAID := chainA.Config().ChainID
chainBID := chainB.Config().ChainID
pathName := s.generatePathName()
err := ibcrelayer.GeneratePath(ctx, s.GetRelayerExecReporter(), chainAID, chainBID, pathName)
s.Require().NoError(err)
return pathName
}
// SetupClients creates clients on chainA and chainB using the provided create client options
func (s *E2ETestSuite) SetupClients(ctx context.Context, ibcrelayer ibc.Relayer, opts ibc.CreateClientOptions) {
pathName := s.generatePath(ctx, ibcrelayer)
err := ibcrelayer.CreateClients(ctx, s.GetRelayerExecReporter(), pathName, opts)
s.Require().NoError(err)
}
// UpdateClients updates clients on chainA and chainB
func (s *E2ETestSuite) UpdateClients(ctx context.Context, ibcrelayer ibc.Relayer, pathName string) {
err := ibcrelayer.UpdateClients(ctx, s.GetRelayerExecReporter(), pathName)
s.Require().NoError(err)
}
// GetChains returns two chains that can be used in a test. The pair returned
// is unique to the current test being run. Note: this function does not create containers.
func (s *E2ETestSuite) GetChains(chainOpts ...ChainOptionConfiguration) (ibc.Chain, ibc.Chain) {
if s.paths == nil {
s.paths = map[string]pathPair{}
}
suitePath, ok := s.paths[s.T().Name()]
if ok {
return suitePath.chainA, suitePath.chainB
}
chainOptions := DefaultChainOptions()
for _, opt := range chainOpts {
opt(&chainOptions)
}
chainA, chainB := s.createChains(chainOptions)
suitePath = newPath(chainA, chainB)
s.paths[s.T().Name()] = suitePath
if s.proposalIDs == nil {
s.proposalIDs = map[string]uint64{}
}
s.proposalIDs[chainA.Config().ChainID] = 1
s.proposalIDs[chainB.Config().ChainID] = 1
return suitePath.chainA, suitePath.chainB
}
// GetRelayerWallets returns the ibcrelayer wallets associated with the chains.
func (s *E2ETestSuite) GetRelayerWallets(ibcrelayer ibc.Relayer) (ibc.Wallet, ibc.Wallet, error) {
chainA, chainB := s.GetChains()
chainARelayerWallet, ok := ibcrelayer.GetWallet(chainA.Config().ChainID)
if !ok {
return nil, nil, fmt.Errorf("unable to find chain A relayer wallet")
}
chainBRelayerWallet, ok := ibcrelayer.GetWallet(chainB.Config().ChainID)
if !ok {
return nil, nil, fmt.Errorf("unable to find chain B relayer wallet")
}
return chainARelayerWallet, chainBRelayerWallet, nil
}
// RecoverRelayerWallets adds the corresponding ibcrelayer address to the keychain of the chain.
// This is useful if commands executed on the chains expect the relayer information to present in the keychain.
func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc.Relayer) error {
chainARelayerWallet, chainBRelayerWallet, err := s.GetRelayerWallets(ibcrelayer)
if err != nil {
return err
}
chainA, chainB := s.GetChains()
if err := chainA.RecoverKey(ctx, ChainARelayerName, chainARelayerWallet.Mnemonic()); err != nil {
return fmt.Errorf("could not recover relayer wallet on chain A: %s", err)
}
if err := chainB.RecoverKey(ctx, ChainBRelayerName, chainBRelayerWallet.Mnemonic()); err != nil {
return fmt.Errorf("could not recover relayer wallet on chain B: %s", err)
}
return nil
}
// StartRelayer starts the given ibcrelayer.
func (s *E2ETestSuite) StartRelayer(ibcrelayer ibc.Relayer) {
if s.startRelayerFn == nil {
panic(errors.New("cannot start relayer before it is created"))
}
s.startRelayerFn(ibcrelayer)
}
// StopRelayer stops the given ibcrelayer.
func (s *E2ETestSuite) StopRelayer(ctx context.Context, ibcrelayer ibc.Relayer) {
err := ibcrelayer.StopRelayer(ctx, s.GetRelayerExecReporter())
s.Require().NoError(err)
}
// RestartRelayer restarts the given relayer.
func (s *E2ETestSuite) RestartRelayer(ctx context.Context, ibcrelayer ibc.Relayer) {
s.StopRelayer(ctx, ibcrelayer)
s.StartRelayer(ibcrelayer)
}
// CreateUserOnChainA creates a user with the given amount of funds on chain A.
func (s *E2ETestSuite) CreateUserOnChainA(ctx context.Context, amount int64) ibc.Wallet {
chainA, _ := s.GetChains()
return interchaintest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), sdkmath.NewInt(amount), chainA)[0]
}
// CreateUserOnChainB creates a user with the given amount of funds on chain B.
func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) ibc.Wallet {
_, chainB := s.GetChains()
return interchaintest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), sdkmath.NewInt(amount), chainB)[0]
}
// GetChainANativeBalance gets the balance of a given user on chain A.
func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) {
chainA, _ := s.GetChains()
balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainA, &banktypes.QueryBalanceRequest{
Address: user.FormattedAddress(),
Denom: chainA.Config().Denom,
})
if err != nil {
return 0, err
}
return balanceResp.Balance.Amount.Int64(), nil
}
// GetChainBNativeBalance gets the balance of a given user on chain B.
func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) {
_, chainB := s.GetChains()
balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainB, &banktypes.QueryBalanceRequest{
Address: user.FormattedAddress(),
Denom: chainB.Config().Denom,
})
if err != nil {
return 0, err
}
return balanceResp.Balance.Amount.Int64(), nil
}
// AssertPacketRelayed asserts that the packet commitment does not exist on the sending chain.
// The packet commitment will be deleted upon a packet acknowledgement or timeout.
func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64) {
_, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{
PortId: portID,
ChannelId: channelID,
Sequence: sequence,
})
s.Require().ErrorContains(err, "packet commitment hash not found")
}
// AssertHumanReadableDenom asserts that a human readable denom is present for a given chain.
func (s *E2ETestSuite) AssertHumanReadableDenom(ctx context.Context, chain ibc.Chain, counterpartyNativeDenom string, counterpartyChannel ibc.ChannelOutput) {
chainIBCDenom := GetIBCToken(counterpartyNativeDenom, counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID)
denomMetadataResp, err := query.GRPCQuery[banktypes.QueryDenomMetadataResponse](ctx, chain, &banktypes.QueryDenomMetadataRequest{
Denom: chainIBCDenom.IBCDenom(),
})
s.Require().NoError(err)
denomMetadata := denomMetadataResp.Metadata
s.Require().Equal(chainIBCDenom.IBCDenom(), denomMetadata.Base, "denom metadata base does not match expected %s: got %s", chainIBCDenom.IBCDenom(), denomMetadata.Base)
expectedName := fmt.Sprintf("%s/%s/%s IBC token", counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID, counterpartyNativeDenom)
s.Require().Equal(expectedName, denomMetadata.Name, "denom metadata name does not match expected %s: got %s", expectedName, denomMetadata.Name)
expectedDisplay := fmt.Sprintf("%s/%s/%s", counterpartyChannel.Counterparty.PortID, counterpartyChannel.Counterparty.ChannelID, counterpartyNativeDenom)
s.Require().Equal(expectedDisplay, denomMetadata.Display, "denom metadata display does not match expected %s: got %s", expectedDisplay, denomMetadata.Display)
s.Require().Equal(strings.ToUpper(counterpartyNativeDenom), denomMetadata.Symbol, "denom metadata symbol does not match expected %s: got %s", strings.ToUpper(counterpartyNativeDenom), denomMetadata.Symbol)
}
// createChains creates two separate chains in docker containers.
// test and can be retrieved with GetChains.
func (s *E2ETestSuite) createChains(chainOptions ChainOptions) (ibc.Chain, ibc.Chain) {
client, network := interchaintest.DockerSetup(s.T())
t := s.T()
s.logger = zap.NewExample()
s.DockerClient = client
s.network = network
cf := interchaintest.NewBuiltinChainFactory(s.logger, []*interchaintest.ChainSpec{chainOptions.ChainASpec, chainOptions.ChainBSpec})
// this is intentionally called after the interchaintest.DockerSetup function. The above function registers a
// cleanup task which deletes all containers. By registering a cleanup function afterwards, it is executed first
// this allows us to process the logs before the containers are removed.
t.Cleanup(func() {
dumpLogs := LoadConfig().DebugConfig.DumpLogs
chains := []string{chainOptions.ChainASpec.ChainConfig.Name, chainOptions.ChainBSpec.ChainConfig.Name}
diagnostics.Collect(t, s.DockerClient, dumpLogs, chains...)
})
chains, err := cf.Chains(t.Name())
s.Require().NoError(err)
return chains[0], chains[1]
}
// GetRelayerExecReporter returns a testreporter.RelayerExecReporter instances
// using the current test's testing.T.
func (s *E2ETestSuite) GetRelayerExecReporter() *testreporter.RelayerExecReporter {
rep := testreporter.NewNopReporter()
return rep.RelayerExecReporter(s.T())
}
// TransferChannelOptions configures both of the chains to have non-incentivized transfer channels.
func (*E2ETestSuite) TransferChannelOptions() func(options *ibc.CreateChannelOptions) {
return func(opts *ibc.CreateChannelOptions) {
opts.Version = transfertypes.Version
opts.SourcePortName = transfertypes.PortID
opts.DestPortName = transfertypes.PortID
}
}
// FeeMiddlewareChannelOptions configures both of the chains to have fee middleware enabled.
func (s *E2ETestSuite) FeeMiddlewareChannelOptions() func(options *ibc.CreateChannelOptions) {
versionMetadata := feetypes.Metadata{
FeeVersion: feetypes.Version,
AppVersion: transfertypes.Version,
}
versionBytes, err := feetypes.ModuleCdc.MarshalJSON(&versionMetadata)
s.Require().NoError(err)
return func(opts *ibc.CreateChannelOptions) {
opts.Version = string(versionBytes)
opts.DestPortName = transfertypes.PortID
opts.SourcePortName = transfertypes.PortID
}
}
// GetTimeoutHeight returns a timeout height of 1000 blocks above the current block height.
// This function should be used when the timeout is never expected to be reached
func (s *E2ETestSuite) GetTimeoutHeight(ctx context.Context, chain ibc.Chain) clienttypes.Height {
height, err := chain.Height(ctx)
s.Require().NoError(err)
return clienttypes.NewHeight(clienttypes.ParseChainID(chain.Config().ChainID), uint64(height)+1000)
}
// CreateUpgradeFields creates upgrade fields for channel with fee middleware
func (s *E2ETestSuite) CreateUpgradeFields(channel channeltypes.Channel) channeltypes.UpgradeFields {
versionMetadata := feetypes.Metadata{
FeeVersion: feetypes.Version,
AppVersion: channel.Version,
}
versionBytes, err := feetypes.ModuleCdc.MarshalJSON(&versionMetadata)
s.Require().NoError(err)
return channeltypes.NewUpgradeFields(channel.Ordering, channel.ConnectionHops, string(versionBytes))
}
// SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s
func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet) {
const timeoutDelta = 1000000000 // use 1 second as relative timeout to force upgrade timeout on the counterparty
govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain)
s.Require().NoError(err)
s.Require().NotNil(govModuleAddress)
upgradeTimeout := channeltypes.NewTimeout(channeltypes.DefaultTimeout.Height, timeoutDelta)
msg := channeltypes.NewMsgUpdateChannelParams(govModuleAddress.String(), channeltypes.NewParams(upgradeTimeout))
s.ExecuteAndPassGovV1Proposal(ctx, msg, chain, wallet)
}
// InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade
func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields) {
govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain)
s.Require().NoError(err)
s.Require().NotNil(govModuleAddress)
msg := channeltypes.NewMsgChannelUpgradeInit(portID, channelID, upgradeFields, govModuleAddress.String())
s.ExecuteAndPassGovV1Proposal(ctx, msg, chain, wallet)
}
// GetIBCToken returns the denomination of the full token denom sent to the receiving channel
func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes.DenomTrace {
return transfertypes.ParseDenomTrace(fmt.Sprintf("%s/%s/%s", portID, channelID, fullTokenDenom))
}
// getValidatorsAndFullNodes returns the number of validators and full nodes respectively that should be used for
// the test. If the test is running in CI, more nodes are used, when running locally a single node is used by default to
// use less resources and allow the tests to run faster.
// both the number of validators and full nodes can be overwritten in a config file.
func getValidatorsAndFullNodes(chainIdx int) (int, int) {
if IsCI() {
return 4, 1
}
tc := LoadConfig()
return tc.GetChainNumValidators(chainIdx), tc.GetChainNumFullNodes(chainIdx)
}