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 Upgrade Tests #5109

Merged
merged 5 commits into from
Nov 14, 2023
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
3 changes: 3 additions & 0 deletions e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestGrandpaTestSuite(t *testing.T) {
t.Setenv(testsuite.ChainImageEnv, wasmSimdImage)
}

// wasm tests require a longer voting period to account for the time it takes to upload a contract.
testvalues.VotingPeriod = time.Minute * 5

validateTestConfig()
testifysuite.Run(t, new(GrandpaTestSuite))
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func defaultGovv1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([]
return nil, fmt.Errorf("failed to unmarshal genesis bytes into app state: %w", err)
}

govGenBz, err := modifyGovAppState(chainConfig, appState[govtypes.ModuleName])
govGenBz, err := modifyGovV1AppState(chainConfig, appState[govtypes.ModuleName])
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -618,8 +618,8 @@ func defaultGovv1Beta1ModifyGenesis() func(ibc.ChainConfig, []byte) ([]byte, err
}
}

// modifyGovAppState takes the existing gov app state and marshals it to a govv1 GenesisState.
func modifyGovAppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byte, error) {
// modifyGovV1AppState takes the existing gov app state and marshals it to a govv1 GenesisState.
func modifyGovV1AppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byte, error) {
cfg := testutil.MakeTestEncodingConfig()

cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)
Expand Down
2 changes: 1 addition & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
// 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 = 5000000000
DefaultGasValue = 500_000_0000
)

// E2ETestSuite has methods and functionality which can be shared among all test suites.
Expand Down
23 changes: 16 additions & 7 deletions e2e/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import (
"strings"
"time"

sdkmath "cosmossdk.io/math"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
test "github.com/strangelove-ventures/interchaintest/v8/testutil"

errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -160,7 +159,7 @@ func (s *E2ETestSuite) ExecuteGovV1Proposal(ctx context.Context, msg sdk.Msg, ch

msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(
msgs,
sdk.NewCoins(sdk.NewCoin(cosmosChain.Config().Denom, sdkmath.NewInt(testvalues.DefaultProposalTokenAmount))),
sdk.NewCoins(sdk.NewCoin(cosmosChain.Config().Denom, sdkmath.NewInt(testvalues.DefaultGovV1ProposalTokenAmount))),
sender.String(),
"",
fmt.Sprintf("e2e gov proposal: %d", proposalID),
Expand Down Expand Up @@ -230,11 +229,21 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha
s.Require().NoError(err)
s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposal.Status)

time.Sleep(testvalues.VotingPeriod) // pass proposal

proposal, err = s.QueryProposalV1Beta1(ctx, cosmosChain, proposalID)
err = s.waitForGovV1Beta1ProposalToPass(ctx, cosmosChain, proposalID)
s.Require().NoError(err)
s.Require().Equal(govtypesv1beta1.StatusPassed, proposal.Status)
}

// waitForGovV1Beta1ProposalToPass polls for the entire voting period to see if the proposal has passed.
// if the proposal has not passed within the duration of the voting period, an error is returned.
func (s *E2ETestSuite) waitForGovV1Beta1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error {
// poll for the query for the entire voting period to see if the proposal has passed.
return test.WaitForCondition(testvalues.VotingPeriod, 10*time.Second, func() (bool, error) {
proposal, err := s.QueryProposalV1Beta1(ctx, chain, proposalID)
if err != nil {
return false, err
}
return proposal.Status == govtypesv1beta1.StatusPassed, nil
})
}

// ExecuteGovV1Beta1Proposal submits a v1beta1 governance proposal using the provided content.
Expand Down
14 changes: 9 additions & 5 deletions e2e/testvalues/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ import (
)

const (
StartingTokenAmount int64 = 500_000_000_000
IBCTransferAmount int64 = 10_000
InvalidAddress string = "<invalid-address>"
VotingPeriod time.Duration = time.Minute * 5
DefaultProposalTokenAmount = 500000000
StartingTokenAmount int64 = 500_000_000_000
IBCTransferAmount int64 = 10_000
InvalidAddress string = "<invalid-address>"
DefaultGovV1ProposalTokenAmount = 500_000_000
)

var (
// VotingPeriod may differ per test.
VotingPeriod = time.Second * 30
)

// ImmediatelyTimeout returns an ibc.IBCTimeout which will cause an IBC transfer to timeout immediately.
Expand Down
Loading