diff --git a/dagger/manifest.nim b/dagger/manifest.nim index 5e25fae2..bdcce58a 100644 --- a/dagger/manifest.nim +++ b/dagger/manifest.nim @@ -79,9 +79,6 @@ proc cid*(b: var BlocksManifest): ?!Cid = var stack: seq[MultiHash] - if stack.len == 1: - stack.add((? EmptyDigests[b.version][b.hcodec].catch)) - for cid in b.blocks: stack.add(? cid.mhash.mapFailure) @@ -95,7 +92,11 @@ proc cid*(b: var BlocksManifest): ?!Cid = stack.add(mh) if stack.len == 1: - let cid = ? Cid.init(b.version, b.codec, stack[0]).mapFailure + let cid = ? Cid.init( + b.version, + b.codec, + (? EmptyDigests[b.version][b.hcodec].catch)) + .mapFailure b.htree = cid.some return cid.success diff --git a/tests/dagger/testmanifest.nim b/tests/dagger/testmanifest.nim index d2f4cf33..70424f4f 100644 --- a/tests/dagger/testmanifest.nim +++ b/tests/dagger/testmanifest.nim @@ -28,17 +28,17 @@ suite "Manifest": fail() let - checksum = @[18.byte, 32, 14, 78, 178, 161, - 50, 175, 26, 57, 68, 6, 163, 128, - 19, 131, 212, 203, 93, 98, 219, - 34, 243, 217, 132, 191, 86, 255, - 171, 160, 77, 167, 91, 145] + checksum = @[18.byte, 32, 227, 176, 196, 66, 152, + 252, 28, 20, 154, 251, 244, 200, 153, + 111, 185, 36, 39, 174, 65, 228, 100, + 155, 147, 76, 164, 149, 153, 27, 120, + 82, 184, 85] var mh: MultiHash check MultiHash.decode(checksum, mh).get() > 0 let checkSumCid = Cid.init(manifest.version, manifest.codec, mh).get() - check checkSumCid == !(manifest.cid) + check checkSumCid == manifest.cid.get() test "Should encode/decode to/from manifest": let