mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-03 21:33:07 +00:00
add test for UnregisterTopicValidator
This commit is contained in:
parent
399bcb25a6
commit
ed1dd154b6
@ -341,6 +341,31 @@ func TestOneToOne(t *testing.T) {
|
||||
checkMessageRouting(t, "foobar", psubs, []*Subscription{sub})
|
||||
}
|
||||
|
||||
func TestRegisterUnregisterValidator(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
hosts := getNetHosts(t, ctx, 1)
|
||||
psubs := getPubsubs(ctx, hosts)
|
||||
|
||||
err := psubs[0].RegisterTopicValidator("foo", func(context.Context, *Message) bool {
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = psubs[0].UnregisterTopicValidator("foo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = psubs[0].UnregisterTopicValidator("foo")
|
||||
if err == nil {
|
||||
t.Fatal("Unregistered bogus topic validator")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user