Skip to content

Commit

Permalink
tests ensure server is running
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Feb 14, 2019
1 parent fbc6589 commit c41a6c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ var carol = createSbot({

var m1, m2

tape('ready', function (t) {
bob.once('multiserver:listening', function () {
t.end()
})

})

tape('connect', function (t) {
alice.connect(bob.getAddress(), function (err) {
if(err) throw err
Expand Down
28 changes: 15 additions & 13 deletions test/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ var bob = createSbot({
})

tape('connect', function (t) {
bob.publish({type: 'test', ooo: true}, function (err, msg) {
console.log(msg)
var ts = Date.now()
alice.ooo.get({id:msg.key, timeout: 1000}, function (err) {
t.ok(err)
t.ok(Date.now() > ts + 1000)
alice.connect(bob.getAddress(), function () {
alice.ooo.get({id:msg.key, timeout: 1000}, function (err, _data) {
if(err) throw err
t.deepEqual(_data.value, msg.value)
alice.close()
bob.close()
t.end()
bob.once('multiserver:listening', function () {
bob.publish({type: 'test', ooo: true}, function (err, msg) {
console.log(msg)
var ts = Date.now()
alice.ooo.get({id:msg.key, timeout: 1000}, function (err) {
t.ok(err)
t.ok(Date.now() > ts + 1000)
alice.connect(bob.getAddress(), function () {
alice.ooo.get({id:msg.key, timeout: 1000}, function (err, _data) {
if(err) throw err
t.deepEqual(_data.value, msg.value)
alice.close()
bob.close()
t.end()
})
})
})
})
Expand Down

0 comments on commit c41a6c1

Please sign in to comment.