Skip to content

Commit

Permalink
WIP test for consumer proposal migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfadingviolets committed Aug 29, 2024
1 parent 6bc91fd commit 5af7aa0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/interchain/chainsuite/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func (c *Chain) WaitForProposalStatus(ctx context.Context, proposalID string, st
if err != nil {
return err
}
maxHeight := chainHeight + UpgradeDelta
// At 4s per block, 250 blocks is about 20 minutes.
maxHeight := chainHeight + 250
_, err = cosmos.PollForProposalStatusV1(ctx, c.CosmosChain, chainHeight, maxHeight, uint64(propID), status)
return err
}
Expand Down
8 changes: 4 additions & 4 deletions tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,25 +438,25 @@ func (p *Chain) SubmitConsumerAdditionProposal(ctx context.Context, chainID stri
defer close(errCh)
if err := p.WaitForProposalStatus(ctx, propTx.ProposalID, govv1.StatusDepositPeriod); err != nil {
errCh <- err
return
panic(err)
}
propWaiter.waitForDepositAllowed()

if _, err := p.GetNode().ExecTx(ctx, interchaintest.FaucetAccountKeyName, "gov", "deposit", propTx.ProposalID, prop.Deposit); err != nil {
errCh <- err
return
panic(err)
}

if err := p.WaitForProposalStatus(ctx, propTx.ProposalID, govv1.StatusVotingPeriod); err != nil {
errCh <- err
return
panic(err)
}
propWaiter.startVotingPeriod()
propWaiter.waitForVoteAllowed()

if err := p.PassProposal(ctx, propTx.ProposalID); err != nil {
errCh <- err
return
panic(err)
}
propWaiter.pass()
}()
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.20240827183230-b4c212b9721e
replace github.com/strangelove-ventures/interchaintest/v8 => github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240828194359-d54b58b07d5a
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.20240827183230-b4c212b9721e h1:oK1cjf88bKBx/l+4BLtWX2nNBeWYBWQDpe4ZR1L3tWE=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240827183230-b4c212b9721e/go.mod h1:mpI1s9X2V0NK3JmPEpQUU+5AWM/iv/hTcixpSAlM3ZE=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240828194359-d54b58b07d5a h1:p+eXxh5GFTn4lfJor0c0My05yy6l7cAKO8KywVWGeq0=
github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240828194359-d54b58b07d5a/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
91 changes: 91 additions & 0 deletions tests/interchain/permissionless_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package interchain_test

import (
"context"
"fmt"
"testing"
"time"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/gaia/v20/tests/interchain/chainsuite"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/stretchr/testify/suite"
)

const (
permissionlessDepositPeriod = 10 * time.Minute
)

type PermissionlessSuite struct {
*chainsuite.Suite
}

func (s *PermissionlessSuite) TestConsumerAdditionMigration() {
cfg := chainsuite.ConsumerConfig{
ChainName: "ics-consumer",
Version: "v5.0.0",
ShouldCopyProviderKey: allProviderKeysCopied(),
Denom: chainsuite.Ucon,
TopN: 100,
AllowInactiveVals: true,
MinStake: 1_000_000,
}
consumer, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg)
s.Require().NoError(err)
err = s.Chain.CheckCCV(s.GetContext(), consumer, s.Relayer, 1_000_000, 0, 1)
s.Require().NoError(err)

proposals, err := s.Chain.GovQueryProposalsV1(s.GetContext(), govtypes.ProposalStatus_PROPOSAL_STATUS_PASSED)
s.Require().NoError(err)
s.Require().Len(proposals, 1)
oldProposalCh1 := proposals[0]

cfg.DuringDepositPeriod = func(ctx context.Context, consumer *cosmos.CosmosChain) {
time.Sleep(permissionlessDepositPeriod - 1*time.Minute)
}

chainIDCh2 := cfg.ChainName + "-2"
propWaiter, errCh, err := s.Chain.SubmitConsumerAdditionProposal(s.GetContext(), chainIDCh2, cfg, time.Now().Add(permissionlessDepositPeriod+2*time.Minute))
s.Require().NoError(err)
propWaiter.AllowDeposit()

s.UpgradeChain()

// check that the new is around
chain, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("chains.#(chain_id=%q)", chainIDCh2), "provider", "list-consumer-chains")
s.Require().NoError(err)
s.Require().True(chain.Exists())

proposals, err = s.Chain.GovQueryProposalsV1(s.GetContext(), govtypes.ProposalStatus_PROPOSAL_STATUS_PASSED)
s.Require().NoError(err)
s.Require().Len(proposals, 2)
newProposalCh1 := proposals[0]
s.Require().Equal(oldProposalCh1, newProposalCh1)

propWaiter.WaitForVotingPeriod()
propWaiter.AllowVote()
propWaiter.WaitForPassed()
s.Require().NoError(<-errCh)

}

func TestPermissionlessLaunches(t *testing.T) {
genesis := chainsuite.DefaultGenesis()
genesis = append(genesis,
cosmos.NewGenesisKV("app_state.gov.params.max_deposit_period", permissionlessDepositPeriod.String()),
)
s := &UnbondingSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
ChainConfig: ibc.ChainConfig{
ModifyGenesis: cosmos.ModifyGenesis(genesis),
},
},
}),
}
suite.Run(t, s)

}

0 comments on commit 5af7aa0

Please sign in to comment.