From 06bb21bfc72f74452ec66aaa6cbe58f2f7478f54 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 14 Nov 2023 10:53:06 -0600 Subject: [PATCH] backport changes from fix-erasure-tests (#618) --- tests/codex/testerasure.nim | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/codex/testerasure.nim b/tests/codex/testerasure.nim index 41732a1a..fa034001 100644 --- a/tests/codex/testerasure.nim +++ b/tests/codex/testerasure.nim @@ -1,4 +1,5 @@ import std/sequtils +import std/sugar import pkg/asynctest import pkg/chronos @@ -10,6 +11,7 @@ import pkg/codex/manifest import pkg/codex/stores import pkg/codex/blocktype as bt import pkg/codex/rng +import pkg/codex/utils import ./helpers @@ -42,7 +44,7 @@ asyncchecksuite "Erasure encode/decode": check: encoded.blocksCount mod (buffers + parity) == 0 - encoded.rounded == (manifest.blocksCount + (buffers - (manifest.blocksCount mod buffers))) + encoded.rounded == roundUp(manifest.blocksCount, buffers) encoded.steps == encoded.rounded div buffers return encoded @@ -55,14 +57,14 @@ asyncchecksuite "Erasure encode/decode": let encoded = await encode(buffers, parity) var - column = rng.rand((encoded.blocksCount - 1) div encoded.steps) # random column + column = rng.rand((encoded.blocksCount div encoded.steps) - 1) # random column dropped: seq[int] for _ in 0..