From d9592dcbdc0bc1ba4a416d2158da6632d01095a4 Mon Sep 17 00:00:00 2001 From: Fabiana Cecin Date: Wed, 3 Jun 2026 13:41:45 -0300 Subject: [PATCH] Bump fixes * add yamux to our newStandardSwitch to match prod behavior * test: rng instantiation cleanup --- tests/common/test_ratelimit_setting.nim | 7 ++++--- tests/common/test_requestratelimiter.nim | 7 ++++--- tests/testlib/wakucore.nim | 12 ++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/common/test_ratelimit_setting.nim b/tests/common/test_ratelimit_setting.nim index c9385ea57..f41a66b8d 100644 --- a/tests/common/test_ratelimit_setting.nim +++ b/tests/common/test_ratelimit_setting.nim @@ -18,9 +18,10 @@ import ../../waku/common/rate_limit/timed_map let proto = "ProtocolDescriptor" -let conn1 = Connection(peerId: PeerId.random(newRng()).tryGet()) -let conn2 = Connection(peerId: PeerId.random(newRng()).tryGet()) -let conn3 = Connection(peerId: PeerId.random(newRng()).tryGet()) +let rng = newRng() +let conn1 = Connection(peerId: PeerId.random(rng).tryGet()) +let conn2 = Connection(peerId: PeerId.random(rng).tryGet()) +let conn3 = Connection(peerId: PeerId.random(rng).tryGet()) suite "RateLimitSetting": test "Parse rate limit setting - ok": diff --git a/tests/common/test_requestratelimiter.nim b/tests/common/test_requestratelimiter.nim index e3801f853..68e1d36df 100644 --- a/tests/common/test_requestratelimiter.nim +++ b/tests/common/test_requestratelimiter.nim @@ -18,9 +18,10 @@ import ../../waku/common/rate_limit/timed_map let proto = "ProtocolDescriptor" -let conn1 = Connection(peerId: PeerId.random(newRng()).tryGet()) -let conn2 = Connection(peerId: PeerId.random(newRng()).tryGet()) -let conn3 = Connection(peerId: PeerId.random(newRng()).tryGet()) +let rng = newRng() +let conn1 = Connection(peerId: PeerId.random(rng).tryGet()) +let conn2 = Connection(peerId: PeerId.random(rng).tryGet()) +let conn3 = Connection(peerId: PeerId.random(rng).tryGet()) suite "RequestRateLimiter": test "RequestRateLimiter Allow up to main bucket": diff --git a/tests/testlib/wakucore.nim b/tests/testlib/wakucore.nim index c0d59b0fc..d6a0e4e63 100644 --- a/tests/testlib/wakucore.nim +++ b/tests/testlib/wakucore.nim @@ -37,11 +37,23 @@ proc newStandardSwitch*( privKey = Opt.none(libp2p_keys.PrivateKey), addrs: MultiAddress = MultiAddress.init("/ip4/127.0.0.1/tcp/0").get(), ): Switch = + ## Bare libp2p switch for tests. Replaces nim-libp2p's `newStandardSwitch`, + ## removed in 2.0.0. Mirrors the *substrate* of the production switch + ## (`newWakuSwitch`, waku/node/waku_switch.nim): same transport (TCP only — no + ## QUIC yet, like prod), security (Noise), and muxers (yamux first so it is the + ## one negotiated, then mplex). Tests therefore run on the same kernel peers + ## actually use in prod. NB: the removed libp2p `newStandardSwitch` was + ## mplex-only; mounting yamux here is intentional (match prod's muxer) — do not + ## "restore" it to mplex-only. Deliberately omits the prod services (autonat, circuit + ## relay, name resolver, NAT, signed peer record, connection limits): they add + ## port grief, network delays, and nondeterminism with no value to unit tests. + ## For a full-stack node, use newTestWakuNode / newWakuSwitch instead. var b = SwitchBuilder .new() .withRng(common.rng()) .withAddress(addrs) .withTcpTransport() + .withYamux() .withMplex() .withNoise() if privKey.isSome():