2023-11-15 15:11:36 +00:00
|
|
|
{.used.}
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
import std/[strutils], stew/shims/net as stewNet, chronos
|
2023-11-15 15:11:36 +00:00
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
import ../../../waku/waku_relay, ../../../waku/waku_core, ../testlib/wakucore
|
2023-11-15 15:11:36 +00:00
|
|
|
|
|
|
|
proc noopRawHandler*(): WakuRelayHandler =
|
2024-03-15 23:08:47 +00:00
|
|
|
var handler: WakuRelayHandler
|
|
|
|
handler = proc(topic: PubsubTopic, msg: WakuMessage): Future[void] {.async, gcsafe.} =
|
|
|
|
discard
|
|
|
|
handler
|
2023-11-15 15:11:36 +00:00
|
|
|
|
|
|
|
proc newTestWakuRelay*(switch = newTestSwitch()): Future[WakuRelay] {.async.} =
|
|
|
|
let proto = WakuRelay.new(switch).tryGet()
|
|
|
|
|
|
|
|
let protocolMatcher = proc(proto: string): bool {.gcsafe.} =
|
|
|
|
return proto.startsWith(WakuRelayCodec)
|
|
|
|
|
|
|
|
switch.mount(proto, protocolMatcher)
|
|
|
|
|
|
|
|
return proto
|