-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-replicator-bootstrap.ts
55 lines (42 loc) · 1.74 KB
/
test-replicator-bootstrap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { start } from '@libp2p/interfaces/startable'
import { assert } from 'aegir/chai'
import { type SetupComponents, setup, teardown } from './utils/replicator.js'
import { bootstrapReplicator, type BootstrapReplicator } from '@/replicator/bootstrap/index.js'
// import { isBrowser } from 'wherearewe'
const testName = 'bootstrap-replicator'
// let _describe: Mocha.SuiteFunction | Mocha.PendingSuiteFunction
// if (isBrowser) {
// // eslint-disable-next-line no-console
// console.log('no web3.storage token found at .w3_token. skipping zzzync replicator tests')
// _describe = describe.skip
// } else {
// _describe = describe
// }
describe.skip(testName, () => {
let components: SetupComponents<BootstrapReplicator>
before(async () => {
components = await setup(testName, bootstrapReplicator({ reverseSync: false }))
})
after(async () => {
await teardown(components)
})
describe('instance', () => {
it('replicates replica entries and identities on startup', async () => {
await start(components.replicator1)
await components.replica1.write(new Uint8Array())
const updatePromise = new Promise(resolve => {
components.replica2.events.addEventListener('update', resolve, { once: true })
})
await Promise.all([
components.libp2p1.dial(components.addr2),
new Promise(resolve => { components.libp2p2.addEventListener('peer:connect', resolve, { once: true }) })
])
await start(components.replicator2)
await updatePromise
if (components.replica1.root == null || components.replica2.root == null) {
throw new Error('replica root is null')
}
assert.equal(components.replica1.root.toString(), components.replica2.root.toString())
})
})
})