mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-05 22:33:10 +00:00
test blacklist implementations
This commit is contained in:
parent
f6ac3aab4f
commit
440c8b7331
@ -4,8 +4,37 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
)
|
||||
|
||||
func TestMapBlacklist(t *testing.T) {
|
||||
b := NewMapBlacklist()
|
||||
|
||||
p := peer.ID("test")
|
||||
|
||||
b.Add(p)
|
||||
if !b.Contains(p) {
|
||||
t.Fatal("peer not in the blacklist")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestLRUBlacklist(t *testing.T) {
|
||||
b, err := NewLRUBlacklist(10)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
p := peer.ID("test")
|
||||
|
||||
b.Add(p)
|
||||
if !b.Contains(p) {
|
||||
t.Fatal("peer not in the blacklist")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBlacklist(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user