Skip to content

Commit

Permalink
dump more useful test output...
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Feb 9, 2018
1 parent 27c7d7c commit daf87aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 10 additions & 6 deletions test/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ var alice = ssbKeys.generate()
.use(require('../'))
.use(require('ssb-friends'))

var timeout = 2000

var a_bot = createSbot({
temp: 'alice',
port: 55451, host: 'localhost', timeout: 20001,
port: 55451, host: 'localhost', timeout: timeout,
replicate: {hops: 3, legacy: false},
keys: alice
})
Expand All @@ -56,7 +58,7 @@ var alice = ssbKeys.generate()

var b_bot = createSbot({
temp: 'bob',
port: 55452, host: 'localhost', timeout: 20001,
port: 55452, host: 'localhost', timeout: timeout,
replicate: {hops: 3, legacy: false},
keys: ssbKeys.generate()
})
Expand Down Expand Up @@ -121,17 +123,20 @@ var alice = ssbKeys.generate()
// })
//
b_bot.connect(a_bot.getAddress(), function (err) {
console.log('A<-->B')
if(err) throw err
var int = setInterval(function () {
// console.log(JSON.stringify(b_bot.status().ebt))

var prog = a_bot.progress()
console.log('assertions')
assert.ok(prog.indexes)
assert.ok(prog.ebt)
assert.ok(prog.ebt.target)

a_bot.getVectorClock(function (err, clock) {
b_bot.getVectorClock(function (err, _clock) {
console.log('clocks', clock, _clock)
var d = 0, total_a = 0, total_b = 0
function count (o) {
var t = 0, s = 0
Expand Down Expand Up @@ -166,14 +171,13 @@ var alice = ssbKeys.generate()
}
else {
console.log('inconsistent', JSON.stringify(a_bot.status().ebt))
console.log(JSON.stringify(
b_bot.ebt._streams(), null, 2
))
}
})
})
},1000).unref()
},1000)//.unref()
})
})
})



7 changes: 5 additions & 2 deletions test/resync.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ var alice = ssbKeys.generate()
.use(require('../'))
.use(require('ssb-friends'))

var timeout = 2000

var a_bot = createSbot({
temp: 'alice',
port: 45451, host: 'localhost', timeout: 20001,
port: 45451, host: 'localhost', timeout: timeout,
replicate: {hops: 3, legacy: false},
keys: alice
})
Expand All @@ -53,7 +55,7 @@ var alice = ssbKeys.generate()

var b_bot = createSbot({
temp: 'bob',
port: 45452, host: 'localhost', timeout: 20001,
port: 45452, host: 'localhost', timeout: timeout,
replicate: {hops: 3, legacy: false},
keys: bob
})
Expand Down Expand Up @@ -125,6 +127,7 @@ var alice = ssbKeys.generate()
console.log('A', count(clock), 'B', count(_clock), 'diff', d, 'common', c)
if(d === 0 && c ) {
clearInterval(int)
console.log('close...')
a_bot.close()
b_bot.close()
}
Expand Down
13 changes: 3 additions & 10 deletions test/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ function next () {
b_bot.replicate.request(f.id)
})

console.log(
"LOADED, Bob's Alice:",
require('fs').readFileSync('/tmp/random-animals_bob/ebt/a', 'utf8')
)
console.log(
"LOADED, Alice's Bob:",
require('fs').readFileSync('/tmp/random-animals_alice/ebt/b', 'utf8')
)

a_bot.publish({type:'post', content: 'hello bob'}, function () {

peers(a_bot, b_bot, 'a', 'b', 10)
Expand All @@ -189,6 +180,9 @@ function next () {
var int = setInterval(function () {
if(!j--) {
console.log('FAILED')
console.log(JSON.stringify(a_bot.ebt._state(), null, 2))
console.log(JSON.stringify(b_bot.ebt._state(), null, 2))

process.exit(1)
}
a_bot.getVectorClock(function (err, clock) {
Expand All @@ -214,4 +208,3 @@ function next () {
}



0 comments on commit daf87aa

Please sign in to comment.