add test for blocktypes and inits

This commit is contained in:
Jaremy Creechley 2023-08-02 15:06:46 -07:00
parent bbebc85541
commit 8d2bfddf0d
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
3 changed files with 30 additions and 0 deletions

View File

@ -64,6 +64,7 @@ else:
switch("passC", "-mno-avx512vl")
when getEnv("CODEX_USE_ORC", "") in ["true", "1"]:
echo "Using ORC"
--mm:orc
--deepcopy:on

View File

@ -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)

View File

@ -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