nwaku/tests/v2/test_waku_filter.nim

292 lines
9.2 KiB
Nim
Raw Normal View History

Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
{.used.}
import
2022-11-04 09:52:08 +00:00
std/[options, tables],
testutils/unittests,
chronicles,
chronos,
libp2p/crypto/crypto
import
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
../../waku/v2/node/peer_manager/peer_manager,
../../waku/v2/protocol/waku_message,
../../waku/v2/protocol/waku_filter,
../../waku/v2/protocol/waku_filter/client,
./utils,
./testlib/common,
./testlib/switch
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
proc newTestWakuFilterNode(switch: Switch, timeout: Duration = 2.hours): Future[WakuFilter] {.async.} =
let
peerManager = PeerManager.new(switch)
rng = crypto.newRng()
proto = WakuFilter.new(peerManager, rng, timeout)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
await proto.start()
switch.mount(proto)
return proto
proc newTestWakuFilterClient(switch: Switch): Future[WakuFilterClient] {.async.} =
let
peerManager = PeerManager.new(switch)
rng = crypto.newRng()
proto = WakuFilterClient.new(peerManager, rng)
await proto.start()
switch.mount(proto)
return proto
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
# TODO: Extend test coverage
suite "Waku Filter":
asyncTest "should forward messages to client after subscribed":
## Setup
let
serverSwitch = newTestSwitch()
clientSwitch = newTestSwitch()
await allFutures(serverSwitch.start(), clientSwitch.start())
let
server = await newTestWakuFilterNode(serverSwitch)
client = await newTestWakuFilterClient(clientSwitch)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## Given
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()
let pushHandlerFuture = newFuture[(string, WakuMessage)]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
pushHandlerFuture.complete((pubsubTopic, message))
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
let
pubsubTopic = DefaultPubsubTopic
contentTopic = "test-content-topic"
msg = fakeWakuMessage(contentTopic=contentTopic)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## When
require (await client.subscribe(pubsubTopic, contentTopic, pushHandler, peer=serverAddr)).isOk()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
# WARN: Sleep necessary to avoid a race condition between the subscription and the handle message proc
await sleepAsync(5.milliseconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
await server.handleMessage(pubsubTopic, msg)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
require await pushHandlerFuture.withTimeout(5.seconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## Then
let (pushedMsgPubsubTopic, pushedMsg) = pushHandlerFuture.read()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
check:
pushedMsgPubsubTopic == pubsubTopic
pushedMsg == msg
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## Cleanup
await allFutures(clientSwitch.stop(), serverSwitch.stop())
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
asyncTest "should not forward messages to client after unsuscribed":
## Setup
let
serverSwitch = newTestSwitch()
clientSwitch = newTestSwitch()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
await allFutures(serverSwitch.start(), clientSwitch.start())
let
server = await newTestWakuFilterNode(serverSwitch)
client = await newTestWakuFilterClient(clientSwitch)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## Given
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
pushHandlerFuture.complete()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
let
pubsubTopic = DefaultPubsubTopic
contentTopic = "test-content-topic"
msg = fakeWakuMessage(contentTopic=contentTopic)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## When
require (await client.subscribe(pubsubTopic, contentTopic, pushHandler, peer=serverAddr)).isOk()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
# WARN: Sleep necessary to avoid a race condition between the subscription and the handle message proc
await sleepAsync(5.milliseconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
await server.handleMessage(pubsubTopic, msg)
require await pushHandlerFuture.withTimeout(1.seconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
# Reset to test unsubscribe
pushHandlerFuture = newFuture[void]()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
require (await client.unsubscribe(pubsubTopic, contentTopic, peer=serverAddr)).isOk()
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
# WARN: Sleep necessary to avoid a race condition between the unsubscription and the handle message proc
await sleepAsync(5.milliseconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
await server.handleMessage(pubsubTopic, msg)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
## Then
let handlerWasCalledAfterUnsubscription = await pushHandlerFuture.withTimeout(1.seconds)
Fix redundant use of content topics (#528) made resulting changes to waku_filter Made changes to wakunode2, filter_api and waku_filter Update waku v2 test scripts referencing Content Topics Update ContentFilter in chat example Remove unneccesary loops from filter api closes #496 Apply keep-alive for chat2 (#525) Makes the arguments of the store jsonrpc api optional (#526) * makes pubsubTopic filter optional * makes contentFilter optional * append Option Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Update Changelog with changes to ContentFilter Fix indentation and code semantics Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix ContentFilter Schema in wakunode test script Enables perssist-message flag in the store protocol for wakunode2 (#519) * enables perssistmessage flag * disables in memory storage when persist-messages is false * adds the persistMessages input to the mountStore * defaults the store flag to true * adds the missing argument * persists messages in memory conditioned to the persistMessages flag * adds persistmessages flag to the config_bridge * defaults persistmessages to true * defaults the store flag to true and persist-messages to false * updates store.md * updates chat2 instructions about --store flag * removes --store flag from chat2 command execution Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Fix: light-mode relay for all light protocols (#529) * Fix: light-mode relay for all light protocols * Clear up confusing use of overloaded concepts Fix resulting issues after merge
2021-05-05 08:34:40 +00:00
check:
not handlerWasCalledAfterUnsubscription
## Cleanup
await allFutures(clientSwitch.stop(), serverSwitch.stop())
asyncTest "peer subscription should be dropped if connection fails for second time after the timeout has elapsed":
## Setup
let
serverSwitch = newTestSwitch()
clientSwitch = newTestSwitch()
await allFutures(serverSwitch.start(), clientSwitch.start())
let
server = await newTestWakuFilterNode(serverSwitch, timeout=200.milliseconds)
client = await newTestWakuFilterClient(clientSwitch)
## Given
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()
var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
pushHandlerFuture.complete()
let
pubsubTopic = DefaultPubsubTopic
contentTopic = "test-content-topic"
msg = fakeWakuMessage(contentTopic=contentTopic)
## When
require (await client.subscribe(pubsubTopic, contentTopic, pushHandler, peer=serverAddr)).isOk()
# WARN: Sleep necessary to avoid a race condition between the unsubscription and the handle message proc
await sleepAsync(5.milliseconds)
await server.handleMessage(DefaultPubsubTopic, msg)
# Push handler should be called
require await pushHandlerFuture.withTimeout(1.seconds)
# Stop client node to test timeout unsubscription
await clientSwitch.stop()
await sleepAsync(5.milliseconds)
# First failure should not remove the subscription
await server.handleMessage(DefaultPubsubTopic, msg)
let
subscriptionsBeforeTimeout = server.subscriptions.len()
failedPeersBeforeTimeout = server.failedPeers.len()
# Wait for the configured peer connection timeout to elapse (200ms)
await sleepAsync(200.milliseconds)
# Second failure should remove the subscription
await server.handleMessage(DefaultPubsubTopic, msg)
let
subscriptionsAfterTimeout = server.subscriptions.len()
failedPeersAfterTimeout = server.failedPeers.len()
## Then
check:
subscriptionsBeforeTimeout == 1
failedPeersBeforeTimeout == 1
subscriptionsAfterTimeout == 0
failedPeersAfterTimeout == 0
## Cleanup
await serverSwitch.stop()
asyncTest "peer subscription should not be dropped if connection recovers before timeout elapses":
## Setup
let
serverSwitch = newTestSwitch()
clientSwitch = newTestSwitch()
await allFutures(serverSwitch.start(), clientSwitch.start())
let
server = await newTestWakuFilterNode(serverSwitch, timeout=200.milliseconds)
client = await newTestWakuFilterClient(clientSwitch)
## Given
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()
var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
pushHandlerFuture.complete()
let
pubsubTopic = DefaultPubsubTopic
contentTopic = "test-content-topic"
msg = fakeWakuMessage(contentTopic=contentTopic)
## When
require (await client.subscribe(pubsubTopic, contentTopic, pushHandler, peer=serverAddr)).isOk()
# WARN: Sleep necessary to avoid a race condition between the unsubscription and the handle message proc
await sleepAsync(5.milliseconds)
await server.handleMessage(DefaultPubsubTopic, msg)
# Push handler should be called
require await pushHandlerFuture.withTimeout(1.seconds)
let
subscriptionsBeforeFailure = server.subscriptions.len()
failedPeersBeforeFailure = server.failedPeers.len()
# Stop switch to test unsubscribe
await clientSwitch.stop()
await sleepAsync(5.milliseconds)
# First failure should add to failure list
await server.handleMessage(DefaultPubsubTopic, msg)
pushHandlerFuture = newFuture[void]()
let
subscriptionsAfterFailure = server.subscriptions.len()
failedPeersAfterFailure = server.failedPeers.len()
await sleepAsync(100.milliseconds)
2022-01-14 09:25:01 +00:00
# Start switch with same key as before
let clientSwitch2 = newTestSwitch(
some(clientSwitch.peerInfo.privateKey),
some(clientSwitch.peerInfo.addrs[0])
)
await clientSwitch2.start()
await client.start()
clientSwitch2.mount(client)
2022-01-14 09:25:01 +00:00
# If push succeeds after failure, the peer should removed from failed peers list
await server.handleMessage(DefaultPubsubTopic, msg)
let handlerShouldHaveBeenCalled = await pushHandlerFuture.withTimeout(1.seconds)
let
subscriptionsAfterSuccessfulConnection = server.subscriptions.len()
failedPeersAfterSuccessfulConnection = server.failedPeers.len()
## Then
check:
handlerShouldHaveBeenCalled
check:
subscriptionsBeforeFailure == 1
subscriptionsAfterFailure == 1
subscriptionsAfterSuccessfulConnection == 1
check:
failedPeersBeforeFailure == 0
failedPeersAfterFailure == 1
failedPeersAfterSuccessfulConnection == 0
## Cleanup
await allFutures(clientSwitch2.stop(), serverSwitch.stop())