From 1913c800c1a763c671a172ea8e7c4db2b85c0d77 Mon Sep 17 00:00:00 2001 From: violet Date: Tue, 7 Jan 2025 10:22:39 -0500 Subject: [PATCH 1/3] fix(ci): Fix the LSM test for v22. Some versions of gaia differ in how they report shares vs tokens staked, and that can produce discrepancies in tests. This updates us for a v22 chain, with potential ICAs in v21 chains --- tests/interchain/delegator/lsm_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/interchain/delegator/lsm_test.go b/tests/interchain/delegator/lsm_test.go index 4f05e8fbad..f26e8d5ba7 100644 --- a/tests/interchain/delegator/lsm_test.go +++ b/tests/interchain/delegator/lsm_test.go @@ -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) @@ -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) @@ -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) @@ -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(), @@ -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", @@ -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) }) } From 1df2b2c9bf7f02373fdf3fef3189ce8c5b0f4e47 Mon Sep 17 00:00:00 2001 From: violet Date: Wed, 8 Jan 2025 11:29:21 -0500 Subject: [PATCH 2/3] fix(ci): interchaintest: get the right genesis transform for consumer chains --- tests/interchain/chainsuite/chain_ics.go | 13 ++++++++----- tests/interchain/consumer_chain/changeover_test.go | 10 ++++------ tests/interchain/go.mod | 2 +- tests/interchain/go.sum | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/interchain/chainsuite/chain_ics.go b/tests/interchain/chainsuite/chain_ics.go index 13b161ef2d..b99c0c4f25 100644 --- a/tests/interchain/chainsuite/chain_ics.go +++ b/tests/interchain/chainsuite/chain_ics.go @@ -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}, diff --git a/tests/interchain/consumer_chain/changeover_test.go b/tests/interchain/consumer_chain/changeover_test.go index 219af6ae65..e14c96a25d 100644 --- a/tests/interchain/consumer_chain/changeover_test.go +++ b/tests/interchain/consumer_chain/changeover_test.go @@ -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{ @@ -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, }, }, diff --git a/tests/interchain/go.mod b/tests/interchain/go.mod index 783e85b62d..3b78c3cbe5 100644 --- a/tests/interchain/go.mod +++ b/tests/interchain/go.mod @@ -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 diff --git a/tests/interchain/go.sum b/tests/interchain/go.sum index 712971939f..373aafaeb5 100644 --- a/tests/interchain/go.sum +++ b/tests/interchain/go.sum @@ -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= From 53f7ecc9c827da808f3b0322ef253daf74acfb0b Mon Sep 17 00:00:00 2001 From: violet Date: Thu, 9 Jan 2025 09:58:31 -0500 Subject: [PATCH 3/3] fix(ci): add an error check to the config test suite --- tests/interchain/chainsuite/chain.go | 12 +++++++++--- tests/interchain/validator/config_test.go | 13 ++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/interchain/chainsuite/chain.go b/tests/interchain/chainsuite/chain.go index 81a831cf37..c67d317453 100644 --- a/tests/interchain/chainsuite/chain.go +++ b/tests/interchain/chainsuite/chain.go @@ -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( diff --git a/tests/interchain/validator/config_test.go b/tests/interchain/validator/config_test.go index 7f731502e8..01f671fd1c 100644 --- a/tests/interchain/validator/config_test.go +++ b/tests/interchain/validator/config_test.go @@ -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(), @@ -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") }