-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration tests for equivocation proposals (#710)
* add integration test for equivocation proposal * fixup
- Loading branch information
Showing
6 changed files
with
248 additions
and
1 deletion.
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
108 changes: 108 additions & 0 deletions
108
tests/integration/steps_submit_equivocation_proposal.go
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,108 @@ | ||
package main | ||
|
||
import "time" | ||
|
||
// submits an equivocation proposal, votes on it, and tomstones the equivocating validator | ||
func stepsSubmitEquivocationProposal(consumerName string) []Step { | ||
s := []Step{ | ||
{ | ||
// bob submits a proposal to slash himself | ||
action: submitEquivocationProposalAction{ | ||
chain: chainID("consu"), | ||
from: validatorID("bob"), | ||
deposit: 10000001, | ||
height: 10, | ||
time: time.Now(), // not sure what time in equivocations means | ||
power: 500, | ||
validator: validatorID("bob"), | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 500, | ||
}, | ||
ValBalances: &map[validatorID]uint{ | ||
validatorID("bob"): 9489999999, | ||
}, | ||
Proposals: &map[uint]Proposal{ | ||
2: EquivocationProposal{ | ||
Deposit: 10000001, | ||
Status: "PROPOSAL_STATUS_VOTING_PERIOD", | ||
ConsensusAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", | ||
Power: 500, | ||
Height: 10, | ||
}, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 500, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
action: voteGovProposalAction{ | ||
chain: chainID("provi"), | ||
from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, | ||
vote: []string{"yes", "yes", "yes"}, | ||
propNumber: 2, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 0, // bob is slashed after proposal passes | ||
validatorID("carol"): 500, | ||
}, | ||
Proposals: &map[uint]Proposal{ | ||
2: EquivocationProposal{ | ||
Deposit: 10000001, | ||
Status: "PROPOSAL_STATUS_PASSED", | ||
ConsensusAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", | ||
Power: 500, | ||
Height: 10, | ||
}, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 500, // slash not reflected in consumer chain | ||
validatorID("carol"): 500, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// relay power change to consumer1 | ||
action: relayPacketsAction{ | ||
chain: chainID("provi"), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 0, | ||
validatorID("carol"): 500, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 511, | ||
validatorID("bob"): 0, // slash relayed to consumer chain | ||
validatorID("carol"): 500, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return s | ||
} |