mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-05-28 19:39:27 +00:00
Merge pull request #122 from libp2p/fix/forbid-nonsensical-options
forbid sign strict without signing enabled
This commit is contained in:
commit
dbbae462a6
@ -900,6 +900,16 @@ func assertPeerList(t *testing.T, peers []peer.ID, expected ...peer.ID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNonsensicalSigningOptions(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
hosts := getNetHosts(t, ctx, 1)
|
||||||
|
_, err := NewFloodSub(ctx, hosts[0], WithMessageSigning(false), WithStrictSignatureVerification(true))
|
||||||
|
if err == nil {
|
||||||
|
t.Error("expected constructor to fail on nonsensical options")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWithSigning(t *testing.T) {
|
func TestWithSigning(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
@ -177,6 +177,10 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ps.signStrict && ps.signKey == nil {
|
||||||
|
return nil, fmt.Errorf("strict signature verification enabled but message signing is disabled")
|
||||||
|
}
|
||||||
|
|
||||||
rt.Attach(ps)
|
rt.Attach(ps)
|
||||||
|
|
||||||
for _, id := range rt.Protocols() {
|
for _, id := range rt.Protocols() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user