mirror of https://github.com/waku-org/nwaku.git
fix: Fix test for filter client receiving messages after restart (#2360)
This commit is contained in:
parent
f841454edc
commit
7de91d92bb
|
@ -37,6 +37,7 @@ import
|
||||||
suite "Waku Filter - End to End":
|
suite "Waku Filter - End to End":
|
||||||
var client {.threadvar.}: WakuNode
|
var client {.threadvar.}: WakuNode
|
||||||
var clientPeerId {.threadvar.}: PeerId
|
var clientPeerId {.threadvar.}: PeerId
|
||||||
|
var clientClone {.threadvar.}: WakuNode
|
||||||
var server {.threadvar.}: WakuNode
|
var server {.threadvar.}: WakuNode
|
||||||
var serverRemotePeerInfo {.threadvar.}: RemotePeerInfo
|
var serverRemotePeerInfo {.threadvar.}: RemotePeerInfo
|
||||||
var pubsubTopic {.threadvar.}: PubsubTopic
|
var pubsubTopic {.threadvar.}: PubsubTopic
|
||||||
|
@ -60,20 +61,25 @@ suite "Waku Filter - End to End":
|
||||||
serverKey = generateSecp256k1Key()
|
serverKey = generateSecp256k1Key()
|
||||||
clientKey = generateSecp256k1Key()
|
clientKey = generateSecp256k1Key()
|
||||||
|
|
||||||
server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0))
|
server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(23450))
|
||||||
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))
|
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(23451))
|
||||||
|
clientClone = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(23451)) # Used for testing client restarts
|
||||||
|
|
||||||
waitFor allFutures(server.start(), client.start())
|
await allFutures(server.start(), client.start())
|
||||||
|
|
||||||
waitFor server.mountFilter()
|
await server.mountFilter()
|
||||||
waitFor client.mountFilterClient()
|
await client.mountFilterClient()
|
||||||
|
|
||||||
client.wakuFilterClient.registerPushHandler(messagePushHandler)
|
client.wakuFilterClient.registerPushHandler(messagePushHandler)
|
||||||
serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
|
serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
|
||||||
clientPeerId = client.peerInfo.toRemotePeerInfo().peerId
|
clientPeerId = client.peerInfo.toRemotePeerInfo().peerId
|
||||||
|
|
||||||
|
# Prepare the clone but do not start it
|
||||||
|
await clientClone.mountFilterClient()
|
||||||
|
clientClone.wakuFilterClient.registerPushHandler(messagePushHandler)
|
||||||
|
|
||||||
asyncTeardown:
|
asyncTeardown:
|
||||||
waitFor allFutures(client.stop(), server.stop())
|
await allFutures(client.stop(), clientClone.stop(), server.stop())
|
||||||
|
|
||||||
asyncTest "Client Node receives Push from Server Node, via Filter":
|
asyncTest "Client Node receives Push from Server Node, via Filter":
|
||||||
# When a client node subscribes to a filter node
|
# When a client node subscribes to a filter node
|
||||||
|
@ -142,8 +148,8 @@ suite "Waku Filter - End to End":
|
||||||
serverKey = generateSecp256k1Key()
|
serverKey = generateSecp256k1Key()
|
||||||
server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0))
|
server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0))
|
||||||
|
|
||||||
waitFor server.start()
|
await server.start()
|
||||||
waitFor server.mountRelay()
|
await server.mountRelay()
|
||||||
|
|
||||||
let serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
|
let serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
|
||||||
|
|
||||||
|
@ -155,7 +161,7 @@ suite "Waku Filter - End to End":
|
||||||
# Then the subscription is successful
|
# Then the subscription is successful
|
||||||
check (not subscribeResponse.isOk())
|
check (not subscribeResponse.isOk())
|
||||||
|
|
||||||
xasyncTest "Filter Client Node can receive messages after subscribing and restarting, via Filter":
|
asyncTest "Filter Client Node can receive messages after subscribing and restarting, via Filter":
|
||||||
# Given a valid filter subscription
|
# Given a valid filter subscription
|
||||||
let subscribeResponse = await client.filterSubscribe(
|
let subscribeResponse = await client.filterSubscribe(
|
||||||
some(pubsubTopic), contentTopicSeq, serverRemotePeerInfo
|
some(pubsubTopic), contentTopicSeq, serverRemotePeerInfo
|
||||||
|
@ -165,9 +171,8 @@ suite "Waku Filter - End to End":
|
||||||
server.wakuFilter.subscriptions.subscribedPeerCount() == 1
|
server.wakuFilter.subscriptions.subscribedPeerCount() == 1
|
||||||
|
|
||||||
# And the client node reboots
|
# And the client node reboots
|
||||||
waitFor client.stop()
|
await client.stop()
|
||||||
waitFor client.start()
|
await clientClone.start() # Mimic restart by starting the clone
|
||||||
client.mountFilterClient()
|
|
||||||
|
|
||||||
# When a message is sent to the subscribed content topic, via Filter; without refreshing the subscription
|
# When a message is sent to the subscribed content topic, via Filter; without refreshing the subscription
|
||||||
let msg = fakeWakuMessage(contentTopic=contentTopic)
|
let msg = fakeWakuMessage(contentTopic=contentTopic)
|
||||||
|
@ -192,9 +197,8 @@ suite "Waku Filter - End to End":
|
||||||
server.wakuFilter.subscriptions.subscribedPeerCount() == 1
|
server.wakuFilter.subscriptions.subscribedPeerCount() == 1
|
||||||
|
|
||||||
# And the client node reboots
|
# And the client node reboots
|
||||||
waitFor client.stop()
|
await client.stop()
|
||||||
waitFor client.start()
|
await clientClone.start() # Mimic restart by starting the clone
|
||||||
discard client.mountFilterClient()
|
|
||||||
|
|
||||||
# When a message is sent to the subscribed content topic, via Relay
|
# When a message is sent to the subscribed content topic, via Relay
|
||||||
let msg = fakeWakuMessage(contentTopic=contentTopic)
|
let msg = fakeWakuMessage(contentTopic=contentTopic)
|
||||||
|
@ -204,7 +208,7 @@ suite "Waku Filter - End to End":
|
||||||
check (not await pushHandlerFuture.withTimeout(FUTURE_TIMEOUT))
|
check (not await pushHandlerFuture.withTimeout(FUTURE_TIMEOUT))
|
||||||
|
|
||||||
# Given the client refreshes the subscription
|
# Given the client refreshes the subscription
|
||||||
let subscribeResponse2 = await client.filterSubscribe(
|
let subscribeResponse2 = await clientClone.filterSubscribe(
|
||||||
some(pubsubTopic), contentTopicSeq, serverRemotePeerInfo
|
some(pubsubTopic), contentTopicSeq, serverRemotePeerInfo
|
||||||
)
|
)
|
||||||
check:
|
check:
|
||||||
|
|
Loading…
Reference in New Issue