refactor: remove makeRandomDataset helper function

Remove makeRandomDataset in favor of direct composition with
makeRandomBlocks and makeDataset.

Part of https://github.com/codex-storage/nim-codex/issues/974

Signed-off-by: Chrysostomos Nanakos <chris@include.gr>
This commit is contained in:
Chrysostomos Nanakos 2025-10-02 17:16:59 +03:00
parent 8812d98271
commit f7a3e90414
No known key found for this signature in database
3 changed files with 9 additions and 15 deletions

View File

@ -198,7 +198,7 @@ asyncchecksuite "NetworkStore - dissemination":
await nodes.stop()
test "Should disseminate blocks across large diameter swarm":
let dataset = (await makeRandomDataset(nBlocks = 60, blockSize = 256'nb)).tryGet()
let dataset = makeDataset(await makeRandomBlocks(60 * 256, 256'nb)).tryGet()
nodes = generateNodes(
6,

View File

@ -14,10 +14,6 @@ proc makeRandomBlock*(size: NBytes): Block =
let bytes = newSeqWith(size.int, rand(uint8))
Block.new(bytes).tryGet()
#proc makeRandomBlocks*(nBlocks: int, blockSize: NBytes): seq[Block] =
#for i in 0 ..< nBlocks:
#result.add(makeRandomBlock(blockSize))
proc makeRandomBlocks*(
datasetSize: int, blockSize: NBytes
): Future[seq[Block]] {.async.} =
@ -47,9 +43,3 @@ proc makeDataset*(blocks: seq[Block]): ?!TestDataset =
)
return success((blocks, tree, manifest))
proc makeRandomDataset*(
nBlocks: int, blockSize: NBytes
): Future[?!TestDataset] {.async.} =
let blocks = await makeRandomBlocks(nBlocks * blockSize.int, blockSize)
makeDataset(blocks)

View File

@ -364,8 +364,10 @@ asyncchecksuite "RepoStore":
let
repo = RepoStore.new(repoDs, metaDs, clock = mockClock, quotaMaxBytes =
1000'nb)
(blocks, tree, manifest) =
(await makeRandomDataset(nBlocks = 2, blockSize = 256'nb)).tryGet()
(blocks, tree, manifest) = makeDataset(
await makeRandomBlocks(datasetSize = 2 * 256, blockSize = 256'nb)
)
.tryGet()
blk = blocks[0]
treeCid = tree.rootCid.tryGet()
proof = tree.getProof(0).tryGet()
@ -381,8 +383,10 @@ asyncchecksuite "RepoStore":
let
repo = RepoStore.new(repoDs, metaDs, clock = mockClock, quotaMaxBytes =
1000'nb)
(blocks, tree, manifest) =
(await makeRandomDataset(nBlocks = 2, blockSize = 256'nb)).tryGet()
(blocks, tree, manifest) = makeDataset(
await makeRandomBlocks(datasetSize = 2 * 256, blockSize = 256'nb)
)
.tryGet()
blk = blocks[0]
treeCid = tree.rootCid.tryGet()
proof = tree.getProof(0).tryGet()