2024-03-14 19:01:13 +01:00
|
|
|
import
|
|
|
|
stew/results,
|
|
|
|
stew/shims/net,
|
|
|
|
chronos,
|
|
|
|
libp2p/crypto/crypto as libp2p_keys,
|
|
|
|
eth/keys as eth_keys
|
|
|
|
|
|
|
|
import
|
2024-04-17 21:48:20 +02:00
|
|
|
../../../waku/[waku_core/topics, waku_enr, discovery/waku_discv5],
|
|
|
|
../testlib/[common, wakucore]
|
2024-03-14 19:01:13 +01: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),
|
|
|
|
): WakuDiscoveryV5 =
|
2024-03-16 00:08:47 +01:00
|
|
|
let config = WakuDiscoveryV5Config(
|
|
|
|
privateKey: eth_keys.PrivateKey(privKey.skkey),
|
|
|
|
address: parseIpAddress(bindIp),
|
|
|
|
port: Port(udpPort),
|
|
|
|
bootstrapRecords: bootstrapRecords,
|
|
|
|
)
|
2024-03-14 19:01:13 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
let discv5 = WakuDiscoveryV5.new(
|
|
|
|
rng = rng(), conf = config, record = some(record), queue = queue
|
|
|
|
)
|
2024-03-14 19:01:13 +01:00
|
|
|
|
|
|
|
return discv5
|