diff options
author | Felix Lange <fjl@twurst.com> | 2017-03-18 07:55:37 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2017-03-18 08:05:28 +0800 |
commit | 24dd0355a34a40b1798c9b8bd97a7332a77e2556 (patch) | |
tree | 6eb22f45d051a3ba7aeeade24614dc2808b1b60e /pow/ethash_algo_test.go | |
parent | 61ede86737d57f62cb09de013191fc430d1dd3a2 (diff) | |
download | dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar.gz dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar.bz2 dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar.lz dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar.xz dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.tar.zst dexon-24dd0355a34a40b1798c9b8bd97a7332a77e2556.zip |
pow: fix Search with ethash test mode
The cache/dataset methods crashed with a nil pointer error if
cachesinmem/dagsinmem were zero. Fix it by skipping the eviction logic
if there are no caches/datasets.
Search always used the regular dataset size regardless of test mode. Fix
it by removing the redundant size parameter of hashimotoFull.
Fixes #3784
Diffstat (limited to 'pow/ethash_algo_test.go')
-rw-r--r-- | pow/ethash_algo_test.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pow/ethash_algo_test.go b/pow/ethash_algo_test.go index c881874ff..0605d70ad 100644 --- a/pow/ethash_algo_test.go +++ b/pow/ethash_algo_test.go @@ -660,7 +660,7 @@ func TestHashimoto(t *testing.T) { if !bytes.Equal(result, wantResult) { t.Errorf("light hashimoto result mismatch: have %x, want %x", result, wantResult) } - digest, result = hashimotoFull(32*1024, dataset, hash, nonce) + digest, result = hashimotoFull(dataset, hash, nonce) if !bytes.Equal(digest, wantDigest) { t.Errorf("full hashimoto digest mismatch: have %x, want %x", digest, wantDigest) } @@ -713,6 +713,17 @@ func TestConcurrentDiskCacheGeneration(t *testing.T) { pend.Wait() } +func TestTestMode(t *testing.T) { + head := &types.Header{Difficulty: big.NewInt(100)} + ethash := NewTestEthash() + nonce, mix := ethash.Search(types.NewBlockWithHeader(head), nil) + head.Nonce = types.EncodeNonce(nonce) + copy(head.MixDigest[:], mix) + if err := ethash.Verify(types.NewBlockWithHeader(head)); err != nil { + t.Error("unexpected Verify error:", err) + } +} + // Benchmarks the cache generation performance. func BenchmarkCacheGeneration(b *testing.B) { for i := 0; i < b.N; i++ { @@ -758,6 +769,6 @@ func BenchmarkHashimotoFullSmall(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - hashimotoFull(32*65536, dataset, hash, 0) + hashimotoFull(dataset, hash, 0) } } |