mirror of
https://github.com/status-im/nim-ethash.git
synced 2025-02-19 15:34:21 +00:00
check if dataset and recomputation from cache matches
This commit is contained in:
parent
235fc1e7a2
commit
d355c37bed
@ -147,7 +147,7 @@ suite "Dagger hashimoto computation":
|
||||
|
||||
let
|
||||
cache_size = 1024'u
|
||||
full_size = 1024'u * 32
|
||||
full_size = 1024 * 32
|
||||
cache_str = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
header_str = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
|
||||
@ -158,12 +158,21 @@ suite "Dagger hashimoto computation":
|
||||
var header: Hash[256]
|
||||
copyMem(addr header, unsafeAddr header_str[0], 256 div 8)
|
||||
|
||||
let full = calc_dataset(full_size, cache)
|
||||
|
||||
test "calc_data_set_item of item 0":
|
||||
# # https://github.com/ethereum/ethash/blob/f5f0a8b1962544d2b6f40df8e4b0d9a32faf8f8e/test/c/test.cpp#L350-L374
|
||||
# https://github.com/ethereum/ethash/blob/f5f0a8b1962544d2b6f40df8e4b0d9a32faf8f8e/test/c/test.cpp#L350-L374
|
||||
let expected = toUpperASCII "b1698f829f90b35455804e5185d78f549fcb1bdce2bee006d4d7e68eb154b596be1427769eb1c3c3e93180c760af75f81d1023da6a0ffbe321c153a7c0103597"
|
||||
|
||||
check: $calc_dataset_item(cache, 0) == expected
|
||||
|
||||
test "Real dataset and recomputation from cache matches":
|
||||
# https://github.com/ethereum/ethash/blob/f5f0a8b1962544d2b6f40df8e4b0d9a32faf8f8e/test/c/test.cpp#L360-L374
|
||||
for i in 0 ..< full_size div sizeof(Hash[512]):
|
||||
for j in 0 ..< 32:
|
||||
let expected = calc_dataset_item(cache, j)
|
||||
check: full[j] == expected
|
||||
|
||||
test "Light and full Hashimoto agree":
|
||||
# https://github.com/ethereum/ethash/blob/f5f0a8b1962544d2b6f40df8e4b0d9a32faf8f8e/test/python/test_pyethash.py#L44-L58
|
||||
|
||||
@ -172,7 +181,8 @@ suite "Dagger hashimoto computation":
|
||||
let
|
||||
light_result = hashimoto_light(full_size, cache, header, 0)
|
||||
dataset = calc_dataset(full_size, cache)
|
||||
full_result = hashimoto_full(full_size, dataset, header, 0)
|
||||
|
||||
let full_result = hashimoto_full(full_size, dataset, header, 0)
|
||||
|
||||
# Check not null
|
||||
var zero_array: array[8, uint32]
|
||||
|
Loading…
x
Reference in New Issue
Block a user