Commit 0832791d authored by vyzo's avatar vyzo

extend behaviour penalty test to ensure coverage

parent 63239829
......@@ -749,14 +749,34 @@ func TestScoreBehaviourPenalty(t *testing.T) {
}
peerA := peer.ID("A")
ps := newPeerScore(params)
ps.AddPeer(peerA, "myproto")
var ps *peerScore
// first check AddPenalty on a nil peerScore
ps.AddPenalty(peerA, 1)
aScore := ps.Score(peerA)
if aScore != 0 {
t.Errorf("expected peer score to be 0, got %f", aScore)
}
// instantiate the peerScore
ps = newPeerScore(params)
// next AddPenalty on a non-existent peer
ps.AddPenalty(peerA, 1)
aScore = ps.Score(peerA)
if aScore != 0 {
t.Errorf("expected peer score to be 0, got %f", aScore)
}
// add the peer and test penalties
ps.AddPeer(peerA, "myproto")
aScore = ps.Score(peerA)
if aScore != 0 {
t.Errorf("expected peer score to be 0, got %f", aScore)
}
ps.AddPenalty(peerA, 1)
aScore = ps.Score(peerA)
if aScore != -1 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment