Fix timeout and timing bug in Sync

This commit is contained in:
haad
2025-05-20 09:51:11 +03:00
parent 90f84bf12f
commit 85686ba478
4 changed files with 21 additions and 26 deletions

View File

@@ -319,12 +319,12 @@ describe('KeyValueIndexed Database Replication', function () {
])
})
it('indexes deletes correctly', async () => {
it.only('indexes deletes correctly', async () => {
let replicated = false
let err
const onError = (err) => {
console.error(err)
deepStrictEqual(err, undefined)
const onError = (error) => {
err = error
}
kv1 = await KeyValueIndexed()({ ipfs: ipfs1, identity: testIdentity1, address: databaseId, accessController, directory: './orbitdb11' })
@@ -339,11 +339,11 @@ describe('KeyValueIndexed Database Replication', function () {
kv2 = await KeyValueIndexed()({ ipfs: ipfs2, identity: testIdentity2, address: databaseId, accessController, directory: './orbitdb22' })
const onUpdate = (entry) => {
const onConnected = (entry) => {
replicated = true
}
kv2.events.on('update', onUpdate)
kv2.events.on('join', onConnected)
kv2.events.on('error', onError)
await waitFor(() => replicated, () => true)
@@ -358,6 +358,8 @@ describe('KeyValueIndexed Database Replication', function () {
all2.push(keyValue)
}
deepStrictEqual(err, undefined)
deepStrictEqual(all2.map(e => { return { key: e.key, value: e.value } }), [
{ key: 'init', value: true },
{ key: 'hello', value: 'friend' }