test blacklist implementations

This commit is contained in:
vyzo 2019-01-17 14:26:06 +02:00
parent f6ac3aab4f
commit 440c8b7331

View File

@ -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()