This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSailplaneNode.test.js
67 lines (54 loc) · 1.73 KB
/
SailplaneNode.test.js
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
56
57
58
59
60
61
62
63
64
65
66
67
'use strict'
const assert = require('assert')
const rmrf = require('rimraf')
const path = require('path')
const OrbitDB = require('orbit-db')
const SailplaneNode = require('../src')
const {
config,
startIpfs,
stopIpfs,
testAPIs
} = require('orbit-db-test-utils')
const dbPath = './orbitdb/tests/sailplane-node'
const ipfsPath = './orbitdb/tests/sailplane-node/ipfs'
Object.keys(testAPIs).forEach(API => {
describe(`Sailplane Node (${API})`, function () {
this.timeout(config.timeout)
let ipfsd, ipfs, orbitdb1, sailplane1, address1, sharedfs1
before(async () => {
config.daemon1.repo = ipfsPath
rmrf.sync(config.daemon1.repo)
ipfsd = await startIpfs(API, config.daemon1)
ipfs = ipfsd.api
orbitdb1 = await OrbitDB.createInstance(ipfs, { directory: path.join(dbPath, '1') })
})
after(async () => {
if (sailplane1) {
await sailplane1.stop()
assert.strict.deepEqual(sailplane1.mounted, {})
}
if (orbitdb1) {
await orbitdb1.stop()
}
if (ipfsd) {
await stopIpfs(ipfsd)
}
})
it('create an instance of Sailplane', async function () {
sailplane1 = await SailplaneNode.create(orbitdb1)
})
it('determine sharedfs address', async function () {
const config = { accessController: { write: ['*'] } }
address1 = await sailplane1.determineAddress('sailplane-drive', config)
assert.strict.equal(
address1.toString(),
'/orbitdb/zdpuAsTJLAXJQTYfG6qDNGmH7XphJ5QJX1uxcrrSvQPdNLVHv/sailplane-drive'
)
})
it('mount a sharedfs', async function () {
sharedfs1 = await sailplane1.mount(address1)
assert.strict.equal(sharedfs1, sailplane1.mounted[address1])
})
})
})