Skip to content

Commit

Permalink
fix interchaintests (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed May 18, 2024
1 parent e46b105 commit 082823c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package interchaintest
import (
"context"
"fmt"
"strconv"
"testing"
"time"

sdkmath "cosmossdk.io/math"
junoconformance "github.com/CosmosContracts/juno/tests/interchaintest/conformance"
helpers "github.com/CosmosContracts/juno/tests/interchaintest/helpers"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
cosmosproto "github.com/cosmos/gogoproto/proto"
"github.com/docker/docker/client"
"github.com/strangelove-ventures/interchaintest/v7"
Expand Down Expand Up @@ -94,7 +96,10 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, upgradeBranchVersion, upgra
haltHeight := height + haltHeightDelta
proposalID := SubmitUpgradeProposal(t, ctx, chain, chainUser, upgradeName, haltHeight)

ValidatorVoting(t, ctx, chain, proposalID, height, haltHeight)
proposalIDInt, err := strconv.ParseInt(proposalID, 10, 64)
require.NoError(t, err, "failed to parse proposal ID")

ValidatorVoting(t, ctx, chain, proposalIDInt, height, haltHeight)

UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeBranchVersion)

Expand Down Expand Up @@ -135,11 +140,11 @@ func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain,
require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade")
}

func ValidatorVoting(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, proposalID string, height int64, haltHeight int64) {
func ValidatorVoting(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, proposalID int64, height int64, haltHeight int64) {
err := chain.VoteOnProposalAllValidators(ctx, proposalID, cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+haltHeightDelta, proposalID, cosmos.ProposalStatusPassed)
_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+haltHeightDelta, proposalID, govtypes.StatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45)
Expand Down
4 changes: 3 additions & 1 deletion interchaintest/helpers/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"strconv"
"testing"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"

"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
)
Expand Down Expand Up @@ -39,6 +41,6 @@ func ValidatorVote(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain,
height, err := chain.Height(ctx)
require.NoError(t, err, "failed to get height")

_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+searchHeightDelta, proposalID, cosmos.ProposalStatusPassed)
_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+searchHeightDelta, proposalID, govtypes.StatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")
}
9 changes: 7 additions & 2 deletions interchaintest/module_clock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package interchaintest
import (
"context"
"fmt"
"strconv"
"testing"

sdkmath "cosmossdk.io/math"
clocktypes "github.com/CosmosContracts/juno/v22/x/clock/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
cosmosproto "github.com/cosmos/gogoproto/proto"
"github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
Expand Down Expand Up @@ -154,10 +156,13 @@ func SubmitParamChangeProp(t *testing.T, ctx context.Context, chain *cosmos.Cosm

height, _ := chain.Height(ctx)

err = chain.VoteOnProposalAllValidators(ctx, txProp.ProposalID, cosmos.ProposalVoteYes)
proposalID, err := strconv.ParseInt(txProp.ProposalID, 10, 64)
require.NoError(t, err, "failed to parse proposal ID")

err = chain.VoteOnProposalAllValidators(ctx, proposalID, cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+haltHeightDelta, txProp.ProposalID, cosmos.ProposalStatusPassed)
_, err = cosmos.PollForProposalStatus(ctx, chain, height, height+haltHeightDelta, proposalID, govtypes.StatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

return txProp.ProposalID
Expand Down

0 comments on commit 082823c

Please sign in to comment.