From 440c8b7331c7eac14007e924875b501083679d99 Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 17 Jan 2019 14:26:06 +0200 Subject: [PATCH] test blacklist implementations --- blacklist_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/blacklist_test.go b/blacklist_test.go index 67f8882..514d9fa 100644 --- a/blacklist_test.go +++ b/blacklist_test.go @@ -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()