-
Notifications
You must be signed in to change notification settings - Fork 122
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
test: add partial-set-security E2E tests #1737
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
991e220
init commit
insumity 3eb2b9b
fix traces
insumity 15cb7bd
Add PSS to default tests
p-offtermatt 9293f9c
Merge branch 'feat/partial-set-security' into insumity/add-e2e-test
insumity 02f4c10
Update tests/e2e/steps_partial_set_security.go
insumity 7d7255d
Update tests/e2e/steps_partial_set_security.go
insumity 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
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -253,6 +253,7 @@ type SubmitConsumerAdditionProposalAction struct { | |||||||||
SpawnTime uint | ||||||||||
InitialHeight clienttypes.Height | ||||||||||
DistributionChannel string | ||||||||||
TopN uint32 | ||||||||||
} | ||||||||||
|
||||||||||
func (tr TestConfig) submitConsumerAdditionProposal( | ||||||||||
|
@@ -278,7 +279,7 @@ func (tr TestConfig) submitConsumerAdditionProposal( | |||||||||
UnbondingPeriod: params.UnbondingPeriod, | ||||||||||
Deposit: fmt.Sprint(action.Deposit) + `stake`, | ||||||||||
DistributionTransmissionChannel: action.DistributionChannel, | ||||||||||
TopN: 100, | ||||||||||
TopN: action.TopN, | ||||||||||
} | ||||||||||
|
||||||||||
bz, err := json.Marshal(prop) | ||||||||||
|
@@ -292,9 +293,14 @@ func (tr TestConfig) submitConsumerAdditionProposal( | |||||||||
} | ||||||||||
|
||||||||||
//#nosec G204 -- bypass unsafe quoting warning (no production code) | ||||||||||
bz, err = target.ExecCommand( | ||||||||||
cmd := target.ExecCommand( | ||||||||||
"/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json"), | ||||||||||
).CombinedOutput() | ||||||||||
) | ||||||||||
bz, err = cmd.CombinedOutput() | ||||||||||
|
||||||||||
if verbose { | ||||||||||
log.Println("submitConsumerAdditionProposal cmd: ", cmd.String()) | ||||||||||
} | ||||||||||
|
||||||||||
if err != nil { | ||||||||||
log.Fatal(err, "\n", string(bz)) | ||||||||||
|
@@ -2292,6 +2298,98 @@ func (tc TestConfig) startConsumerEvidenceDetector( | |||||||||
tc.waitBlocks("provi", 10, 2*time.Minute) | ||||||||||
} | ||||||||||
|
||||||||||
type OptInAction struct { | ||||||||||
Chain ChainID | ||||||||||
Validator ValidatorID | ||||||||||
} | ||||||||||
|
||||||||||
func (tr TestConfig) optIn(action OptInAction, target ExecutionTarget, verbose bool) { | ||||||||||
// Note: to get error response reported back from this command '--gas auto' needs to be set. | ||||||||||
gas := "auto" | ||||||||||
// Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then | ||||||||||
if tr.useCometmock { | ||||||||||
gas = "9000000" | ||||||||||
} | ||||||||||
|
||||||||||
// Use: "opt-in [consumer-chain-id] [consumer-pubkey]", | ||||||||||
optIn := fmt.Sprintf( | ||||||||||
`%s tx provider opt-in %s --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, | ||||||||||
tr.chainConfigs[ChainID("provi")].BinaryName, | ||||||||||
string(tr.chainConfigs[action.Chain].ChainId), | ||||||||||
action.Validator, | ||||||||||
tr.chainConfigs[ChainID("provi")].ChainId, | ||||||||||
tr.getValidatorHome(ChainID("provi"), action.Validator), | ||||||||||
tr.getValidatorNode(ChainID("provi"), action.Validator), | ||||||||||
gas, | ||||||||||
) | ||||||||||
|
||||||||||
cmd := target.ExecCommand( | ||||||||||
"/bin/bash", "-c", | ||||||||||
optIn, | ||||||||||
) | ||||||||||
|
||||||||||
if verbose { | ||||||||||
fmt.Println("optIn cmd:", cmd.String()) | ||||||||||
} | ||||||||||
|
||||||||||
bz, err := cmd.CombinedOutput() | ||||||||||
_, _ = bz, err | ||||||||||
if !tr.useCometmock { // error report only works with --gas auto, which does not work with CometMock, so ignore | ||||||||||
if verbose { | ||||||||||
fmt.Printf("got expected error during opt in | err: %s | output: %s \n", err, string(bz)) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// wait for inclusion in a block -> '--broadcast-mode block' is deprecated | ||||||||||
tr.waitBlocks(ChainID("provi"), 2, 30*time.Second) | ||||||||||
} | ||||||||||
|
||||||||||
type OptOutAction struct { | ||||||||||
Chain ChainID | ||||||||||
Validator ValidatorID | ||||||||||
} | ||||||||||
|
||||||||||
func (tr TestConfig) optOut(action OptOutAction, target ExecutionTarget, verbose bool) { | ||||||||||
// Note: to get error response reported back from this command '--gas auto' needs to be set. | ||||||||||
gas := "auto" | ||||||||||
// Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then | ||||||||||
if tr.useCometmock { | ||||||||||
gas = "9000000" | ||||||||||
} | ||||||||||
|
||||||||||
// Use: "opt-out [consumer-chain-id]", | ||||||||||
optIn := fmt.Sprintf( | ||||||||||
`%s tx provider opt-out %s --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, | ||||||||||
tr.chainConfigs[ChainID("provi")].BinaryName, | ||||||||||
string(tr.chainConfigs[action.Chain].ChainId), | ||||||||||
action.Validator, | ||||||||||
tr.chainConfigs[ChainID("provi")].ChainId, | ||||||||||
tr.getValidatorHome(ChainID("provi"), action.Validator), | ||||||||||
tr.getValidatorNode(ChainID("provi"), action.Validator), | ||||||||||
gas, | ||||||||||
) | ||||||||||
|
||||||||||
cmd := target.ExecCommand( | ||||||||||
"/bin/bash", "-c", | ||||||||||
optIn, | ||||||||||
) | ||||||||||
|
||||||||||
if verbose { | ||||||||||
fmt.Println("optOut cmd:", cmd.String()) | ||||||||||
} | ||||||||||
|
||||||||||
bz, err := cmd.CombinedOutput() | ||||||||||
_, _ = bz, err | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if !tr.useCometmock { // error report only works with --gas auto, which does not work with CometMock, so ignore | ||||||||||
if verbose { | ||||||||||
fmt.Printf("got expected error during opt out | err: %s | output: %s \n", err, string(bz)) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// wait for inclusion in a block -> '--broadcast-mode block' is deprecated | ||||||||||
tr.waitBlocks(ChainID("provi"), 2, 30*time.Second) | ||||||||||
} | ||||||||||
|
||||||||||
// WaitTime waits for the given duration. | ||||||||||
// To make sure that the new timestamp is visible on-chain, it also waits until at least one block has been | ||||||||||
// produced on each chain after waiting. | ||||||||||
|
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 |
---|---|---|
|
@@ -156,6 +156,18 @@ var stepChoices = map[string]StepChoice{ | |
description: `Minimal set of test steps to perform compatibility tests`, | ||
testConfig: CompatibilityTestCfg, | ||
}, | ||
"partial-set-security-opt-in": { | ||
name: "partial-set-security-opt-in", | ||
steps: stepsOptInChain(), | ||
description: "test partial set security for an Opt-In chain", | ||
testConfig: DefaultTestCfg, | ||
}, | ||
"partial-set-security-top-n": { | ||
name: "partial-set-security-top-n", | ||
steps: stepsTopNChain(), | ||
description: "test partial set security for a Top-N chain", | ||
testConfig: DefaultTestCfg, | ||
}, | ||
} | ||
|
||
func getTestCaseUsageString() string { | ||
|
@@ -241,7 +253,7 @@ func getTestCases(selectedPredefinedTests, selectedTestFiles TestSet, providerVe | |
"changeover", "happy-path", | ||
"democracy-reward", "democracy", | ||
"slash-throttle", "consumer-double-sign", "consumer-misbehaviour", | ||
"consumer-double-downtime", | ||
"consumer-double-downtime", "partial-set-security-opt-in", "partial-set-security-top-n", | ||
} | ||
if includeMultiConsumer != nil && *includeMultiConsumer { | ||
selectedPredefinedTests = append(selectedPredefinedTests, "multiconsumer") | ||
|
@@ -430,13 +442,13 @@ TEST RESULTS | |
} | ||
} | ||
if len(passedTests) > 0 { | ||
report += fmt.Sprintln("\n\nPASSED TESTS:\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed new lines because of:
|
||
report += fmt.Sprintln("\n\nPASSED TESTS:") | ||
for _, t := range passedTests { | ||
report += t.Report() | ||
} | ||
} | ||
if len(remainingTests) > 0 { | ||
report += fmt.Sprintln("\n\nREMAINING TESTS:\n") | ||
report += fmt.Sprintln("\n\nREMAINING TESTS:") | ||
for _, t := range remainingTests { | ||
report += t.Report() | ||
} | ||
|
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
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.