Browse Source

update the scoring test

pull/8137/head
jay tseng 3 years ago
parent
commit
da9ba1913d
No known key found for this signature in database GPG Key ID: 5A9D3063305E6427
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      internal/p2p/peermanager_scoring_test.go

+ 16
- 0
internal/p2p/peermanager_scoring_test.go View File

@ -80,4 +80,20 @@ func TestPeerScoring(t *testing.T) {
time.Millisecond, time.Millisecond,
"startAt=%d score=%d", start, peerManager.Scores()[id]) "startAt=%d score=%d", start, peerManager.Scores()[id])
}) })
t.Run("TestNonPersistantPeerUpperBound", func(t *testing.T) {
start := int64(peerManager.Scores()[id] + 1)
for i := start; i <= int64(PeerScorePersistent); i++ {
peerManager.processPeerEvent(ctx, PeerUpdate{
NodeID: id,
Status: PeerStatusGood,
})
if i == int64(PeerScorePersistent) {
require.EqualValues(t, MaxPeerScoreNotPersistent, peerManager.Scores()[id])
} else {
require.EqualValues(t, i, peerManager.Scores()[id])
}
}
})
} }

Loading…
Cancel
Save