Skip to content
Snippets Groups Projects
Commit 20913920 authored by Kevin Jahns's avatar Kevin Jahns
Browse files

implemented random seed generator, in order to reproduce tests

parent 3dc67e07
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@
},
"homepage": "http://y-js.org",
"devDependencies": {
"babel-eslint": "^5.0.0-beta6",
"babel-plugin-transform-runtime": "^6.1.18",
"babel-preset-es2015": "^6.1.18",
"babelify": "^7.2.0",
......@@ -69,10 +70,10 @@
"pre-commit": "^1.1.1",
"regenerator": "^0.8.42",
"run-sequence": "^1.1.4",
"seedrandom": "^2.4.2",
"standard": "^5.2.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"babel-eslint": "^5.0.0-beta6"
"vinyl-source-stream": "^1.1.0"
},
"dependencies": {}
}
......@@ -23,6 +23,29 @@ if (typeof global !== 'undefined') {
}
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
jasmine.DEFAULT_TIMEOUT_INTERVAL = 200000
......@@ -86,6 +109,7 @@ function getRandomString () {
g.getRandomString = getRandomString
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++) {
var r = Math.random()
if (r > 0.95) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment