mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-27 03:49:40 +00:00
* bump nim-libp2p pin to v2.0.0 tag * bump json_rpc to v0.6.1, lsquic to v0.5.1, boringssl to v0.0.8 (latest tags) * add libp2p_mix dep; repoint libp2p/protocols/mix -> libp2p_mix * pin nimble.lock: websock / protobuf_serialization / npeg / jwt * Makefile: add -d:libp2p_quic_support * regenerate nix/deps.nix (adds libp2p_mix, refreshes pins) * migrate rng ref HmacDrbgContext -> libp2p Rng across prod/channels/tests (interface-only; same DRBG) * waku_switch: TransportConfig factory; unified 2.0.0 connection limits (withMaxInOut, withMaxConnections); local MaxConnections * waku_relay/rendezvous/discv5/kademlia: v2.0.0 API (rng, config, ServiceDiscovery rename) * call Service.setup() on post-build switch services (2.0.0 split setup/start) * drop libp2p/utils/semaphore -> chronos AsyncSemaphore * add logos_delivery/waku/compat/option_valueor shim (Option[T] valueOr/withValue, dropped upstream) * add std/options where a transitive re-export was removed * add newStandardSwitch shim (libp2p removed it in 2.0.0); mounts yamux+mplex to match prod muxer * PeerId.random(rng); common.rng()/crypto.newRng(); hoist shared rng (instantiation cleanup) * update expectations for 2.0.0 defaults: DEFAULT_PROTOCOLS += /ipfs/id/push/1.0.0; agent "nim-libp2p" * drop relay reboot/reconnect test (asserted a Switch restart capability that is simply not supported) * fix up a few tests that were flaking on MacOS (libp2p upgrade may have exposed these)
145 lines
3.8 KiB
Nim
145 lines
3.8 KiB
Nim
import logos_delivery/waku/compat/option_valueor
|
|
{.used.}
|
|
|
|
import
|
|
std/json,
|
|
testutils/unittests,
|
|
chronicles,
|
|
chronos,
|
|
libp2p/[crypto/crypto, crypto/secp, multiaddress, switch],
|
|
tests/testlib/[wakucore, wakunode],
|
|
logos_delivery/waku/factory/conf_builder/conf_builder
|
|
|
|
include logos_delivery/waku/factory/waku, logos_delivery/waku/common/enr/typed_record
|
|
|
|
suite "Wakunode2 - Waku":
|
|
test "compilation version should be reported":
|
|
## Given
|
|
let conf = defaultTestWakuConf()
|
|
|
|
let waku = (waitFor Waku.new(conf)).valueOr:
|
|
raiseAssert error
|
|
|
|
## When
|
|
let version = waku.stateInfo.getNodeInfoItem(NodeInfoId.Version)
|
|
|
|
## Then
|
|
check:
|
|
version == git_version
|
|
|
|
suite "Wakunode2 - Waku initialization":
|
|
test "peer persistence setup should be successfully mounted":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
conf.peerPersistence = true
|
|
|
|
let waku = (waitFor Waku.new(conf)).valueOr:
|
|
raiseAssert error
|
|
|
|
check:
|
|
not waku.node.peerManager.storage.isNil()
|
|
|
|
test "node setup is successful with default configuration":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
|
|
## When
|
|
var waku = (waitFor Waku.new(conf)).valueOr:
|
|
raiseAssert error
|
|
|
|
(waitFor waku.start()).isOkOr:
|
|
raiseAssert error
|
|
|
|
## Then
|
|
let node = waku.node
|
|
check:
|
|
not node.isNil()
|
|
node.wakuArchive.isNil()
|
|
node.wakuStore.isNil()
|
|
not node.wakuStoreClient.isNil()
|
|
not node.wakuRendezvous.isNil()
|
|
|
|
## Cleanup
|
|
(waitFor waku.stop()).isOkOr:
|
|
raiseAssert error
|
|
|
|
test "app properly handles dynamic port configuration":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
conf.endpointConf.p2pTcpPort = Port(0)
|
|
|
|
## When
|
|
var waku = (waitFor Waku.new(conf)).valueOr:
|
|
raiseAssert error
|
|
|
|
(waitFor waku.start()).isOkOr:
|
|
raiseAssert error
|
|
|
|
## Then
|
|
let
|
|
node = waku.node
|
|
typedNodeEnr = node.enr.toTyped()
|
|
|
|
assert typedNodeEnr.isOk(), $typedNodeEnr.error
|
|
let tcpPort = typedNodeEnr.value.tcp()
|
|
assert tcpPort.isSome()
|
|
check tcpPort.get() != 0
|
|
|
|
check:
|
|
# Waku started properly
|
|
not node.isNil()
|
|
node.wakuArchive.isNil()
|
|
node.wakuStore.isNil()
|
|
not node.wakuStoreClient.isNil()
|
|
not node.wakuRendezvous.isNil()
|
|
|
|
# DS structures are updated with dynamic ports
|
|
typedNodeEnr.get().tcp.get() != 0
|
|
|
|
## Cleanup
|
|
(waitFor waku.stop()).isOkOr:
|
|
raiseAssert error
|
|
|
|
test "explicit port=0 triggers auto-bind across all services":
|
|
var builder = defaultTestWakuConfBuilder()
|
|
builder.withP2pTcpPort(Port(0))
|
|
builder.discv5Conf.withEnabled(true)
|
|
builder.discv5Conf.withUdpPort(Port(0))
|
|
builder.restServerConf.withEnabled(true)
|
|
builder.restServerConf.withRelayCacheCapacity(50'u32)
|
|
builder.restServerConf.withPort(Port(0))
|
|
builder.metricsServerConf.withEnabled(true)
|
|
builder.metricsServerConf.withHttpPort(Port(0))
|
|
builder.webSocketConf.withEnabled(true)
|
|
builder.webSocketConf.withWebSocketPort(Port(0))
|
|
|
|
let conf = builder.build().valueOr:
|
|
raiseAssert error
|
|
|
|
check:
|
|
conf.endpointConf.p2pTcpPort == Port(0)
|
|
conf.discv5Conf.get().udpPort == Port(0)
|
|
conf.restServerConf.get().port == Port(0)
|
|
conf.metricsServerConf.get().httpPort == Port(0)
|
|
conf.webSocketConf.get().port == Port(0)
|
|
|
|
var waku = (waitFor Waku.new(conf)).valueOr:
|
|
raiseAssert error
|
|
defer:
|
|
(waitFor waku.stop()).isOkOr:
|
|
raiseAssert error
|
|
|
|
(waitFor waku.start()).isOkOr:
|
|
raiseAssert error
|
|
|
|
let portsJson = waku.stateInfo.getNodeInfoItem(NodeInfoId.MyBoundPorts)
|
|
let parsed = parseJson(portsJson)
|
|
|
|
check:
|
|
parsed.kind == JObject
|
|
parsed["tcp"].getInt() != 0
|
|
parsed["webSocket"].getInt() != 0
|
|
parsed["rest"].getInt() != 0
|
|
parsed["discv5Udp"].getInt() != 0
|
|
parsed["metrics"].getInt() != 0
|