diff --git a/internal/p2p/peermanager_scoring_test.go b/internal/p2p/peermanager_scoring_test.go index 4c7bef0cc..a45df0b72 100644 --- a/internal/p2p/peermanager_scoring_test.go +++ b/internal/p2p/peermanager_scoring_test.go @@ -80,4 +80,20 @@ func TestPeerScoring(t *testing.T) { time.Millisecond, "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]) + } + } + }) }