Skip to content

Commit

Permalink
feat(postgresql): 1st commit to async sql (waku_archive/driver...) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status authored May 25, 2023
1 parent 3c2d289 commit 59ca03a
Show file tree
Hide file tree
Showing 23 changed files with 526 additions and 486 deletions.
2 changes: 1 addition & 1 deletion apps/chat2/chat2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
await node.mountFilterClient()
node.peerManager.addServicePeer(peerInfo.value, WakuFilterCodec)

proc filterHandler(pubsubTopic: PubsubTopic, msg: WakuMessage) {.gcsafe.} =
proc filterHandler(pubsubTopic: PubsubTopic, msg: WakuMessage) {.async, gcsafe, closure.} =
trace "Hit filter handler", contentTopic=msg.contentTopic
chat.printReceivedMessage(msg)

Expand Down
8 changes: 4 additions & 4 deletions tests/v2/test_waku_filter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ suite "Waku Filter":
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()

let pushHandlerFuture = newFuture[(string, WakuMessage)]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.async, gcsafe, closure.} =
pushHandlerFuture.complete((pubsubTopic, message))

let
Expand Down Expand Up @@ -97,7 +97,7 @@ suite "Waku Filter":
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()

var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.async, gcsafe, closure.} =
pushHandlerFuture.complete()

let
Expand Down Expand Up @@ -149,7 +149,7 @@ suite "Waku Filter":
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()

var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.async, gcsafe, closure.} =
pushHandlerFuture.complete()

let
Expand Down Expand Up @@ -214,7 +214,7 @@ suite "Waku Filter":
let serverAddr = serverSwitch.peerInfo.toRemotePeerInfo()

var pushHandlerFuture = newFuture[void]()
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.gcsafe, closure.} =
proc pushHandler(pubsubTopic: PubsubTopic, message: WakuMessage) {.async, gcsafe, closure.} =
pushHandlerFuture.complete()

let
Expand Down
16 changes: 8 additions & 8 deletions tests/v2/test_wakunode_filter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ suite "WakuNode - Filter":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0))

await allFutures(server.start(), client.start())
waitFor allFutures(server.start(), client.start())

await server.mountFilter()
await client.mountFilterClient()
waitFor server.mountFilter()
waitFor client.mountFilterClient()

## Given
let serverPeerInfo = server.peerInfo.toRemotePeerInfo()
Expand All @@ -39,18 +39,18 @@ suite "WakuNode - Filter":
message = fakeWakuMessage(contentTopic=contentTopic)

var filterPushHandlerFut = newFuture[(PubsubTopic, WakuMessage)]()
proc filterPushHandler(pubsubTopic: PubsubTopic, msg: WakuMessage) {.gcsafe, closure.} =
proc filterPushHandler(pubsubTopic: PubsubTopic, msg: WakuMessage) {.async, gcsafe, closure.} =
filterPushHandlerFut.complete((pubsubTopic, msg))

## When
await client.filterSubscribe(pubsubTopic, contentTopic, filterPushHandler, peer=serverPeerInfo)

# Wait for subscription to take effect
await sleepAsync(100.millis)
waitFor sleepAsync(100.millis)

await server.filterHandleMessage(pubSubTopic, message)
waitFor server.filterHandleMessage(pubSubTopic, message)

require await filterPushHandlerFut.withTimeout(5.seconds)
require waitFor filterPushHandlerFut.withTimeout(5.seconds)

## Then
check filterPushHandlerFut.completed()
Expand All @@ -60,4 +60,4 @@ suite "WakuNode - Filter":
filterMessage == message

## Cleanup
await allFutures(client.stop(), server.stop())
waitFor allFutures(client.stop(), server.stop())
Loading

0 comments on commit 59ca03a

Please sign in to comment.