Skip to content

Commit

Permalink
test: Refactor gov e2e for v0.45 Rho (#1951)
Browse files Browse the repository at this point in the history
* WIP

* Refactor gov tests for v45

* Refactor gov and add community spend test

* Refactor

* Set explicit sdk & tm versions for all dependencies

Co-authored-by: billy rennekamp <billy.rennekamp@gmail.com>

* Skip broken redirect link check

* Restrict disable link to single link

Co-authored-by: billy rennekamp <billy.rennekamp@gmail.com>
  • Loading branch information
glnro and okwme authored Dec 12, 2022
1 parent 420f7a0 commit be2b14f
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 485 deletions.
2 changes: 2 additions & 0 deletions docs/governance/proposal-types/params-change/Auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ There is an option to include a "memo," or additional information (data) to Cosm
Decreasing the value of `MaxMemoCharacters` will decrease the character limit for each transaction memo. This may break the functionality of applications that rely upon the data in the memo field. For example, an exchange may use a common deposit address for all of its users, and then individualize account deposits using the memo field. If the memo field suddenly decreased, the exchange may no longer automatically sort its users' transactions.

#### Increasing the value of `MaxMemoCharacters`
<!-- markdown-link-check-disable -->
Increasing the value of `MaxMemoCharacters` will increase the character limit for each transaction memo. This may enable new functionality for applications that use transaction memos. It may also enable an increase in the amount of data in each block, leading to an increased storage need for the blockchain and [state bloat](https://thecontrol.co/state-growth-a-look-at-the-problem-and-its-solutions-6de9d7634b0b).
<!-- markdown-link-check-enable -->

### `TxSigLimit`
**The max number of signatures per transaction**
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ replace (

// force all dependecies to use the same versions of ibc, tendermint and cosmos-sdk
github.com/cosmos/ibc-go/v3 => github.com/cosmos/ibc-go/v3 v3.4.0
github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.11

// use cosmos style protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24

// latest grpc doesn't work with with our modified proto compiler, so we need to enforce
// the following version across all dependencies.
Expand Down
34 changes: 34 additions & 0 deletions tests/e2e/e2e_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,37 @@ func (s *IntegrationTestSuite) testDistribution() {
5*time.Second,
)
}

/*
fundCommunityPool tests the funding of the community pool on behalf of the distribution module.
Test Benchmarks:
1. Validation that balance of the distribution module account before funding
2. Execution funding the community pool
3. Verification that correct funds have been deposited to distribution module account
*/
func (s *IntegrationTestSuite) fundCommunityPool() {
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
sender := s.chainA.validators[0].keyInfo.GetAddress()

beforeDistUatomBalance, _ := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom)
if beforeDistUatomBalance.IsNil() {
// Set balance to 0 if previous balance does not exist
beforeDistUatomBalance = sdk.NewInt64Coin(uatomDenom, 0)
}

s.execDistributionFundCommunityPool(s.chainA, 0, sender.String(), tokenAmount.String(), standardFees.String())

// there are still tokens being added to the community pool through block production rewards but they should be less than 500 tokens
marginOfErrorForBlockReward := sdk.NewInt64Coin(uatomDenom, 500)

s.Require().Eventually(
func() bool {
afterDistPhotonBalance, err := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom)
s.Require().NoErrorf(err, "Error getting balance: %s", afterDistPhotonBalance)

return afterDistPhotonBalance.Sub(beforeDistUatomBalance.Add(tokenAmount.Add(standardFees))).IsLT(marginOfErrorForBlockReward)
},
15*time.Second,
5*time.Second,
)
}
109 changes: 6 additions & 103 deletions tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,69 +364,18 @@ func (s *IntegrationTestSuite) execDistributionFundCommunityPool(c *chain, valId
s.T().Logf("Successfully funded community pool")
}

func (s *IntegrationTestSuite) execGovSubmitLegacyGovProposal(c *chain, valIdx int, submitterAddr, govProposalPath, fees, govProposalSubType string) {
func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, govCommand string, proposalFlags []string, fees string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("Executing gaiad tx gov submit-proposal on chain %s", c.id)

gaiaCommand := []string{
gaiadBinary,
txCommand,
govtypes.ModuleName,
"submit-proposal",
govProposalSubType,
govProposalPath,
fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
"--keyring-backend=test",
"--output=json",
"-y",
}

s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully submitted legacy proposal")
}

func (s *IntegrationTestSuite) execGovDepositProposal(c *chain, valIdx int, submitterAddr string, proposalId int, amount, fees string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("Executing gaiad tx gov deposit on chain %s", c.id)

gaiaCommand := []string{
gaiadBinary,
txCommand,
govtypes.ModuleName,
"deposit",
fmt.Sprintf("%d", proposalId),
amount,
fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
"--keyring-backend=test",
"--output=json",
"-y",
govCommand,
}

s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully deposited proposal %d", proposalId)
}

func (s *IntegrationTestSuite) execGovVoteProposal(c *chain, valIdx int, submitterAddr string, proposalId int, vote, fees string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("Executing gaiad tx gov vote on chain %s", c.id)

gaiaCommand := []string{
gaiadBinary,
txCommand,
govtypes.ModuleName,
"vote",
fmt.Sprintf("%d", proposalId),
vote,
generalFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
Expand All @@ -435,57 +384,11 @@ func (s *IntegrationTestSuite) execGovVoteProposal(c *chain, valIdx int, submitt
"-y",
}

s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully voted on proposal %d", proposalId)
}

func (s *IntegrationTestSuite) execGovWeightedVoteProposal(c *chain, valIdx int, submitterAddr string, proposalId int, vote, fees string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("Executing gaiad tx gov vote on chain %s", c.id)

gaiaCommand := []string{
gaiadBinary,
txCommand,
govtypes.ModuleName,
"weighted-vote",
fmt.Sprintf("%d", proposalId),
vote,
fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
"--keyring-backend=test",
"--output=json",
"-y",
}

s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully voted on proposal %d", proposalId)
}

func (s *IntegrationTestSuite) execGovSubmitProposal(c *chain, valIdx int, submitterAddr, govProposalPath, fees string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("Executing gaiad tx gov submit-proposal on chain %s", c.id)

gaiaCommand := []string{
gaiadBinary,
txCommand,
govtypes.ModuleName,
"submit-proposal",
govProposalPath,
fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
"--keyring-backend=test",
"--output=json",
"-y",
}
gaiaCommand = concatFlags(gaiaCommand, proposalFlags, generalFlags)

s.T().Logf("Executing gaiad tx gov %s on chain %s", govCommand, c.id)
s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully submitted proposal %s", govProposalPath)
s.T().Logf("Successfully executed %s", govCommand)
}

func (s *IntegrationTestSuite) executeGKeysAddCommand(c *chain, valIdx int, name string, home string) string {
Expand Down
10 changes: 7 additions & 3 deletions tests/e2e/e2e_globalfee_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ package e2e

import (
"fmt"
"strconv"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
)

func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, proposalCounter int, submitter string, fees string) {
s.writeGovParamChangeProposalGlobalFees(s.chainA, newGlobalfee)
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
submitGovFlags := []string{"param-change", configFile(proposalGlobalFeeFilename)}
depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"}

// gov proposing new fees
s.T().Logf("Proposal number: %d", proposalCounter)
s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fee to %s", newGlobalfee.String())
s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, fees, "param-change", proposalCounter, configFile(proposalGlobalFee))
s.depositGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter)
s.voteGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter, "yes", false)
s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote")

// query the proposal status and new fee
s.Require().Eventually(
Expand Down
Loading

0 comments on commit be2b14f

Please sign in to comment.