add from nodes test

This commit is contained in:
Dmitriy Ryajov 2023-12-15 16:43:16 -06:00
parent 333492b310
commit f4bc1187ba
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 11 additions and 0 deletions

View File

@ -73,6 +73,17 @@ checksuite "merkletree":
tree.mcodec == sha256
tree.leaves == data
test "Should build from nodes":
let
tree = CodexMerkleTree.init(sha256, leaves = data).tryGet
fromNodes = CodexMerkleTree.fromNodes(
nodes = toSeq(tree.nodes),
nleaves = tree.leavesCount).tryGet
check:
tree.mcodec == sha256
tree == fromNodes
let
mhash = sha256.getMhash().tryGet
zero: seq[byte] = newSeq[byte](mhash.size)