This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathroutes.js
89 lines (73 loc) · 2.14 KB
/
routes.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* eslint-env mocha */
'use strict'
const fs = require('fs')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
chai.use(dirtyChai)
const hat = require('hat')
const Daemon = require('../../src/cli/daemon')
const promisify = require('promisify-es6')
const ncp = promisify(require('ncp').ncp)
const path = require('path')
const clean = require('../utils/clean')
describe('HTTP API', () => {
const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo')
const repoTests = path.join(__dirname, '../repo-tests-run')
// bootstrap nodes get the set up too slow and gets timed out
const testsForCustomConfig = ['dht.js', 'files.js', 'name.js', 'pin.js', 'ping.js']
const http = {}
const startHttpAPI = async (config) => {
http.api = new Daemon({
repo: repoTests,
pass: hat(),
config,
preload: { enabled: false }
})
await ncp(repoExample, repoTests)
await http.api.start()
}
describe('custom config', () => {
const config = {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
}
before(async function () {
this.timeout(60 * 1000)
await startHttpAPI(config)
})
after(async function () {
this.timeout(50 * 1000)
await http.api.stop()
await clean(repoTests)
})
describe('## http-api spec tests for custom config', () => {
fs.readdirSync(path.join(`${__dirname}/inject/`))
.forEach((file) => testsForCustomConfig.includes(file) && require(`./inject/${file}`)(http))
})
})
describe('default config', () => {
const config = {
Bootstrap: []
}
before(async function () {
this.timeout(60 * 1000)
await startHttpAPI(config)
})
after(async function () {
this.timeout(50 * 1000)
await http.api.stop()
await clean(repoTests)
})
describe('## http-api spec tests for default config', () => {
fs.readdirSync(path.join(`${__dirname}/inject/`))
.forEach((file) => !testsForCustomConfig.includes(file) && require(`./inject/${file}`)(http))
})
})
})