diff --git a/test/test.random.js b/test/test.random.js index a02ac6e..b52c5cb 100644 --- a/test/test.random.js +++ b/test/test.random.js @@ -9,7 +9,7 @@ var should = chai.should(); var Key = bitcore.Key; describe('Key randomness tests', function() { - var RUNS = 100; + var RUNS = 128; it('should pass Frequency (Monobits) Test', function() { /* Description: The focus of the test is the proportion @@ -65,14 +65,16 @@ describe('Key randomness tests', function() { return (b >> index) & 1; }; var getBitInKey = function(key, index) { - var bindex = parseInt(index / key.length); - return getBitInByte(key[bindex], index - bindex * key.length); + var bindex = parseInt(index / 8); + bindex.should.be.below(key.length); + return getBitInByte(key[bindex], index - bindex * 8); }; var getBitInKeys = function(keys, index) { - var kindex = parseInt(index / keys.length); - return getBitInKey(keys[kindex], index - keys.length * kindex); + var kindex = parseInt(index / (keys[0].length*8)); + kindex.should.be.below(keys.length); + return getBitInKey(keys[kindex], index - (keys[0].length*8) * kindex); }; - it.skip('should pass Runs Test', function() { + it('should pass Runs Test', function() { var keys = []; for (var i = 0; i < RUNS; i++) { keys.push(Key.generateSync().private); @@ -90,18 +92,19 @@ describe('Key randomness tests', function() { } count += 1; } - console.log(h); - var max; - for(i = 1; i < 32; i++) { - var f = h[i]; - if (i === 1) max = f; - - var fNorm = f * 80 / max; - var s = ''; - for (var c = 0; c