Skip to content

Commit

Permalink
test: add E2E tests for double voting evidence handling (#1256)
Browse files Browse the repository at this point in the history
* fix double voting cli

* add double-signing e2e test

* refortmat e2e double voting test

* godoc, revert unwanted changes

* nit

* verify dv evidence using malicious validator pubkey in infraction block header

* save changes

* fix hermes config

* fist successful run

* nit

* nits

* nits

* doc and nits

* lint

* refactor

* typo

* change hermes docker image

* nits

* Update tests/e2e/steps.go

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>

* address PR comments

* nits

---------

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>
  • Loading branch information
sainoe and p-offtermatt authored Sep 11, 2023
1 parent 98af9c0 commit c881a1a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
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},
}

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,
},
},
},
},
}
}

0 comments on commit c881a1a

Please sign in to comment.