mafintosh / hyperdb

Distributed scalable database
MIT License
752 stars 75 forks source link

Two replications in one test exits early #109

Closed jimpick closed 6 years ago

jimpick commented 6 years ago

Test case:

var tape = require('tape')
var create = require('./helpers/create')
var replicate = require('./helpers/replicate')

tape('2 replications in one test', function (t) {
  var db = create.one(null)
  db.ready(function () {
    db.put('hello', 'world', function () {
      var clone1 = create.one(db.key)
      clone1.ready(function () {
        replicate(db, clone1, function () {
          clone1.get('hello', function (err, node) {
            t.error(err, 'no error')
            t.same(node.value, 'world')
            var clone2 = create.one(db.key)
            clone2.ready(function () {
              replicate(clone1, clone2, function () {
                t.end()
              })
            })
          })
        })
      })
    })
  })
})

Result:

TAP version 13
# 2 replications in one test
ok 1 no error
ok 2 should be equivalent
not ok 3 test exited without ending
  ---
    operator: fail
    at: process.<anonymous> (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/index.js:90:19)
    stack: |-
      Error: test exited without ending
          at Test.assert [as _assert] (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:225:54)
          at Test.bound [as _assert] (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:77:32)
          at Test.fail (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:318:10)
          at Test.bound [as fail] (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:77:32)
          at Test._exit (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:191:14)
          at Test.bound [as _exit] (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/lib/test.js:77:32)
          at process.<anonymous> (/Users/jim/backblend/clients/code-for-science/hyperdb/node_modules/tape/index.js:90:19)
          at process.emit (events.js:160:13)
  ...

1..3
# tests 3
# pass  2
# fail  1

I was attempting to write test cases for some more complicated replication scenarios when I hit this.

mafintosh commented 6 years ago

fixed in latest