add reopen tests

This commit is contained in:
shamb0t 2019-11-21 14:53:17 +00:00 committed by haad
parent a0deceba5f
commit e4bbfa7c41

View File

@ -170,6 +170,7 @@ Object.keys(testAPIs).forEach(API => {
it('database has the correct access-controller', async () => {
assert.equal(db.access.type, 'ipfs')
assert.equal(db.options.accessControllerAddress, '/ipfs/zdpuAsYRtJLLLDibnmxWPzyRGJEqtjmJP27ppKWcLreNGGTFN')
assert.strictEqual(db.access.write[0], '*')
})
@ -183,6 +184,16 @@ Object.keys(testAPIs).forEach(API => {
assert.equal(newEntries.length, 1)
assert.strictEqual(newEntries[0].hash, hash)
})
it('reopens db after adding new entry', async () => {
await db.close()
db = await orbitdb.open(v1Address, { directory: dbPath2 })
assert.notEqual(db, null)
await db.load()
assert.equal(db.all.length, 101)
const newEntries = db.all.filter(e => e.v > 1)
assert.equal(newEntries.length, 1)
})
})
})
})