Remove another function

This commit is contained in:
Smaug123
2022-11-12 21:37:51 +00:00
parent 7396979958
commit fe7f5427c1
2 changed files with 3 additions and 54 deletions

View File

@@ -9,57 +9,6 @@ open FsCheck
[<TestFixture>]
module TestInMemoryServer =
[<Test>]
let ``Startup sequence, first fumbling steps`` () =
let cluster, network = InMemoryCluster.make<int> 5
let logger, logs = TestLogger.make ()
// Candidate 1 asks server 0 to vote for it.
{
CandidateTerm = 0<Term>
CandidateId = 1<ServerId>
ReplyChannel = fun message -> logger (sprintf "Received message for term %i" message.VoterTerm)
CandidateLastLogEntry = None
}
|> Instruction.RequestVote
|> Message.Instruction
|> cluster.SendMessageDirectly 0<ServerId>
logs () |> shouldEqual [ "Received message for term 0" ]
// Candidate 1 asks to be elected again! This is fine, maybe the network is replaying requests
// and the network swallowed our reply, so we should reply in the same way.
{
CandidateTerm = 0<Term>
CandidateId = 1<ServerId>
ReplyChannel = fun message -> logger (sprintf "Received message for term %i" message.VoterTerm)
CandidateLastLogEntry = None
}
|> Instruction.RequestVote
|> Message.Instruction
|> cluster.SendMessageDirectly 0<ServerId>
logs ()
|> shouldEqual [ "Received message for term 0" ; "Received message for term 0" ]
// Candidate 2 asks to be elected. We won't vote for them, because we've already voted.
// and the network swallowed our reply, so we should reply in the same way.
let calls = ref 0
{
CandidateTerm = 0<Term>
CandidateId = 2<ServerId>
ReplyChannel = fun _ -> Interlocked.Increment calls |> ignore
CandidateLastLogEntry = None
}
|> Instruction.RequestVote
|> Message.Instruction
|> cluster.SendMessageDirectly 0<ServerId>
calls.Value |> shouldEqual 0
[<Test>]
let ``Startup sequence in prod, only one timeout takes place`` () =
let cluster, network = InMemoryCluster.make<int> 5

View File

@@ -75,7 +75,6 @@ type RequestVoteMessage =
CandidateTerm : int<Term>
CandidateId : int<ServerId>
CandidateLastLogEntry : LogEntryMetadata option
ReplyChannel : RequestVoteReply -> unit
}
override this.ToString () =
@@ -381,7 +380,9 @@ type Server<'a>
VoteGranted = true
Candidate = message.CandidateId
}
|> message.ReplyChannel
|> Reply.RequestVoteReply
|> Message.Reply
|> messageChannel message.CandidateId
| AppendEntries message ->
// This was guaranteed above.
@@ -695,7 +696,6 @@ type Server<'a>
CandidateTerm = persistentState.CurrentTerm
CandidateId = me
CandidateLastLogEntry = persistentState.GetLastLogEntry () |> Option.map snd
ReplyChannel = fun reply -> messageChannel me (RequestVoteReply reply |> Message.Reply)
}
|> Instruction.RequestVote
|> Message.Instruction