aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-06-17 06:56:25 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-06-17 06:56:25 +0800
commitbe303ba1864d760c2d47eb9b27acbe889d1a0e29 (patch)
tree3db38cf6c7c9d7122a370545fdd5384b48017e95 /Godeps/_workspace
parenta9d6846f9218ef131ec4b3ca8d31284f64f1b8a5 (diff)
downloadgo-tangerine-be303ba1864d760c2d47eb9b27acbe889d1a0e29.tar.gz
go-tangerine-be303ba1864d760c2d47eb9b27acbe889d1a0e29.tar.zst
go-tangerine-be303ba1864d760c2d47eb9b27acbe889d1a0e29.zip
Update ethash Godep (again)
Diffstat (limited to 'Godeps/_workspace')
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go3
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go28
2 files changed, 21 insertions, 10 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
index ee68ab95f..73c5bf664 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
@@ -8,7 +8,6 @@ int ethashGoCallback_cgo(unsigned);
import "C"
import (
- "bytes"
"errors"
"fmt"
"io/ioutil"
@@ -122,7 +121,7 @@ func (l *Light) Verify(block pow.Block) bool {
}
// avoid mixdigest malleability as it's not included in a block's "hashNononce"
- if !bytes.Equal(block.MixDigest().Bytes(), C.GoBytes(unsafe.Pointer(&ret.mix_hash), C.int(32))) {
+ if block.MixDigest() != h256ToHash(ret.mix_hash) {
return false
}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
index 42be77b94..e6833e343 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
@@ -39,6 +39,7 @@ var validBlocks = []*testBlock{
hashNoNonce: common.HexToHash("372eca2454ead349c3df0ab5d00b0b706b23e49d469387db91811cee0358fc6d"),
difficulty: big.NewInt(132416),
nonce: 0x495732e0ed7a801c,
+ mixDigest: common.HexToHash("2f74cdeb198af0b9abe65d22d372e22fb2d474371774a9583c1cc427a07939f5"),
},
// from proof of concept nine testnet, epoch 1
{
@@ -46,6 +47,7 @@ var validBlocks = []*testBlock{
hashNoNonce: common.HexToHash("7e44356ee3441623bc72a683fd3708fdf75e971bbe294f33e539eedad4b92b34"),
difficulty: big.NewInt(1532671),
nonce: 0x318df1c8adef7e5e,
+ mixDigest: common.HexToHash("144b180aad09ae3c81fb07be92c8e6351b5646dda80e6844ae1b697e55ddde84"),
},
// from proof of concept nine testnet, epoch 2
{
@@ -53,6 +55,7 @@ var validBlocks = []*testBlock{
hashNoNonce: common.HexToHash("5fc898f16035bf5ac9c6d9077ae1e3d5fc1ecc3c9fd5bee8bb00e810fdacbaa0"),
difficulty: big.NewInt(2467358),
nonce: 0x50377003e5d830ca,
+ mixDigest: common.HexToHash("ab546a5b73c452ae86dadd36f0ed83a6745226717d3798832d1b20b489e82063"),
},
}
@@ -73,8 +76,9 @@ func TestEthashConcurrentVerify(t *testing.T) {
defer os.RemoveAll(eth.Full.Dir)
block := &testBlock{difficulty: big.NewInt(10)}
- nonce, _ := eth.Search(block, nil)
+ nonce, md := eth.Search(block, nil)
block.nonce = nonce
+ block.mixDigest = common.BytesToHash(md)
// Verify the block concurrently to check for data races.
var wg sync.WaitGroup
@@ -98,21 +102,26 @@ func TestEthashConcurrentSearch(t *testing.T) {
eth.Turbo(true)
defer os.RemoveAll(eth.Full.Dir)
- // launch n searches concurrently.
+ type searchRes struct {
+ n uint64
+ md []byte
+ }
+
var (
block = &testBlock{difficulty: big.NewInt(35000)}
nsearch = 10
wg = new(sync.WaitGroup)
- found = make(chan uint64)
+ found = make(chan searchRes)
stop = make(chan struct{})
)
rand.Read(block.hashNoNonce[:])
wg.Add(nsearch)
+ // launch n searches concurrently.
for i := 0; i < nsearch; i++ {
go func() {
- nonce, _ := eth.Search(block, stop)
+ nonce, md := eth.Search(block, stop)
select {
- case found <- nonce:
+ case found <- searchRes{n: nonce, md: md}:
case <-stop:
}
wg.Done()
@@ -120,12 +129,14 @@ func TestEthashConcurrentSearch(t *testing.T) {
}
// wait for one of them to find the nonce
- nonce := <-found
+ res := <-found
// stop the others
close(stop)
wg.Wait()
- if block.nonce = nonce; !eth.Verify(block) {
+ block.nonce = res.n
+ block.mixDigest = common.BytesToHash(res.md)
+ if !eth.Verify(block) {
t.Error("Block could not be verified")
}
}
@@ -140,8 +151,9 @@ func TestEthashSearchAcrossEpoch(t *testing.T) {
for i := epochLength - 40; i < epochLength+40; i++ {
block := &testBlock{number: i, difficulty: big.NewInt(90)}
rand.Read(block.hashNoNonce[:])
- nonce, _ := eth.Search(block, nil)
+ nonce, md := eth.Search(block, nil)
block.nonce = nonce
+ block.mixDigest = common.BytesToHash(md)
if !eth.Verify(block) {
t.Fatalf("Block could not be verified")
}