Bump fixes

* add yamux to our newStandardSwitch to match prod behavior
* test: rng instantiation cleanup
This commit is contained in:
Fabiana Cecin 2026-06-03 13:41:45 -03:00
parent 3dfc86262b
commit d9592dcbdc
No known key found for this signature in database
GPG Key ID: BCAB8A55CB51B6C7
3 changed files with 20 additions and 6 deletions

View File

@ -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":

View File

@ -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":

View File

@ -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():