2022-01-10 15:32:56 +00:00
|
|
|
import std/sequtils
|
|
|
|
|
|
|
|
import pkg/chronos
|
|
|
|
import pkg/questionable/results
|
|
|
|
import pkg/asynctest
|
2022-05-19 19:56:03 +00:00
|
|
|
import pkg/codex/chunker
|
|
|
|
import pkg/codex/blocktype as bt
|
|
|
|
import pkg/codex/manifest
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
import ./helpers
|
2023-11-14 12:02:17 +00:00
|
|
|
import ./examples
|
2022-01-10 15:32:56 +00:00
|
|
|
|
2023-06-22 18:01:21 +00:00
|
|
|
checksuite "Manifest":
|
2023-12-12 08:11:54 +00:00
|
|
|
let
|
|
|
|
manifest = Manifest.new(
|
|
|
|
treeCid = Cid.example,
|
|
|
|
blockSize = 1.MiBs,
|
|
|
|
datasetSize = 100.MiBs
|
|
|
|
)
|
|
|
|
protectedManifest = Manifest.new(
|
|
|
|
manifest = manifest,
|
|
|
|
treeCid = Cid.example,
|
|
|
|
datasetSize = 200.MiBs,
|
|
|
|
eck = 10,
|
|
|
|
ecM = 10
|
|
|
|
)
|
|
|
|
verifiableManifest = Manifest.new(
|
|
|
|
manifest = protectedManifest,
|
|
|
|
verificationRoot = Cid.example,
|
|
|
|
slotRoots = @[Cid.example, Cid.example]
|
|
|
|
).tryGet()
|
|
|
|
|
|
|
|
proc encodeDecode(manifest: Manifest): Manifest =
|
|
|
|
let e = manifest.encode().tryGet()
|
|
|
|
Manifest.decode(e).tryGet()
|
2022-01-10 15:32:56 +00:00
|
|
|
|
2023-12-12 08:11:54 +00:00
|
|
|
test "Should encode/decode to/from base manifest":
|
|
|
|
check:
|
|
|
|
encodeDecode(manifest) == manifest
|
2022-01-10 15:32:56 +00:00
|
|
|
|
2023-12-12 08:11:54 +00:00
|
|
|
test "Should encode/decode to/from protected manifest":
|
2022-04-05 00:46:13 +00:00
|
|
|
check:
|
2023-12-12 08:11:54 +00:00
|
|
|
encodeDecode(protectedManifest) == protectedManifest
|
2022-04-05 00:46:13 +00:00
|
|
|
|
2023-12-12 08:11:54 +00:00
|
|
|
test "Should encode/decode to/from verifiable manifest":
|
|
|
|
check:
|
|
|
|
encodeDecode(verifiableManifest) == verifiableManifest
|