diff --git a/test/sim/misc/prng.js b/test/sim/misc/prng.js index c000c9547f56..724ec1d2e131 100644 --- a/test/sim/misc/prng.js +++ b/test/sim/misc/prng.js @@ -3,9 +3,24 @@ const PRNG = require('../../../dist/sim/prng').PRNG; const assert = require('../../assert'); -const testSeed = [1, 2, 3, 4]; +const testSeed = ['sodium', 1, 2, 3, 4]; describe(`PRNG`, function () { + it("should always generate the same results off the same seed", function () { + const results = []; + const testAgainst = new PRNG(testSeed); + for (let i = 0; i < 100; i++) { + results.push(testAgainst.next()); + } + for (let i = 0; i < 10; i++) { + const cur = new PRNG(testSeed); + for (let j = 0; j < results.length; j++) { + const n = cur.next(); + assert(results[j] === n, `generation ${j} for seed ${testSeed} did not match (expected: ${results[j]}, got ${n})`); + } + } + }); + describe(`randomChance(numerator=0, denominator=1)`, function () { it(`should always return false`, function () { const prng = new PRNG(testSeed);