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

test: add E2E tests for double voting evidence handling #1256

Merged
merged 24 commits into from
Sep 11, 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
2 changes: 2 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func main() {
{DemocracyTestRun(false), rewardDenomConsumerSteps},
{SlashThrottleTestRun(), slashThrottleSteps},
{ConsumerMisbehaviourTestRun(), consumerMisbehaviourSteps},
{DefaultTestRun(), consumerDoubleSignSteps},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls note that the way tests are selected/organized has changed in the latest version of main branch

}

if includeMultiConsumer != nil && *includeMultiConsumer {
testRuns = append(testRuns, testRunWithSteps{MultiConsumerTestRun(), multipleConsumers})
}
Expand Down
10 changes: 9 additions & 1 deletion tests/e2e/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ var changeoverSteps = concatSteps(
var consumerMisbehaviourSteps = concatSteps(
// start provider and consumer chain
stepsStartChainsWithSoftOptOut("consu"),
// make consumer validator to misbehave and get jail
// make a consumer validator to misbehave and get jailed
stepsCauseConsumerMisbehaviour("consu"),
)

var consumerDoubleSignSteps = concatSteps(
// start provider and consumer chain
stepsStartChains([]string{"consu"}, false),

// make a consumer validator double sign and get jailed
stepsCauseDoubleSignOnConsumer("consu", "provi"),
)
76 changes: 76 additions & 0 deletions tests/e2e/steps_double_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,79 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step {
},
}
}

// Steps that make bob double sign on the consumer
func stepsCauseDoubleSignOnConsumer(consumerName, providerName string) []Step {
return []Step{
{
action: doublesignSlashAction{
chain: chainID(consumerName),
validator: validatorID("bob"),
},
state: State{
chainID(providerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
// detect the double voting infraction
// and jail bob on the provider
{
action: detectConsumerEvidenceAction{
chain: chainID(consumerName),
},
state: State{
chainID(providerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
// consumer learns about the jailing
{
action: relayPacketsAction{
chainA: chainID(providerName),
chainB: chainID(consumerName),
port: "provider",
channel: 0,
},
state: State{
chainID(providerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
},
},
}
}
Loading