mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-20 08:38:29 +00:00
TestManifest: added test of manifest.removeProtection()
This commit is contained in:
parent
546ec70589
commit
0260635564
@ -54,22 +54,33 @@ suite "Manifest":
|
|||||||
decoded = Manifest.decode(e).tryGet()
|
decoded = Manifest.decode(e).tryGet()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
decoded.blocks == blocks
|
|
||||||
decoded.protected == false
|
decoded.protected == false
|
||||||
|
decoded.cid.tryGet() == manifest.cid.tryGet()
|
||||||
|
decoded.blocks == manifest.blocks
|
||||||
|
|
||||||
test "Should produce a protected manifest":
|
test "Should produce a protected manifest":
|
||||||
let
|
let
|
||||||
blocks = (0..<333).mapIt(
|
N = 333
|
||||||
|
blocks = (0..<N).mapIt(
|
||||||
Block.new(("Block " & $it).toBytes).tryGet().cid
|
Block.new(("Block " & $it).toBytes).tryGet().cid
|
||||||
)
|
)
|
||||||
manifest = Manifest.new(blocks).tryGet()
|
manifest = Manifest.new(blocks).tryGet()
|
||||||
protected = manifest.addProtection(2, 2).tryGet()
|
|
||||||
|
|
||||||
|
let
|
||||||
|
protected = manifest.addProtection(2, 2).tryGet()
|
||||||
check:
|
check:
|
||||||
protected.originalCid == manifest.cid.tryGet()
|
protected.protected == true
|
||||||
protected.blocks[0..<333] == manifest.blocks
|
protected.originalLen == manifest.len
|
||||||
protected.protected == true
|
protected.originalCid == manifest.cid.tryGet()
|
||||||
protected.originalLen == manifest.len
|
protected.blocks[0..<N] == manifest.blocks
|
||||||
|
|
||||||
|
let
|
||||||
|
unprotected = protected.removeProtection().tryGet()
|
||||||
|
check:
|
||||||
|
unprotected.protected == false
|
||||||
|
unprotected.cid.tryGet() == manifest.cid.tryGet()
|
||||||
|
unprotected.blocks == manifest.blocks
|
||||||
|
|
||||||
|
|
||||||
# fill up with empty Cid's
|
# fill up with empty Cid's
|
||||||
for i in protected.rounded..<protected.len:
|
for i in protected.rounded..<protected.len:
|
||||||
@ -94,4 +105,4 @@ suite "Manifest":
|
|||||||
decoded.originalCid == manifest.cid.tryGet()
|
decoded.originalCid == manifest.cid.tryGet()
|
||||||
|
|
||||||
decoded.blocks == protected.blocks
|
decoded.blocks == protected.blocks
|
||||||
decoded.blocks[0..<333] == manifest.blocks
|
decoded.blocks[0..<N] == manifest.blocks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user