diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index bd1d837b6..e46a8c894 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -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 = diff --git a/tests/testlib/common.nim b/tests/testlib/common.nim index 216320692..6d5340668 100644 --- a/tests/testlib/common.nim +++ b/tests/testlib/common.nim @@ -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