-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test results are not consistent #45
Comments
Just FYI @zrrrzzt https://gitter.im/amark/gun?at=5a5bb8075ade18be397611e4 :) :) :) will add you to the README of contributors when I update the README next, too! I (and everybody else) are very grateful. :) |
I think the right move would be to remove this test from |
More updates. I tried However. I created 2 other scripts // merge-test.js
module.exports = callback => {
const Gun = require('gun')
const gun = Gun()
const key = Math.random().toString(36).slice(2)
// write initial data
gun.get(key).put({ data: true }, res1 => {
if (res1.err) {
return callback(res1.err, null)
}
// add to it
gun.get(key).put({ success: true }, res2 => {
if (res2.err) {
return callback(res2.err, null)
}
// verify data merge
gun.get(key).val(value => {
if (value.success && value.success === true && value.data && value.data === true) {
return callback(null, {value: true})
} else {
return callback(null, {value: false})
}
})
})
})
} //run-multiple.js
let jobs = 100
let done = 0
let fail = 0
let success = 0
function printResult () {
console.log(`Fail: ${fail}`)
console.log(`Success: ${success}`)
console.log('\n')
}
function doTest () {
const mergeTest = require('./merge-test')
mergeTest((error, result) => {
if (error) {
console.error(error)
} else {
if (result.value === true) {
success++
} else {
fail++
}
printResult()
}
})
}
while (jobs > done) {
done++
console.log(`Running ${done} of ${jobs}`)
doTest()
} to run node run-multiple.js So there might still be something fishy with |
I did a PR and discovered one of the tests failed on travis. I ran the tests on my local machine and it passed. By running the tests multiple times I found that the result was not predictable.
The problem seems to be this line: https://github.com/PsychoLlama/gun-level/blob/master/src/spec.js#L87
How to recreate
clone repo
npm install
Add a script to the root of the repo
run-multiple.js
Run the script
node run-multiple.js
Look at the results.
The text was updated successfully, but these errors were encountered: