diff --git a/raft/consensus_state_machine.nim b/raft/consensus_state_machine.nim index f72a999..d27f0b7 100644 --- a/raft/consensus_state_machine.nim +++ b/raft/consensus_state_machine.nim @@ -14,7 +14,7 @@ import chronicles type # Node events - EventType = enum + EventType* = enum VotingTimeout, ElectionTimeout, HeartbeatTimeout, @@ -59,7 +59,7 @@ type # FSM type constructor proc new*[RaftNodeState, EventType, NodeType, RaftNodeStates]( - T: type ConsensusFsm[RaftNodeState, EventType, NodeType, RaftMessageBase], startSymbol: RaftNodeState): T = + T: type ConsensusFsm[RaftNodeState, EventType, NodeType, RaftMessageBase], startSymbol: RaftNodeState = rnsFollower): T = result = new(ConsensusFsm[NodeType, EventType, RaftNodeStates]) initRLock(result.mtx) @@ -79,7 +79,7 @@ proc addFsmTransitionLogicalConditions*[RaftNodeState, EventType, NodeType, Raft fsm: ConsensusFsm[RaftNodeState, EventType, NodeType, RaftMessageBase], state: RaftNodeState, event: EventType, - logicalConditions: seq[LogicalCondition[NodeType, Option[RaftMessageBase]]]) = + logicalConditions: seq[LogicalCondition[NodeType, RaftMessageBase]]) = fsm.logicalFunctionsLut[(state, event)] = logicalConditions diff --git a/tests/test_consensus_state_machine.nim b/tests/test_consensus_state_machine.nim index 2785125..f85008b 100644 --- a/tests/test_consensus_state_machine.nim +++ b/tests/test_consensus_state_machine.nim @@ -8,10 +8,12 @@ # those terms. import unittest2 +import basic_state_machine import ../raft/consensus_state_machine +import ../raft/types suite "Create and test Consensus State Machine": test "Create Consensus State Machine": - let csm = ConsensusStateMachine.new() + let csm = ConsensusFsm[RaftNodeState, EventType, RaftNode[SmState, SmCommand], RaftMessageBase].new() check csm != nil \ No newline at end of file