mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-06-06 22:19:30 +00:00
fix(tests): use HmacDrbgContext.new() instead of crypto.newRng()
libp2p v2.0.0's `crypto.newRng()` returns the new `Rng` wrapper type, which can't be assigned to a `ref HmacDrbgContext` field. The two test helper modules (tests/testlib/common.nim and tests/test_helpers.nim) both fall in this pattern; rest of the codebase migrated in the prior sweep but these two test-only files were missed because they don't compile during the wakunode2 / chat2mix builds — only when the test target is built (which CI does, locally we didn't until this PR). Same fix pattern as the other newRng → HmacDrbgContext.new() migrations.
This commit is contained in:
parent
d8bbef0c5b
commit
2f24448abd
@ -39,7 +39,10 @@ proc getRng(): ref rand.HmacDrbgContext =
|
||||
# purpose of the tests, it's ok as long as we only use a single thread
|
||||
{.gcsafe.}:
|
||||
if rngVar.rng.isNil:
|
||||
rngVar.rng = crypto.newRng()
|
||||
# libp2p v2.0.0: crypto.newRng() returns the new `Rng` wrapper type;
|
||||
# construct an HmacDrbgContext directly so the field type stays as
|
||||
# `ref HmacDrbgContext` (what bearssl-style consumers expect).
|
||||
rngVar.rng = HmacDrbgContext.new()
|
||||
rngVar.rng
|
||||
|
||||
template rng*(): ref rand.HmacDrbgContext =
|
||||
|
||||
@ -24,7 +24,10 @@ proc getRng(): ref HmacDrbgContext =
|
||||
# purpose of the tests, it's ok as long as we only use a single thread
|
||||
{.gcsafe.}:
|
||||
if rngVar.rng.isNil():
|
||||
rngVar.rng = crypto.newRng()
|
||||
# libp2p v2.0.0: crypto.newRng() returns the new `Rng` wrapper type;
|
||||
# construct an HmacDrbgContext directly so the field type stays as
|
||||
# `ref HmacDrbgContext` (what bearssl-style consumers expect).
|
||||
rngVar.rng = HmacDrbgContext.new()
|
||||
|
||||
rngVar.rng
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user