mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
chore: don't return error on double relay subscription/unsubscription (#3429)
This commit is contained in:
parent
768b2785e1
commit
5e22ea18b6
@ -631,7 +631,7 @@ suite "WakuNode - Relay":
|
||||
# Stop all nodes
|
||||
await allFutures(nodes.mapIt(it.stop()))
|
||||
|
||||
asyncTest "Only one subscription is allowed for contenttopics that generate the same shard":
|
||||
asyncTest "Multiple subscription calls are allowed for contenttopics that generate the same shard":
|
||||
## Setup
|
||||
let
|
||||
nodeKey = generateSecp256k1Key()
|
||||
@ -663,12 +663,12 @@ suite "WakuNode - Relay":
|
||||
## When
|
||||
node.subscribe((kind: ContentSub, topic: contentTopicA), some(handler)).isOkOr:
|
||||
assert false, "Failed to subscribe to topic: " & $error
|
||||
node.subscribe((kind: ContentSub, topic: contentTopicB), some(handler)).isErrOr:
|
||||
node.subscribe((kind: ContentSub, topic: contentTopicB), some(handler)).isOkOr:
|
||||
assert false,
|
||||
"The subscription should fail because is already subscribe to that shard"
|
||||
node.subscribe((kind: ContentSub, topic: contentTopicC), some(handler)).isErrOr:
|
||||
"The subscription call shouldn't error even though it's already subscribed to that shard"
|
||||
node.subscribe((kind: ContentSub, topic: contentTopicC), some(handler)).isOkOr:
|
||||
assert false,
|
||||
"The subscription should fail because is already subscribe to that shard"
|
||||
"The subscription call shouldn't error even though it's already subscribed to that shard"
|
||||
|
||||
## Then
|
||||
node.unsubscribe((kind: ContentUnsub, topic: contentTopicB)).isOkOr:
|
||||
|
||||
@ -323,12 +323,12 @@ proc subscribe*(
|
||||
return err("Unsupported subscription type in relay subscribe")
|
||||
|
||||
if node.wakuRelay.isSubscribed(pubsubTopic):
|
||||
debug "already subscribed to topic", pubsubTopic
|
||||
return err("Already subscribed to topic: " & $pubsubTopic)
|
||||
warn "No-effect API call to subscribe. Already subscribed to topic", pubsubTopic
|
||||
return ok()
|
||||
|
||||
if contentTopicOp.isSome() and node.contentTopicHandlers.hasKey(contentTopicOp.get()):
|
||||
error "Invalid API call to `subscribe`. Was already subscribed"
|
||||
return err("Invalid API call to `subscribe`. Was already subscribed")
|
||||
warn "No-effect API call to `subscribe`. Was already subscribed"
|
||||
return ok()
|
||||
|
||||
node.topicSubscriptionQueue.emit((kind: PubsubSub, topic: pubsubTopic))
|
||||
node.registerRelayDefaultHandler(pubsubTopic)
|
||||
@ -364,9 +364,8 @@ proc unsubscribe*(
|
||||
return err("Unsupported subscription type in relay unsubscribe")
|
||||
|
||||
if not node.wakuRelay.isSubscribed(pubsubTopic):
|
||||
error "Invalid API call to `unsubscribe`. Was not subscribed", pubsubTopic
|
||||
return
|
||||
err("Invalid API call to `unsubscribe`. Was not subscribed to: " & $pubsubTopic)
|
||||
warn "No-effect API call to `unsubscribe`. Was not subscribed", pubsubTopic
|
||||
return ok()
|
||||
|
||||
if contentTopicOp.isSome():
|
||||
# Remove this handler only
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user