-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start skip round logic (missing to see what messages are there upon skipping) * added skip round reaction upon votes * bug in strings calling bookkeeper fixed * another wrong string * added round switch test - not activated yet * tests around round switching * failing test * Fix typos * added a test that generates a lot of unsuccessful rounds * added assertion for correct round * Ensure `Skip` event is emitted even when no threshold has been reached yet * Ensure `Skip` event is emitted only when vote round is strictly greater than the current round * Remove debug statement * parameterized test is more concise * made parameterized test even more concise * added an assertion at the end of unsuccessful round --------- Co-authored-by: Romain Ruetschi <romain@informal.systems>
- Loading branch information
1 parent
2a7862b
commit ce7a130
Showing
6 changed files
with
234 additions
and
34 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
module parameterizedTest { | ||
|
||
import statemachineAsync( | ||
validators = Set("v1", "v2", "v3", "v4"), | ||
validatorSet = Set("v1", "v2", "v3", "v4").mapBy(x => 1), | ||
Faulty = Set(), | ||
Values = Set("a", "b"), | ||
Rounds = Set(0, 1, 2, 3), | ||
Heights = Set(0) // , 1, 2, 3) | ||
) as N4F0 from "./statemachineAsync" | ||
|
||
val validatorList = N4F0::validators.fold(List(), (s, x) => s.append(x)) | ||
|
||
run everyoneTakesAStep = { | ||
validatorList.length().reps(i => N4F0::valStep(validatorList[i])) | ||
} | ||
|
||
// here there is a different prevote from the proposer | ||
run oneDeliversPrevote (validator, prop, r, proposer, nonprop) = { | ||
nonprop.length().reps( i => | ||
N4F0::deliverVote(validator, { height: 0, id: "nil", round: r, src: nonprop[i], step: "Prevote" })) | ||
.then(N4F0::deliverVote(validator, { height: 0, id: prop, round: r, src: proposer, step: "Prevote" })) | ||
} | ||
|
||
run everyoneDeliversPrevote (prop, r, proposer, nonprop) = { | ||
validatorList.length().reps(i => oneDeliversPrevote (validatorList[i], prop, r, proposer, nonprop)) | ||
} | ||
|
||
// all the precommits are for "nil" | ||
run oneDeliversPrecommit (validator, prop, r, proposer, nonprop) = { | ||
validatorList.length().reps(i => | ||
N4F0::deliverVote(validator, { height: 0, id: "nil", round: r, src: validatorList[i], step: "Precommit" })) | ||
} | ||
|
||
run everyoneDeliversPrecommit (prop, r, proposer, nonprop) = { | ||
validatorList.length().reps(i => oneDeliversPrecommit (validatorList[i], prop, r, proposer, nonprop)) | ||
} | ||
|
||
run UnSuccessfulRound (prop: str, r: int) : bool = { | ||
val proposer = N4F0::Proposer(N4F0::validatorSet, 0, r) | ||
val nonprop = validatorList.select(x => x != proposer) | ||
// everyone is in round r and proposer sent a proposal | ||
all { | ||
assert(N4F0::propBuffer.keys().forall(p => N4F0::propBuffer.get(p).contains( | ||
{ height: 0, proposal: prop, round: r, src: proposer, validRound: -1 }) )), | ||
N4F0::unchangedAll | ||
} | ||
.then(N4F0::deliverProposal(proposer, { height: 0, proposal: prop, round: r, src: proposer, validRound: -1 })) | ||
.then(everyoneTakesAStep) | ||
.then(everyoneDeliversPrevote(prop, r, proposer, nonprop)) | ||
.then(3.reps(i => everyoneTakesAStep)) | ||
.then(all { | ||
assert(N4F0::system.keys().forall(p => N4F0::system.get(p).timeout.contains( | ||
("TimeoutPrevote", 0, r)) )), | ||
N4F0::unchangedAll | ||
}) | ||
.then(everyoneTakesAStep) | ||
.then(everyoneDeliversPrecommit(prop, r, proposer, nonprop)) | ||
.then(4.reps(i => everyoneTakesAStep)) | ||
.then(all { | ||
assert(N4F0::system.keys().forall(p => N4F0::system.get(p).timeout.contains( | ||
("TimeoutPrecommit", 0, r)) )), | ||
N4F0::unchangedAll | ||
}) | ||
} | ||
|
||
run UnSuccessfulRoundWithSetup (prop: str, r: int) : bool = { | ||
N4F0::setNextValueToPropose(N4F0::Proposer(N4F0::validatorSet, 0, r), prop) | ||
.then(everyoneTakesAStep) | ||
.then(all { | ||
assert(N4F0::system.keys().forall(p => N4F0::system.get(p).es.cs.round == r)), | ||
UnSuccessfulRound (prop, r) | ||
}) | ||
} | ||
|
||
run multiRoundTest = { | ||
val proposals = ["blue", "red", "green", "yellow"] | ||
val repetitions = proposals.length() | ||
N4F0::init | ||
.then(repetitions.reps(i => UnSuccessfulRoundWithSetup(proposals[i], i))) | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.