From 8d2bfddf0dcbf5d8840dd39515b0131e5fdd9ed6 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Wed, 2 Aug 2023 15:06:46 -0700 Subject: [PATCH] add test for blocktypes and inits --- config.nims | 1 + tests/codex/testblocktypes.nim | 28 ++++++++++++++++++++++++++++ tests/testCodex.nim | 1 + 3 files changed, 30 insertions(+) create mode 100644 tests/codex/testblocktypes.nim diff --git a/config.nims b/config.nims index f94f5d70..28cea98e 100644 --- a/config.nims +++ b/config.nims @@ -64,6 +64,7 @@ else: switch("passC", "-mno-avx512vl") when getEnv("CODEX_USE_ORC", "") in ["true", "1"]: + echo "Using ORC" --mm:orc --deepcopy:on diff --git a/tests/codex/testblocktypes.nim b/tests/codex/testblocktypes.nim new file mode 100644 index 00000000..e94cc2f7 --- /dev/null +++ b/tests/codex/testblocktypes.nim @@ -0,0 +1,28 @@ +import pkg/libp2p/[cid, multicodec, multihash] +import pkg/codex/blocktype +from ./helpers import `==` +import unittest2 + +suite "Blocktypes": + setup: + let cid0 = Cid.init("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n").get() + test "emptyCids should work": + let sha2 = multiCodec("sha2-256") + let cid = emptyCid(CIDv0, sha2) + + check cid.isOk + check cid.get() == cid0 + + test "emptyDigest should work": + let sha2 = multiCodec("sha2-256") + let dig = emptyDigest(CIDv0, sha2) + + check dig.isOk + check dig.get() == cid0.mhash.get() + + test "emptyBlock should work": + let sha2 = multiCodec("sha2-256") + let blk = emptyBlock(CIDv0, sha2) + + check blk.isOk + check blk.get() == Block(cid: cid0) diff --git a/tests/testCodex.nim b/tests/testCodex.nim index 4f59e747..23884d53 100644 --- a/tests/testCodex.nim +++ b/tests/testCodex.nim @@ -9,6 +9,7 @@ import ./codex/teststorestream import ./codex/testpurchasing import ./codex/testsales import ./codex/testerasure +import ./codex/testblocktypes import ./codex/testproving import ./codex/testutils import ./codex/testclock