mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
Fix OrbitDB AC test
This commit is contained in:
@@ -229,6 +229,7 @@ describe('Write Permissions', function () {
|
||||
it('uses an OrbitDB access controller to manage access - two writers', async () => {
|
||||
let connected = false
|
||||
let updateCount = 0
|
||||
let accessUpdated = false
|
||||
|
||||
const onConnected = async (peerId, heads) => {
|
||||
connected = true
|
||||
@@ -238,6 +239,10 @@ describe('Write Permissions', function () {
|
||||
++updateCount
|
||||
}
|
||||
|
||||
const onAccessUpdated = async (entry) => {
|
||||
accessUpdated = true
|
||||
}
|
||||
|
||||
const db1 = await orbitdb1.open('write-test', { AccessController: OrbitDBAccessController() })
|
||||
const db2 = await orbitdb2.open(db1.address)
|
||||
|
||||
@@ -246,8 +251,12 @@ describe('Write Permissions', function () {
|
||||
|
||||
await waitFor(() => connected, () => true)
|
||||
|
||||
db2.access.events.on('update', onAccessUpdated)
|
||||
|
||||
await db1.access.grant('write', db2.identity.id)
|
||||
|
||||
await waitFor(() => accessUpdated, () => true)
|
||||
|
||||
await db1.add('record 1')
|
||||
await db2.add('record 2')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user