mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
f8c870aa91
* fix bug * return if not ok * don't set peer status there * fix build * fix test * fix all other tests * add regression test * cosmetic changes
27 lines
631 B
Go
27 lines
631 B
Go
package peerstatus
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
)
|
|
|
|
func TestIncrementFailureCount(t *testing.T) {
|
|
testID := peer.ID("test")
|
|
IncreaseFailureCount(testID)
|
|
if FailureCount(testID) != 1 {
|
|
t.Errorf("Wanted failure count of %d but got %d", 1, FailureCount(testID))
|
|
}
|
|
}
|
|
|
|
func TestAboveFailureThreshold(t *testing.T) {
|
|
testID := peer.ID("test")
|
|
for i := 0; i <= maxFailureThreshold; i++ {
|
|
IncreaseFailureCount(testID)
|
|
}
|
|
if !IsBadPeer(testID) {
|
|
t.Errorf("Peer isnt considered as a bad peer despite crossing the failure threshold "+
|
|
"with a failure count of %d", FailureCount(testID))
|
|
}
|
|
}
|