This repository was archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcircuit.js
More file actions
64 lines (50 loc) · 1.35 KB
/
circuit.js
File metadata and controls
64 lines (50 loc) · 1.35 KB
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
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
chai.use(dirtyChai)
const all = require('./circuit/all')
const browser = require('./circuit/browser')
const isNode = require('detect-node')
const send = require('./utils/circuit').send
const connect = require('./utils/circuit').connect
const timeout = 80 * 1000
const baseTest = {
connect,
send,
timeout
}
describe('circuit', () => {
const tests = all
if (!isNode) {
Object.assign(tests, browser)
}
Object.keys(tests).forEach((test) => {
let nodes
let nodeA
let relay
let nodeB
tests[test] = Object.assign({}, baseTest, tests[test])
const dsc = tests[test].skip && tests[test].skip()
? describe.skip
: describe
dsc(test, function () {
this.timeout(tests[test].timeout)
before(async () => {
const _nodes = await tests[test].create()
nodes = _nodes.map((n) => n.ipfsd)
nodeA = _nodes[0]
relay = _nodes[1]
nodeB = _nodes[2]
})
after(() => Promise.all(nodes.map((node) => node.stop())))
it('connect', (done) => {
tests[test].connect(nodeA, nodeB, relay, done)
})
it('send', (done) => {
tests[test].send(nodeA.ipfsd.api, nodeB.ipfsd.api, done)
})
})
})
})