-
Notifications
You must be signed in to change notification settings - Fork 693
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
ci: add gov module to interchaintest folder #3408
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd like to be able to run the test funcs independently of one another. So the order shouldn't matter that much. I suggest consolidating the ones that all use the same proposal into one function and then removing the number indicator from the other ones. This way there's no global state or anything, and the tests are independent.
func (s *GovSuite) Test01SubmitProposal() { | ||
delegatorAddress, err := s.Chain.GetAddress(s.GetContext(), delegatorName) | ||
s.Require().NoError(err) | ||
delegatorAddressString := types.MustBech32ifyAddressBytes("cosmos", delegatorAddress) | ||
|
||
// Submit proposal | ||
prop, err := s.Chain.BuildProposal(nil, "Test Proposal", "Test Proposal", "ipfs://CID", submissionDeposit+"uatom", delegatorAddressString, false) | ||
s.Require().NoError(err) | ||
result, err := s.Chain.SubmitProposal(s.GetContext(), delegatorName, prop) | ||
s.Require().NoError(err) | ||
proposalId = result.ProposalID | ||
|
||
// Get status | ||
proposalIDuint, err := strconv.ParseUint(proposalId, 10, 64) | ||
proposal, err := s.Chain.GovQueryProposalV1(s.GetContext(), proposalIDuint) | ||
s.Require().NoError(err) | ||
currentStatus := proposal.Status.String() | ||
|
||
// Test | ||
s.Require().NotEqual("0", proposalId) | ||
s.Require().Equal("PROPOSAL_STATUS_DEPOSIT_PERIOD", currentStatus) | ||
} | ||
|
||
func (s *GovSuite) Test02ProposalDeposit() { | ||
node := s.Chain.GetNode() | ||
delegatorAddress, err := s.Chain.GetAddress(s.GetContext(), delegatorName) | ||
s.Require().NoError(err) | ||
delegatorAddressString := types.MustBech32ifyAddressBytes("cosmos", delegatorAddress) | ||
proposalDeposit := strconv.Itoa(proposalDepositInt) | ||
|
||
// Submit deposit to proposal | ||
_, err = node.ExecTx(s.GetContext(), delegatorName, "gov", "deposit", proposalId, proposalDeposit+"uatom", "--gas", "auto") | ||
s.Require().NoError(err) | ||
proposalIDuint, err := strconv.ParseUint(proposalId, 10, 64) | ||
proposal, err := s.Chain.GovQueryProposalV1(s.GetContext(), proposalIDuint) | ||
s.Require().NoError(err) | ||
currentStatus := proposal.Status.String() | ||
|
||
submissionDepositUint, err := strconv.ParseUint(submissionDeposit, 10, 64) | ||
s.Require().NoError(err) | ||
depositTotal := chainsuite.GovMinDepositAmount + submissionDepositUint | ||
fmt.Println("Deposit total: ", depositTotal) | ||
|
||
// Test | ||
deposit, err := s.Chain.QueryJSON(s.GetContext(), "deposit", "gov", "deposit", proposalId, delegatorAddressString) | ||
s.Require().NoError(err) | ||
depositAmount := deposit.Get("amount.#(denom==\"uatom\").amount").String() | ||
depositAmountUint, err := strconv.ParseUint(depositAmount, 10, 64) | ||
s.Require().NoError(err) | ||
chainsuite.GetLogger(s.GetContext()).Sugar().Infof("Query amount: %d", depositAmountUint) | ||
s.Require().Equal("PROPOSAL_STATUS_VOTING_PERIOD", currentStatus) | ||
s.Require().Equal(depositTotal, depositAmountUint) | ||
} | ||
|
||
func (s *GovSuite) Test03ProposalVote() { | ||
node := s.Chain.GetNode() | ||
delegatorAddress, err := s.Chain.GetAddress(s.GetContext(), delegatorName) | ||
s.Require().NoError(err) | ||
delegatorAddressString := types.MustBech32ifyAddressBytes("cosmos", delegatorAddress) | ||
// Vote yes on proposal | ||
_, err = node.ExecTx(s.GetContext(), delegatorName, "gov", "vote", proposalId, "yes", "--gas", "auto") | ||
s.Require().NoError(err) | ||
|
||
// Test | ||
vote, err := s.Chain.QueryJSON(s.GetContext(), "vote", "gov", "vote", proposalId, delegatorAddressString) | ||
s.Require().NoError(err) | ||
actual_yes_weight := vote.Get("options.#(option==\"VOTE_OPTION_YES\").weight") | ||
chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", actual_yes_weight.String()) | ||
s.Require().Equal(float64(1.0), actual_yes_weight.Float()) | ||
} | ||
|
||
func (s *GovSuite) Test04ProposalWeightedVote() { | ||
node := s.Chain.GetNode() | ||
delegatorAddress, err := s.Chain.GetAddress(s.GetContext(), delegatorName) | ||
s.Require().NoError(err) | ||
delegatorAddressString := types.MustBech32ifyAddressBytes("cosmos", delegatorAddress) | ||
// Submit weighted vote to proposal | ||
_, err = node.ExecTx(s.GetContext(), delegatorName, "gov", "weighted-vote", proposalId, fmt.Sprintf("yes=%0.2f,no=%0.2f,abstain=%0.2f,no_with_veto=%0.2f", yesWeight, noWeight, abstainWeight, vetoWeight), "--gas", "auto") | ||
s.Require().NoError(err) | ||
|
||
// Test | ||
vote, err := s.Chain.QueryJSON(s.GetContext(), "vote", "gov", "vote", proposalId, delegatorAddressString) | ||
s.Require().NoError(err) | ||
// chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", vote) | ||
actual_yes_weight := vote.Get("options.#(option==\"VOTE_OPTION_YES\").weight") | ||
// chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", actual_yes_weight.String()) | ||
s.Require().Equal(float64(yesWeight), actual_yes_weight.Float()) | ||
actual_no_weight := vote.Get("options.#(option==\"VOTE_OPTION_NO\").weight") | ||
// chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", actual_no_weight.String()) | ||
s.Require().Equal(float64(noWeight), actual_no_weight.Float()) | ||
actual_abstain_weight := vote.Get("options.#(option==\"VOTE_OPTION_ABSTAIN\").weight") | ||
// chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", actual_abstain_weight.String()) | ||
s.Require().Equal(float64(abstainWeight), actual_abstain_weight.Float()) | ||
actual_veto_weight := vote.Get("options.#(option==\"VOTE_OPTION_NO_WITH_VETO\").weight") | ||
// chainsuite.GetLogger(s.GetContext()).Sugar().Infof("%s", actual_veto_weight.String()) | ||
s.Require().Equal(float64(vetoWeight), actual_veto_weight.Float()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these are the ones that use the proposal you submitted in Test01 right? I'd suggest gathering all of them together into one test func and then using s.Run() to split up the individual stories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fastfadingviolets ! I decoupled all tests.
Successful workflow run: |
Description
Adds gov module tests to delegator folder:
Successful workflow run:
https://github.com/cosmos/gaia/actions/runs/11732771239
Author Checklist
I have...
Reviewers Checklist
I have...