diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-20 21:01:35 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-20 21:01:35 +0800 |
commit | 28ddc16a9b5779b6b31036e8248ed8457de7b443 (patch) | |
tree | 7508db500151bdaf0ebed726286f823e67993103 /Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js | |
parent | c161d73d429ef421cdb9c75b743c16d72aa8a89a (diff) | |
parent | 01ff0b3176e6d83dcc5e6716f04301de71e3fc9e (diff) | |
download | go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar.gz go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar.bz2 go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar.lz go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar.xz go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.tar.zst go-tangerine-28ddc16a9b5779b6b31036e8248ed8457de7b443.zip |
Merge remote-tracking branch 'ethereum/conversion' into conversion
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js')
-rw-r--r-- | Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js b/Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js new file mode 100644 index 000000000..a3666a9ed --- /dev/null +++ b/Godeps/_workspace/src/github.com/ethereum/ethash/js/test/seedHash.js @@ -0,0 +1,48 @@ +var tape = require('tape'); +const ethash = require('../ethash.js'); + +tape('seed hash', function(t) { + + t.test('seed should match TRUTH', function(st) { + const seed = '290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563'; + const blockNum = 30000; + + var r = new Buffer(ethash.calcSeed(blockNum)); + st.equal(r.toString('hex'), seed); + + st.end(); + }); + + t.test('seed should match TRUTH2', function(st) { + const seed = '510e4e770828ddbf7f7b00ab00a9f6adaf81c0dc9cc85f1f8249c256942d61d9'; + const blockNum = 60000; + + var r = new Buffer(ethash.calcSeed(blockNum)); + st.equal(r.toString('hex'), seed); + + st.end(); + }); + + t.test('seed should match TRUTH3', function(st) { + const seed = '510e4e770828ddbf7f7b00ab00a9f6adaf81c0dc9cc85f1f8249c256942d61d9'; + const blockNum = 60700; + + var r = new Buffer(ethash.calcSeed(blockNum)); + st.equal(r.toString('hex'), seed); + + st.end(); + }); + + t.test('randomized tests', function(st) { + for (var i = 0; i < 100; i++) { + var x = Math.floor(ethash.params.EPOCH_LENGTH * 2048 * Math.random()); + st.equal(ethash.calcSeed(x).toString('hex'), ethash.calcSeed(Math.floor(x / ethash.params.EPOCH_LENGTH) * ethash.params.EPOCH_LENGTH ).toString('hex')); + } + st.end(); + }); + // '510e4e770828ddbf7f7b00ab00a9f6adaf81c0dc9cc85f1f8249c256942d61d9' + // [7:13:32 PM] Matthew Wampler-Doty: >>> x = randint(0,700000) + // + // >>> pyethash.get_seedhash(x).encode('hex') == pyethash.get_seedhash((x // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH).encode('hex') + +}); |