mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-02-21 22:23:07 +00:00
35 lines
879 B
Nim
35 lines
879 B
Nim
import std/unittest
|
|
import pkg/questionable
|
|
import mysticeti
|
|
import ./examples
|
|
import ./mocks/identity
|
|
|
|
suite "Validator":
|
|
|
|
var validator: Validator
|
|
var validator2, validator3: Validator
|
|
|
|
let scheme = mockIdentityScheme
|
|
|
|
setup:
|
|
validator = Validator.new(scheme)
|
|
validator2 = Validator.new(scheme)
|
|
validator3 = Validator.new(scheme)
|
|
|
|
test "has a unique identifier":
|
|
check Validator.new(scheme).identifier != Validator.new(scheme).identifier
|
|
|
|
test "starts at round 0":
|
|
check validator.round == 0
|
|
|
|
test "can move to next round":
|
|
validator.nextRound()
|
|
check validator.round == 1
|
|
validator.nextRound()
|
|
validator.nextRound()
|
|
check validator.round == 3
|
|
|
|
test "by default proposals are undecided":
|
|
let proposal = validator.propose(seq[Transaction].example)
|
|
check validator.status(proposal) == some ProposalStatus.undecided
|