Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): Fixes to interchaintest for ICS v6.4.0 #3472

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tests/interchain/chainsuite/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,16 @@ func (c *Chain) AddLinkedChain(ctx context.Context, testName interchaintest.Test
return chainB, nil
}

func (c *Chain) ModifyConfig(ctx context.Context, testName interchaintest.TestName, configChanges map[string]testutil.Toml) error {
func (c *Chain) ModifyConfig(ctx context.Context, testName interchaintest.TestName, configChanges map[string]testutil.Toml, validators ...int) error {
eg := errgroup.Group{}
for _, val := range c.Validators {
val := val
if len(validators) == 0 {
validators = make([]int, len(c.Validators))
for _, valIdx := range validators {
validators[valIdx] = valIdx
}
}
for _, i := range validators {
val := c.Validators[i]
eg.Go(func() error {
for file, changes := range configChanges {
if err := testutil.ModifyTomlConfigFile(
Expand Down
13 changes: 8 additions & 5 deletions tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ func (p *Chain) AddConsumerChain(ctx context.Context, relayer *Relayer, config C

defaultSpec := p.DefaultConsumerChainSpec(ctx, chainID, config, spawnTime, proposalWaiter)
config.Spec = MergeChainSpecs(defaultSpec, config.Spec)
providerICS := p.GetNode().ICSVersion(ctx)
if config.Spec.InterchainSecurityConfig.ConsumerVerOverride == "" {
// This will disable the genesis transform
config.Spec.InterchainSecurityConfig.ConsumerVerOverride = providerICS
}
if config.Spec.InterchainSecurityConfig.ICSImageRepo == "" {
config.Spec.InterchainSecurityConfig.ICSImageRepo = "ghcr.io/hyphacoop/ics"
}
// providerICS := p.GetNode().ICSVersion(ctx)
// if config.Spec.InterchainSecurityConfig.ConsumerVerOverride == "" {
// // This will disable the genesis transform
// config.Spec.InterchainSecurityConfig.ConsumerVerOverride = providerICS
// }
cf := interchaintest.NewBuiltinChainFactory(
GetLogger(ctx),
[]*interchaintest.ChainSpec{config.Spec},
Expand Down
10 changes: 4 additions & 6 deletions tests/interchain/consumer_chain/changeover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ func (s *ChangeoverSuite) SetupSuite() {
cosmos.NewGenesisKV("app_state.gov.params.min_deposit.0.amount", strconv.Itoa(chainsuite.GovMinDepositAmount)),
}
spec := &interchaintest.ChainSpec{
Name: "ics-consumer",
ChainName: "ics-consumer",
// Unfortunately, this rc is a bit of a bespoke version; it corresponds to an rc
// in hypha's fork that has a fix for sovereign -> consumer changeovers
Version: "v6.2.0-rc1",
Name: "ics-consumer",
ChainName: "ics-consumer",
Version: "v6.4.0-rc0",
NumValidators: &validators,
NumFullNodes: &fullNodes,
ChainConfig: ibc.ChainConfig{
Expand All @@ -62,7 +60,7 @@ func (s *ChangeoverSuite) SetupSuite() {
Images: []ibc.DockerImage{
{
Repository: chainsuite.HyphaICSRepo,
Version: "v6.2.0-rc1",
Version: "v6.4.0-rc0",
UidGid: chainsuite.ICSUidGuid,
},
},
Expand Down
16 changes: 8 additions & 8 deletions tests/interchain/delegator/lsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *LSMSuite) TestLSMHappyPath() {
s.Require().NoError(err)
delegatorShares2, err := s.Chain.QueryJSON(s.GetContext(), "validator.delegator_shares", "staking", "validator", providerWallet.ValoperAddress)
s.Require().NoError(err)
s.checkAMinusBEqualsX(delegatorShares2.String(), delegatorShares1.String(), sdkmath.NewInt(delegation).Mul(s.ShareFactor))
s.checkAMinusBEqualsX(delegatorShares2.String(), delegatorShares1.String(), sdkmath.NewInt(delegation))

_, err = s.Chain.GetNode().ExecTx(s.GetContext(), s.LSMWallets[lsmBondingMoniker].FormattedAddress(),
"staking", "validator-bond", providerWallet.ValoperAddress)
Expand All @@ -84,7 +84,7 @@ func (s *LSMSuite) TestLSMHappyPath() {
s.Require().NoError(err)
delegatorShares2, err := s.Chain.QueryJSON(s.GetContext(), "validator.delegator_shares", "staking", "validator", providerWallet.ValoperAddress)
s.Require().NoError(err)
s.checkAMinusBEqualsX(delegatorShares2.String(), delegatorShares1.String(), sdkmath.NewInt(delegation).Mul(s.ShareFactor))
s.checkAMinusBEqualsX(delegatorShares2.String(), delegatorShares1.String(), sdkmath.NewInt(delegation))

sharesPreTokenize, err := s.Chain.QueryJSON(s.GetContext(), "validator.liquid_shares", "staking", "validator", providerWallet.ValoperAddress)
s.Require().NoError(err)
Expand Down Expand Up @@ -201,18 +201,18 @@ func (s *LSMSuite) TestLSMHappyPath() {
happyLiquid1Delegations2Result, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("delegation_responses.#(delegation.validator_address==\"%s\").delegation.shares", providerWallet.ValoperAddress), "staking", "delegations", s.LSMWallets[lsmLiquid1Moniker].FormattedAddress())
s.Require().NoError(err)
happyLiquid1Delegations2 := happyLiquid1Delegations2Result.String()
s.checkAMinusBEqualsX(happyLiquid1Delegations2, happyLiquid1Delegations1, sdkmath.NewInt(liquid1Redeem).Mul(s.ShareFactor))
s.checkAMinusBEqualsX(happyLiquid1Delegations2, happyLiquid1Delegations1, sdkmath.NewInt(liquid1Redeem))

happyLiquid2DelegationsResult, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("delegation_responses.#(delegation.validator_address==\"%s\").delegation.shares", providerWallet.ValoperAddress), "staking", "delegations", s.LSMWallets[lsmLiquid2Moniker].FormattedAddress())
s.Require().NoError(err)
happyLiquid2Delegations := happyLiquid2DelegationsResult.String()
// LOL there are better ways of doing this
s.checkAMinusBEqualsX(happyLiquid2Delegations, "0", sdkmath.NewInt(bankSend).Mul(s.ShareFactor))
s.checkAMinusBEqualsX(happyLiquid2Delegations, "0", sdkmath.NewInt(bankSend))

happyLiquid3DelegationsResult, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("delegation_responses.#(delegation.validator_address==\"%s\").delegation.shares", providerWallet.ValoperAddress), "staking", "delegations", s.LSMWallets[lsmLiquid3Moniker].FormattedAddress())
s.Require().NoError(err)
happyLiquid3Delegations := happyLiquid3DelegationsResult.String()
s.checkAMinusBEqualsX(happyLiquid3Delegations, "0", sdkmath.NewInt(ibcTransfer).Mul(s.ShareFactor))
s.checkAMinusBEqualsX(happyLiquid3Delegations, "0", sdkmath.NewInt(ibcTransfer))

happyLiquid1DelegationBalanceResult, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("delegation_responses.#(delegation.validator_address==\"%s\").balance.amount", providerWallet.ValoperAddress), "staking", "delegations", s.LSMWallets[lsmLiquid1Moniker].FormattedAddress())
s.Require().NoError(err)
Expand Down Expand Up @@ -296,7 +296,7 @@ func (s *LSMSuite) TestICADelegate() {
s.Require().NoError(err)

exchangeRate1 := shares1Int.Quo(tokens1Int)
expectedSharesIncrease := exchangeRate1.MulRaw(bondDelegation)
expectedSharesIncrease := exchangeRate1.MulRaw(bondDelegation).Mul(s.ShareFactor)
expectedShares := expectedSharesIncrease.Add(bondShares1Int)

_, err = s.Chain.GetNode().ExecTx(s.GetContext(), bondingWallet.FormattedAddress(),
Expand Down Expand Up @@ -334,7 +334,7 @@ func (s *LSMSuite) TestICADelegate() {
preDelegationSharesInt, err := chainsuite.StrToSDKInt(preDelegationShares)
s.Require().NoError(err)
exchangeRate := preDelegationSharesInt.Quo(preDelegationTokensInt)
expectedLiquidIncrease := exchangeRate.MulRaw(delegate)
expectedLiquidIncrease := exchangeRate.MulRaw(delegate).Mul(s.ShareFactor)

delegateHappy := map[string]interface{}{
"@type": "/cosmos.staking.v1beta1.MsgDelegate",
Expand Down Expand Up @@ -376,7 +376,7 @@ func (s *LSMSuite) TestICADelegate() {
preDelegationLiquidSharesInt, err := chainsuite.StrToSDKInt(preDelegationLiquidShares)
s.Require().NoError(err)
liquidSharesDelta := postDelegationLiquidShares.Sub(preDelegationLiquidSharesInt)
s.Require().Truef(liquidSharesDelta.Sub(expectedLiquidIncrease).Abs().LTE(sdkmath.NewInt(1)), "liquidSharesDelta: %s, expectedLiquidIncrease: %d", liquidSharesDelta, expectedLiquidIncrease)
s.Require().Truef(liquidSharesDelta.Sub(expectedLiquidIncrease).Abs().LTE(sdkmath.NewInt(1)), "liquidSharesDelta: %s, expectedLiquidIncrease: %s", liquidSharesDelta, expectedLiquidIncrease)
})
}

Expand Down
2 changes: 1 addition & 1 deletion tests/interchain/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/strangelove-ventures/interchaintest/v8 => github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c
replace github.com/strangelove-ventures/interchaintest/v8 => github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20250108172813-d45809b8d949
4 changes: 2 additions & 2 deletions tests/interchain/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c h1:zTsxQIsnbocbpjqA6yEpM7nYYrqlF7EjWWFgHUEQtCE=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c/go.mod h1:/4eZW5g+Gm5E7fCJvNVyjSlEyFkAfMzap4i8E6iqyyU=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20250108172813-d45809b8d949 h1:OJzPr2P+GygGjDGKGpoTDZz8RrixD7PKXUSCoSTX09M=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20250108172813-d45809b8d949/go.mod h1:/4eZW5g+Gm5E7fCJvNVyjSlEyFkAfMzap4i8E6iqyyU=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
13 changes: 12 additions & 1 deletion tests/interchain/validator/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (s *ConfigSuite) TestNoIndexingTransactions() {
s.Require().NoError(s.Chain.ModifyConfig(
s.GetContext(), s.T(),
map[string]testutil.Toml{"config/config.toml": configToml},
0,
))

balanceBefore, err := s.Chain.GetBalance(s.GetContext(),
Expand All @@ -53,13 +54,23 @@ func (s *ConfigSuite) TestNoIndexingTransactions() {
s.Require().NoError(json.Unmarshal(stdout, &tx))
s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 2, s.Chain))

txResult, err := s.Chain.Validators[1].GetTransaction(
s.Chain.Validators[1].CliContext(),
tx.TxHash,
)
s.Require().NoError(err)
s.Require().Equal(uint32(0), txResult.Code, txResult.RawLog)

balanceAfter, err := s.Chain.GetBalance(s.GetContext(),
s.Chain.ValidatorWallets[0].Address,
s.Chain.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(balanceBefore.AddRaw(int64(amount)), balanceAfter)

_, err = s.Chain.GetTransaction(tx.TxHash)
_, err = s.Chain.Validators[0].GetTransaction(
s.Chain.Validators[0].CliContext(),
tx.TxHash,
)
s.Require().Error(err)
s.Require().Contains(err.Error(), "transaction indexing is disabled")
}
Expand Down
Loading