From 03ef02a2ff8f8491ef7c426dc610a9ba033a5092 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Thu, 4 Jun 2026 18:05:52 +0530 Subject: [PATCH] fix(tests): wrap HmacDrbgContext via newBearSslRng for libp2p v2.0.0 libp2p v2.0.0's 3-arg `random(T, scheme, rng)` overload now takes the `Rng` wrapper type instead of `var HmacDrbgContext`. My prior `common.rng()[]` (deref) attempt resolves to `HmacDrbgContext` which no longer matches. Wrap our existing `ref HmacDrbgContext` (from `common.rng`) via `newBearSslRng` to get an `Rng` value, satisfying the new signature without re-seeding a fresh PRNG on every key generation. --- tests/testlib/wakucore.nim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/testlib/wakucore.nim b/tests/testlib/wakucore.nim index 92e470bee..fd05010c2 100644 --- a/tests/testlib/wakucore.nim +++ b/tests/testlib/wakucore.nim @@ -22,17 +22,17 @@ proc ts*(offset = 0, origin = now()): Timestamp = # Switch proc generateEcdsaKey*(): libp2p_keys.PrivateKey = - # libp2p v2.0.0 also exports a `rng` symbol (returns the new `Rng` wrapper), - # so the unqualified `rng[]` here is ambiguous against our local - # `common.rng` template. Qualify explicitly to keep using the - # `ref HmacDrbgContext` that `PrivateKey.random` expects. - libp2p_keys.PrivateKey.random(ECDSA, common.rng()[]).get() + # libp2p v2.0.0's 3-arg `random(T, scheme, rng)` overload now takes the + # `Rng` wrapper instead of `var HmacDrbgContext`. Wrap our existing + # `ref HmacDrbgContext` (from `common.rng`) via `newBearSslRng` to satisfy + # the new signature without re-seeding a fresh PRNG each call. + libp2p_keys.PrivateKey.random(ECDSA, newBearSslRng(common.rng())).get() proc generateEcdsaKeyPair*(): libp2p_keys.KeyPair = - libp2p_keys.KeyPair.random(ECDSA, common.rng()[]).get() + libp2p_keys.KeyPair.random(ECDSA, newBearSslRng(common.rng())).get() proc generateSecp256k1Key*(): libp2p_keys.PrivateKey = - libp2p_keys.PrivateKey.random(Secp256k1, common.rng()[]).get() + libp2p_keys.PrivateKey.random(Secp256k1, newBearSslRng(common.rng())).get() proc ethSecp256k1Key*(hex: string): eth_keys.PrivateKey = eth_keys.PrivateKey.fromHex(hex).get()