Fix a bug where creator of the database was not added to the list of writers
This commit is contained in:
parent
54bace5077
commit
9b1f704abe
@ -202,7 +202,7 @@ class OrbitDB {
|
||||
// accessController.add('admin', this.key.getPublic('hex'))
|
||||
// }
|
||||
// Add keys that can write to the database
|
||||
if (options && options.write) {
|
||||
if (options && options.write && options.write.length > 0) {
|
||||
options.write.forEach(e => accessController.add('write', e))
|
||||
} else {
|
||||
// Default is to add ourselves as the admin of the database
|
||||
|
@ -218,6 +218,12 @@ describe('orbit-db - Create & Open', function() {
|
||||
assert.equal(db.address.toString().indexOf('abc'), 56)
|
||||
})
|
||||
|
||||
it('opens a database and adds the creator as the only writer', async () => {
|
||||
db = await orbitdb.open('abc', { create: true, type: 'feed', overwrite: true, write: [] })
|
||||
assert.equal(db.access.write.length, 1)
|
||||
assert.equal(db.access.write[0], db.key.getPublic('hex'))
|
||||
})
|
||||
|
||||
it('doesn\'t open a database if we don\'t have it locally', async () => {
|
||||
const address = new OrbitDBAddress(db.address.root.slice(0, -1) + 'A', 'non-existent')
|
||||
return new Promise((resolve, reject) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user