diff --git a/ssz_serialization/merkleization.nim b/ssz_serialization/merkleization.nim index 91f8945..207a0be 100644 --- a/ssz_serialization/merkleization.nim +++ b/ssz_serialization/merkleization.nim @@ -1413,13 +1413,13 @@ func hash_tree_root*( when indices.len == 1 and indices[0] == 1.GeneralizedIndex: ResultType.ok([hash_tree_root(x)]) else: - var roots {.noinit.}: array[indices.len, Digest] const loopOrder = merkleizationLoopOrder(indices) v = validateIndices(indices, loopOrder) when v.isErr: ResultType.err(v.error) else: + var roots {.noinit.}: array[indices.len, Digest] const slice = 0 ..< loopOrder.len let w = hash_tree_root_multi(x, indices, roots, loopOrder, slice) if w.isErr: diff --git a/tests/test_merkleization_types.nim b/tests/test_merkleization_types.nim index ac8293d..feda94f 100644 --- a/tests/test_merkleization_types.nim +++ b/tests/test_merkleization_types.nim @@ -8,11 +8,14 @@ {.used.} import - std/[sequtils, tables], + std/tables, + results, unittest2, - stew/[endians2, results], + stew/endians2, ../ssz_serialization/merkleization +from std/sequtils import mapIt + func d(x: openArray[byte]): Digest = result.data[0 ..< x.len] = x @@ -97,8 +100,7 @@ let u: E(x: false, y: true), v: (a: false, b: true), w: (a: E(x: false, y: true), b: E(x: true, y: false), c: true), - x: HashArray[2, E](data: array[2, E]( - [E(x: false, y: true), E(x: true, y: false)])), + x: HashArray[2, E](data: [E(x: false, y: true), E(x: true, y: false)]), y: HashList[E, 2].init( @[E(x: false, y: true), E(x: true, y: false)]), z: HashList[E, 2].init(@[]))