2023-11-27 17:33:27 +00:00
|
|
|
{.used.}
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
import std/options, chronos, chronicles, libp2p/crypto/crypto
|
2023-11-27 17:33:27 +00:00
|
|
|
|
|
|
|
import
|
2024-03-15 23:08:47 +00:00
|
|
|
../../../waku/[node/peer_manager, waku_core, waku_store, waku_store/client],
|
|
|
|
../testlib/[common, wakucore]
|
2023-11-27 17:33:27 +00:00
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
proc newTestWakuStore*(
|
|
|
|
switch: Switch, handler: HistoryQueryHandler
|
|
|
|
): Future[WakuStore] {.async.} =
|
2023-11-27 17:33:27 +00:00
|
|
|
let
|
|
|
|
peerManager = PeerManager.new(switch)
|
|
|
|
proto = WakuStore.new(peerManager, rng, handler)
|
|
|
|
|
|
|
|
await proto.start()
|
|
|
|
switch.mount(proto)
|
|
|
|
|
|
|
|
return proto
|
|
|
|
|
|
|
|
proc newTestWakuStoreClient*(switch: Switch): WakuStoreClient =
|
|
|
|
let peerManager = PeerManager.new(switch)
|
|
|
|
WakuStoreClient.new(peerManager, rng)
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
proc computeHistoryCursor*(
|
|
|
|
pubsubTopic: PubsubTopic, message: WakuMessage
|
|
|
|
): HistoryCursor =
|
2023-11-27 17:33:27 +00:00
|
|
|
HistoryCursor(
|
|
|
|
pubsubTopic: pubsubTopic,
|
|
|
|
senderTime: message.timestamp,
|
|
|
|
storeTime: message.timestamp,
|
2024-03-15 23:08:47 +00:00
|
|
|
digest: waku_store.computeDigest(message),
|
2023-11-27 17:33:27 +00:00
|
|
|
)
|