2024-03-14 18:01:13 +00:00
|
|
|
import
|
|
|
|
stew/results,
|
|
|
|
stew/shims/net,
|
|
|
|
chronos,
|
|
|
|
libp2p/crypto/crypto as libp2p_keys,
|
|
|
|
eth/keys as eth_keys
|
|
|
|
|
|
|
|
import
|
2024-07-05 22:03:38 +00:00
|
|
|
waku/
|
2024-05-13 15:25:44 +00:00
|
|
|
[waku_core/topics, waku_enr, discovery/waku_discv5, node/peer_manager/peer_manager],
|
2024-04-17 19:48:20 +00:00
|
|
|
../testlib/[common, wakucore]
|
2024-03-14 18:01:13 +00:00
|
|
|
|
|
|
|
proc newTestDiscv5*(
|
|
|
|
privKey: libp2p_keys.PrivateKey,
|
|
|
|
bindIp: string,
|
|
|
|
tcpPort: uint16,
|
|
|
|
udpPort: uint16,
|
|
|
|
record: waku_enr.Record,
|
|
|
|
bootstrapRecords = newSeq[waku_enr.Record](),
|
|
|
|
queue = newAsyncEventQueue[SubscriptionEvent](30),
|
2024-05-13 15:25:44 +00:00
|
|
|
peerManager: Option[PeerManager] = none(PeerManager),
|
2024-03-14 18:01:13 +00:00
|
|
|
): WakuDiscoveryV5 =
|
2024-03-15 23:08:47 +00:00
|
|
|
let config = WakuDiscoveryV5Config(
|
|
|
|
privateKey: eth_keys.PrivateKey(privKey.skkey),
|
|
|
|
address: parseIpAddress(bindIp),
|
|
|
|
port: Port(udpPort),
|
|
|
|
bootstrapRecords: bootstrapRecords,
|
|
|
|
)
|
2024-03-14 18:01:13 +00:00
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
let discv5 = WakuDiscoveryV5.new(
|
2024-05-13 15:25:44 +00:00
|
|
|
rng = rng(),
|
|
|
|
conf = config,
|
|
|
|
record = some(record),
|
|
|
|
queue = queue,
|
|
|
|
peerManager = peerManager,
|
2024-03-15 23:08:47 +00:00
|
|
|
)
|
2024-03-14 18:01:13 +00:00
|
|
|
|
|
|
|
return discv5
|