mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-04 05:43:06 +00:00
extend behaviour penalty test to ensure coverage
This commit is contained in:
parent
6323982964
commit
0832791d9c
@ -749,10 +749,30 @@ func TestScoreBehaviourPenalty(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
peerA := peer.ID("A")
|
peerA := peer.ID("A")
|
||||||
ps := newPeerScore(params)
|
|
||||||
|
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")
|
ps.AddPeer(peerA, "myproto")
|
||||||
|
|
||||||
aScore := ps.Score(peerA)
|
aScore = ps.Score(peerA)
|
||||||
if aScore != 0 {
|
if aScore != 0 {
|
||||||
t.Errorf("expected peer score to be 0, got %f", aScore)
|
t.Errorf("expected peer score to be 0, got %f", aScore)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user