fix tests

This commit is contained in:
Dmitriy Ryajov 2023-12-22 17:16:38 -06:00
parent 0b47e45e91
commit f15f3f5f27
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 8 additions and 9 deletions

View File

@ -51,7 +51,7 @@ suite "Test CodexTree":
var tree = CodexTree.init(leaves = expectedLeaves)
check:
tree.isOk
tree.get().leaves == expectedLeaves.mapIt( it.bytes )
tree.get().leaves == expectedLeaves.mapIt( it.digestBytes )
tree.get().mcodec == sha256
test "Should build tree from cid leaves":
@ -68,10 +68,10 @@ suite "Test CodexTree":
check:
tree.isOk
tree.get().leaves == expectedLeaves.mapIt( it.mhash.tryGet.bytes )
tree.get().leaves == expectedLeaves.mapIt( it.mhash.tryGet.digestBytes )
tree.get().mcodec == sha256
test "Should build from raw bytes (should not hash leaves)":
test "Should build from raw digestbytes (should not hash leaves)":
let
tree = CodexTree.init(sha256, leaves = data).tryGet
@ -91,7 +91,7 @@ suite "Test CodexTree":
tree == fromNodes
let
mhash = sha256.getMhash().tryGet
mhash = sha256.mhash().tryGet
zero: seq[byte] = newSeq[byte](mhash.size)
compress = proc(x, y: seq[byte], key: ByteTreeKey): seq[byte] =
compress(x, y, key, mhash).tryGet

View File

@ -29,11 +29,10 @@ const
"0000000000000000000000000000006".toBytes,
"0000000000000000000000000000007".toBytes,
"0000000000000000000000000000008".toBytes,
"0000000000000000000000000000009".toBytes,
"0000000000000000000000000000010".toBytes,
"0000000000000000000000000000009".toBytes, # note one less to account for padding of field elements
]
suite "Test CodexTree":
suite "Test Poseidon2Tree":
var
expectedLeaves: seq[Poseidon2Hash]
@ -54,8 +53,8 @@ suite "Test CodexTree":
test "Init tree from byte leaves":
let
tree = Poseidon2Tree.init(
leaves = data.mapIt(
array[31, byte].initCopyFrom( it )
leaves = expectedLeaves.mapIt(
array[31, byte].initCopyFrom( it.toBytes )
)).tryGet
check: