Skip to content

Commit

Permalink
more blacklist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Jan 15, 2019
1 parent 657c899 commit 157a7dd
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions blacklist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestBlacklist(t *testing.T) {
t.Fatal(err)
}

time.Sleep(time.Millisecond * 100)
psubs[1].BlacklistPeer(hosts[0].ID())
time.Sleep(time.Millisecond * 100)

Expand All @@ -32,3 +33,36 @@ func TestBlacklist(t *testing.T) {
t.Fatal("got message from blacklisted peer")
}
}

func TestBlacklist2(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

hosts := getNetHosts(t, ctx, 2)
psubs := getPubsubs(ctx, hosts)
connect(t, hosts[0], hosts[1])

_, err := psubs[0].Subscribe("test")
if err != nil {
t.Fatal(err)
}

sub1, err := psubs[1].Subscribe("test")
if err != nil {
t.Fatal(err)
}

time.Sleep(time.Millisecond * 100)
psubs[1].BlacklistPeer(hosts[0].ID())
time.Sleep(time.Millisecond * 100)

psubs[0].Publish("test", []byte("message"))

wctx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
_, err = sub1.Next(wctx)

if err == nil {
t.Fatal("got message from blacklisted peer")
}
}

0 comments on commit 157a7dd

Please sign in to comment.