int64 fixes
This commit is contained in:
parent
e692aa426f
commit
405f460f9b
|
@ -117,8 +117,8 @@ proc clearCaches*(a: var HashArray, dataIdx: auto) =
|
|||
func nodesAtLayer*(layer, depth, leaves: int): int =
|
||||
## Given a number of leaves, how many nodes do you need at a given layer
|
||||
## in a binary tree structure?
|
||||
let leavesPerNode = 1 shl (depth - layer)
|
||||
(leaves + leavesPerNode - 1) div leavesPerNode
|
||||
let leavesPerNode = 1'i64 shl (depth - layer)
|
||||
int((leaves + leavesPerNode - 1) div leavesPerNode)
|
||||
|
||||
func cacheNodes*(depth, leaves: int): int =
|
||||
## Total number of nodes needed to cache a tree of a given depth with
|
||||
|
|
|
@ -231,11 +231,10 @@ proc sszCheck(baseDir, sszType, sszSubType: string) =
|
|||
of "SmallTestStruct": checkBasic(SmallTestStruct, dir, expectedHash)
|
||||
of "FixedTestStruct": checkBasic(FixedTestStruct, dir, expectedHash)
|
||||
of "VarTestStruct": checkBasic(VarTestStruct, dir, expectedHash)
|
||||
of "ComplexTestStruct": checkBasic(ComplexTestStruct, dir, expectedHash)
|
||||
of "BitsStruct": checkBasic(BitsStruct, dir, expectedHash)
|
||||
of "ComplexTestStruct":
|
||||
checkBasic(ComplexTestStruct, dir, expectedHash)
|
||||
checkBasic(HashComplexTestStruct, dir, expectedHash)
|
||||
of "BitsStruct": checkBasic(BitsStruct, dir, expectedHash)
|
||||
else:
|
||||
raise newException(ValueError, "unknown container in test: " & sszSubType)
|
||||
else:
|
||||
|
|
|
@ -88,7 +88,7 @@ suiteReport "SSZ navigator":
|
|||
let b = [byte 0x04, 0x05, 0x06].toDigest
|
||||
let c = [byte 0x07, 0x08, 0x09].toDigest
|
||||
|
||||
var leaves = HashList[Eth2Digest, int64(1 shl 3)]()
|
||||
var leaves = HashList[Eth2Digest, 1'i64 shl 3]()
|
||||
leaves.add a
|
||||
leaves.add b
|
||||
leaves.add c
|
||||
|
@ -98,6 +98,12 @@ suiteReport "SSZ navigator":
|
|||
leaves.add c
|
||||
check hash_tree_root(leaves) == hash_tree_root(leaves.data)
|
||||
|
||||
var leaves2 = HashList[Eth2Digest, 1'i64 shl 48]() # Large number!
|
||||
leaves2.add a
|
||||
leaves2.add b
|
||||
leaves2.add c
|
||||
check hash_tree_root(leaves2) == hash_tree_root(leaves2.data)
|
||||
|
||||
suiteReport "SSZ dynamic navigator":
|
||||
timedTest "navigating fields":
|
||||
var fooOrig = Foo(bar: Bar(b: BarList @[1'u64, 2, 3], baz: Baz(i: 10'u64)))
|
||||
|
|
Loading…
Reference in New Issue