-
Notifications
You must be signed in to change notification settings - Fork 710
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
deps: bump ics to v3.1; chore: update e2e #2663
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package e2e | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" | ||
) | ||
|
||
const ( | ||
proposalAddConsumerChainFilename = "proposal_add_consumer.json" | ||
proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" | ||
) | ||
|
||
type ConsumerAdditionProposalWithDeposit struct { | ||
providertypes.ConsumerAdditionProposal | ||
Deposit string `json:"deposit"` | ||
Summary string `json:"summary"` // required on legacy proposals | ||
} | ||
|
||
type ConsumerRemovalProposalWithDeposit struct { | ||
providertypes.ConsumerRemovalProposal | ||
Deposit string `json:"deposit"` | ||
Summary string `json:"summary"` // required on legacy proposals | ||
} | ||
|
||
func (s *IntegrationTestSuite) writeAddRemoveConsumerProposals(c *chain, consumerChainID string) { | ||
hash, _ := json.Marshal("Z2VuX2hhc2g=") | ||
addProp := &providertypes.ConsumerAdditionProposal{ | ||
Title: "Create consumer chain", | ||
Description: "First consumer chain", | ||
ChainId: consumerChainID, | ||
InitialHeight: ibcclienttypes.Height{ | ||
RevisionHeight: 1, | ||
}, | ||
GenesisHash: hash, | ||
BinaryHash: hash, | ||
SpawnTime: time.Now(), | ||
UnbondingPeriod: time.Duration(100000000000), | ||
CcvTimeoutPeriod: time.Duration(100000000000), | ||
TransferTimeoutPeriod: time.Duration(100000000000), | ||
ConsumerRedistributionFraction: "0.75", | ||
BlocksPerDistributionTransmission: 10, | ||
HistoricalEntries: 10000, | ||
} | ||
addPropWithDeposit := ConsumerAdditionProposalWithDeposit{ | ||
ConsumerAdditionProposal: *addProp, | ||
Deposit: "1000uatom", | ||
// Summary is | ||
Summary: "Summary for the First consumer chain addition proposal", | ||
} | ||
|
||
removeProp := &providertypes.ConsumerRemovalProposal{ | ||
Title: "Remove consumer chain", | ||
Description: "Removing consumer chain", | ||
ChainId: consumerChainID, | ||
StopTime: time.Now(), | ||
} | ||
|
||
removePropWithDeposit := ConsumerRemovalProposalWithDeposit{ | ||
ConsumerRemovalProposal: *removeProp, | ||
Summary: "Summary for the First consumer chain removal proposal", | ||
Deposit: "1000uatom", | ||
} | ||
|
||
consumerAddBody, err := json.MarshalIndent(addPropWithDeposit, "", " ") | ||
s.Require().NoError(err) | ||
|
||
consumerRemoveBody, err := json.MarshalIndent(removePropWithDeposit, "", " ") | ||
s.Require().NoError(err) | ||
|
||
err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalAddConsumerChainFilename), consumerAddBody) | ||
s.Require().NoError(err) | ||
err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalRemoveConsumerChainFilename), consumerRemoveBody) | ||
s.Require().NoError(err) | ||
} | ||
|
||
/* | ||
AddRemoveConsumerChain tests adding and subsequently removing a new consumer chain to Gaia. | ||
Test Benchmarks: | ||
1. Submit and pass proposal to add consumer chain | ||
2. Validation that consumer chain was added | ||
3. Submit and pass proposal to remove consumer chain | ||
4. Validation that consumer chain was removed | ||
*/ | ||
func (s *IntegrationTestSuite) AddRemoveConsumerChain() { | ||
s.fundCommunityPool() | ||
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) | ||
proposerAddress, _ := s.chainA.validators[0].keyInfo.GetAddress() | ||
sender := proposerAddress.String() | ||
consumerChainID := "consumer" | ||
s.writeAddRemoveConsumerProposals(s.chainA, consumerChainID) | ||
|
||
// Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query | ||
// Add Consumer Chain | ||
proposalCounter++ | ||
submitGovFlags := []string{"consumer-addition", configFile(proposalAddConsumerChainFilename)} | ||
depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} | ||
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} | ||
s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, providertypes.ProposalTypeConsumerAddition, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) | ||
|
||
// Query and assert consumer has been added | ||
s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerAddition, consumerChainID) | ||
|
||
// Remove Consumer Chain | ||
proposalCounter++ | ||
submitGovFlags = []string{"consumer-removal", configFile(proposalRemoveConsumerChainFilename)} | ||
depositGovFlags = []string{strconv.Itoa(proposalCounter), depositAmount.String()} | ||
voteGovFlags = []string{strconv.Itoa(proposalCounter), "yes"} | ||
s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, providertypes.ProposalTypeConsumerRemoval, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) | ||
// Query and assert consumer has been removed | ||
s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerRemoval, consumerChainID) | ||
} | ||
|
||
func validateConsumerAddition(res providertypes.QueryConsumerChainsResponse, consumerChainID string) bool { | ||
if res.Size() == 0 { | ||
return false | ||
} | ||
for _, chain := range res.GetChains() { | ||
return strings.Compare(chain.ChainId, consumerChainID) == 0 | ||
} | ||
return false | ||
} | ||
|
||
func validateConsumerRemoval(res providertypes.QueryConsumerChainsResponse, consumerChainID string) bool { | ||
if res.Size() > 0 { | ||
for _, chain := range res.GetChains() { | ||
if strings.Compare(chain.ChainId, consumerChainID) == 0 { | ||
return false | ||
} | ||
} | ||
} | ||
return true | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we remove this ?
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.
Sry, missed the comment and merged. Will remove at a later time