2024-02-06 17:37:42 +01:00
|
|
|
{.used.}
|
|
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
import std/options, chronicles, chronos, libp2p/crypto/crypto
|
2024-02-06 17:37:42 +01:00
|
|
|
|
|
|
|
|
import
|
2024-07-06 03:33:38 +05:30
|
|
|
waku/node/peer_manager,
|
|
|
|
|
waku/waku_core,
|
|
|
|
|
waku/waku_lightpush,
|
|
|
|
|
waku/waku_lightpush/[client, common],
|
2024-07-16 15:46:21 +02:00
|
|
|
waku/common/rate_limit/setting,
|
2025-02-26 16:30:15 +01:00
|
|
|
../testlib/[common, wakucore],
|
|
|
|
|
waku/incentivization/reputation_manager
|
2024-02-06 17:37:42 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc newTestWakuLightpushNode*(
|
2024-04-15 15:28:35 +02:00
|
|
|
switch: Switch,
|
|
|
|
|
handler: PushMessageHandler,
|
|
|
|
|
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
|
2024-03-16 00:08:47 +01:00
|
|
|
): Future[WakuLightPush] {.async.} =
|
2024-02-06 17:37:42 +01:00
|
|
|
let
|
|
|
|
|
peerManager = PeerManager.new(switch)
|
2024-04-15 15:28:35 +02:00
|
|
|
proto = WakuLightPush.new(peerManager, rng, handler, rateLimitSetting)
|
2024-02-06 17:37:42 +01:00
|
|
|
|
|
|
|
|
await proto.start()
|
|
|
|
|
switch.mount(proto)
|
|
|
|
|
|
|
|
|
|
return proto
|
|
|
|
|
|
2025-03-05 12:53:51 +01:00
|
|
|
proc newTestWakuLightpushClient*(
|
|
|
|
|
switch: Switch,
|
|
|
|
|
reputationEnabled: bool = false
|
|
|
|
|
): WakuLightPushClient =
|
2024-02-06 17:37:42 +01:00
|
|
|
let peerManager = PeerManager.new(switch)
|
2025-02-28 23:22:44 +01:00
|
|
|
let reputationManager =
|
2025-03-05 12:53:51 +01:00
|
|
|
if reputationEnabled:
|
2025-02-28 23:22:44 +01:00
|
|
|
some(ReputationManager.new())
|
|
|
|
|
else:
|
|
|
|
|
none(ReputationManager)
|
2025-02-27 16:42:23 +01:00
|
|
|
WakuLightPushClient.new(peerManager, rng, reputationManager)
|