fix chunker tests

This commit is contained in:
Dmitriy Ryajov 2021-08-27 16:11:33 -06:00
parent 02095967f9
commit bd86433679
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
3 changed files with 3 additions and 22 deletions

View File

@ -70,7 +70,7 @@ iterator items*(c: Chunker): seq[byte] =
yield chunk
func new(
func new*(
T: type Chunker,
kind = ChunkerType.SizedChunker,
reader: Reader,

View File

@ -1,20 +0,0 @@
import std/sequtils
import pkg/chronos
import pkg/asynctest
import pkg/stew/results
import pkg/dagger/chunker
import pkg/dagger/merkletree
import pkg/stew/byteutils
import pkg/dagger/p2p/rng
import pkg/dagger/blocktype as bt
suite "Data set":
test "Make from Blocks":
let
chunker = newRandomChunker(Rng.instance(), size = 256*3, chunkSize = 256)
blocks = chunker.mapIt( bt.Block.new(it) )
let merkle = MerkleTreeRef.fromBlocks(blocks)

View File

@ -4,7 +4,8 @@ import pkg/dagger/chunker
suite "Chunking":
test "should return proper size chunks":
proc reader(data: var openArray[byte], offset: Natural = 0): int {.gcsafe, closure.} =
proc reader(data: var openArray[byte], offset: Natural = 0): int
{.gcsafe, closure, raises: [Defect].} =
let contents = "1234567890".toBytes
copyMem(addr data[0], unsafeAddr contents[offset], data.len)
return data.len