mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-07-03 02:52:30 +00:00
Lint
This commit is contained in:
parent
375296e68d
commit
b3120da26f
@ -666,27 +666,27 @@ describe('Sync protocol', function () {
|
|||||||
describe('Events - error listener', () => {
|
describe('Events - error listener', () => {
|
||||||
let sync1, sync2
|
let sync1, sync2
|
||||||
let log1, log2
|
let log1, log2
|
||||||
|
|
||||||
const timeoutTime = 1 // 1 millisecond
|
const timeoutTime = 1 // 1 millisecond
|
||||||
const unhandledErrors = []
|
const unhandledErrors = []
|
||||||
const handleError = (err) => {
|
const handleError = (err) => {
|
||||||
unhandledErrors.push(err)
|
unhandledErrors.push(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
[ipfs1, ipfs2] = await Promise.all([createHelia(), createHelia()])
|
[ipfs1, ipfs2] = await Promise.all([createHelia(), createHelia()])
|
||||||
|
|
||||||
peerId1 = ipfs1.libp2p.peerId
|
peerId1 = ipfs1.libp2p.peerId
|
||||||
peerId2 = ipfs2.libp2p.peerId
|
peerId2 = ipfs2.libp2p.peerId
|
||||||
|
|
||||||
await connectPeers(ipfs1, ipfs2)
|
await connectPeers(ipfs1, ipfs2)
|
||||||
|
|
||||||
log1 = await Log(testIdentity1, { logId: 'synclog6' })
|
log1 = await Log(testIdentity1, { logId: 'synclog6' })
|
||||||
log2 = await Log(testIdentity2, { logId: 'synclog6' })
|
log2 = await Log(testIdentity2, { logId: 'synclog6' })
|
||||||
|
|
||||||
process.on('unhandledRejection', handleError)
|
process.on('unhandledRejection', handleError)
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (sync1) {
|
if (sync1) {
|
||||||
await sync1.stop()
|
await sync1.stop()
|
||||||
@ -700,24 +700,24 @@ describe('Sync protocol', function () {
|
|||||||
if (log2) {
|
if (log2) {
|
||||||
await log2.close()
|
await log2.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
await ipfs1.stop()
|
await ipfs1.stop()
|
||||||
await ipfs2.stop()
|
await ipfs2.stop()
|
||||||
|
|
||||||
if (typeof process !== 'undefined') { process.off('unhandledRejection', handleError) }
|
if (typeof process !== 'undefined') { process.off('unhandledRejection', handleError) }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not crash when no listeners are attached to the `error` event on `Sync.events`', async () => {
|
it('does not crash when no listeners are attached to the `error` event on `Sync.events`', async () => {
|
||||||
sync1 = await Sync({ ipfs: ipfs1, log: log1, timeout: timeoutTime })
|
sync1 = await Sync({ ipfs: ipfs1, log: log1, timeout: timeoutTime })
|
||||||
sync2 = await Sync({ ipfs: ipfs2, log: log2, start: false, timeout: timeoutTime })
|
sync2 = await Sync({ ipfs: ipfs2, log: log2, start: false, timeout: timeoutTime })
|
||||||
|
|
||||||
await log1.append('hello1')
|
await log1.append('hello1')
|
||||||
|
|
||||||
await sync2.start()
|
await sync2.start()
|
||||||
|
|
||||||
// Be sure to wait long enough for the timeout to cancel the operation with an error
|
// Be sure to wait long enough for the timeout to cancel the operation with an error
|
||||||
await new Promise(resolve => setTimeout(resolve, timeoutTime + 10))
|
await new Promise(resolve => setTimeout(resolve, timeoutTime + 10))
|
||||||
|
|
||||||
// Test that no unhandled abort error has been thrown
|
// Test that no unhandled abort error has been thrown
|
||||||
const err = unhandledErrors.find(e => e.code === 'ABORT_ERR')
|
const err = unhandledErrors.find(e => e.code === 'ABORT_ERR')
|
||||||
strictEqual(err, undefined)
|
strictEqual(err, undefined)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user