implemented random seed generator, in order to reproduce tests
This commit is contained in:
parent
3dc67e075b
commit
2091392031
@ -42,6 +42,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "http://y-js.org",
|
"homepage": "http://y-js.org",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^5.0.0-beta6",
|
||||||
"babel-plugin-transform-runtime": "^6.1.18",
|
"babel-plugin-transform-runtime": "^6.1.18",
|
||||||
"babel-preset-es2015": "^6.1.18",
|
"babel-preset-es2015": "^6.1.18",
|
||||||
"babelify": "^7.2.0",
|
"babelify": "^7.2.0",
|
||||||
@ -69,10 +70,10 @@
|
|||||||
"pre-commit": "^1.1.1",
|
"pre-commit": "^1.1.1",
|
||||||
"regenerator": "^0.8.42",
|
"regenerator": "^0.8.42",
|
||||||
"run-sequence": "^1.1.4",
|
"run-sequence": "^1.1.4",
|
||||||
|
"seedrandom": "^2.4.2",
|
||||||
"standard": "^5.2.2",
|
"standard": "^5.2.2",
|
||||||
"vinyl-buffer": "^1.0.0",
|
"vinyl-buffer": "^1.0.0",
|
||||||
"vinyl-source-stream": "^1.1.0",
|
"vinyl-source-stream": "^1.1.0"
|
||||||
"babel-eslint": "^5.0.0-beta6"
|
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,29 @@ if (typeof global !== 'undefined') {
|
|||||||
}
|
}
|
||||||
g.g = g
|
g.g = g
|
||||||
|
|
||||||
|
// Helper methods for the random number generator
|
||||||
|
Math.seedrandom = require('seedrandom')
|
||||||
|
|
||||||
|
g.generateRandomSeed = function generateRandomSeed() {
|
||||||
|
var seed
|
||||||
|
if (window.location.hash.length > 1) {
|
||||||
|
seed = window.location.hash.slice(1) // first character is the hash!
|
||||||
|
console.warn('Using random seed that was specified in the url!')
|
||||||
|
} else {
|
||||||
|
seed = JSON.stringify(Math.random())
|
||||||
|
}
|
||||||
|
console.info('Using random seed: ' + seed)
|
||||||
|
setRandomSeed(seed)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setRandomSeed = function setRandomSeed(seed) {
|
||||||
|
Math.seedrandom.currentSeed = seed
|
||||||
|
Math.seedrandom(Math.seedrandom.currentSeed, { global: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
g.generateRandomSeed()
|
||||||
|
|
||||||
g.YConcurrency_TestingMode = true
|
g.YConcurrency_TestingMode = true
|
||||||
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000
|
||||||
@ -86,6 +109,7 @@ function getRandomString () {
|
|||||||
g.getRandomString = getRandomString
|
g.getRandomString = getRandomString
|
||||||
|
|
||||||
function * applyTransactions (relAmount, numberOfTransactions, objects, users, transactions, noReconnect) {
|
function * applyTransactions (relAmount, numberOfTransactions, objects, users, transactions, noReconnect) {
|
||||||
|
g.generateRandomSeed() // create a new seed, so we can re-create the behavior
|
||||||
for (var i = 0; i < numberOfTransactions * relAmount + 1; i++) {
|
for (var i = 0; i < numberOfTransactions * relAmount + 1; i++) {
|
||||||
var r = Math.random()
|
var r = Math.random()
|
||||||
if (r > 0.95) {
|
if (r > 0.95) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user