-
Notifications
You must be signed in to change notification settings - Fork 6
/
.aegir.js
69 lines (58 loc) · 1.89 KB
/
.aegir.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
import { resolve } from 'node:path'
import { tmpdir } from 'node:os'
import { createDelegatedRoutingV1HttpApiServer } from '@helia/delegated-routing-v1-http-api-server'
import { stubInterface } from 'sinon-ts'
const IPFS_PATH = resolve(tmpdir(), 'verified-fetch-interop-ipfs-repo')
/** @type {import('aegir').PartialOptions} */
export default {
dependencyCheck: {
ignore: [
'@helia/delegated-routing-v1-http-api-server',
'sinon-ts'
]
},
test: {
files: './dist/src/*.spec.js',
before: async () => {
const { createKuboNode } = await import('./dist/src/fixtures/create-kubo.js')
const kuboNode = await createKuboNode(IPFS_PATH)
await kuboNode.start()
// requires aegir build to be run first, which it will by default.
const { loadFixtures } = await import('./dist/src/fixtures/load-fixtures.js')
await loadFixtures(IPFS_PATH)
const multiaddrs = (await kuboNode.api.id()).addresses
const id = (await kuboNode.api.id()).id
const helia = stubInterface({
routing: stubInterface({
findProviders: async function * findProviders () {
yield {
multiaddrs,
id,
protocols: ['transport-bitswap']
}
}
})
})
const routingServer = await createDelegatedRoutingV1HttpApiServer(helia, {
listen: {
host: '127.0.0.1',
port: 0
}
})
await routingServer.ready()
const address = routingServer.server.address()
const port = typeof address === 'string' ? address : address?.port
return {
kuboNode,
routingServer,
env: {
KUBO_DIRECT_RETRIEVAL_ROUTER: `http://127.0.0.1:${port}`
}
}
},
after: async (_options, beforeResult) => {
await beforeResult.kuboNode.stop()
await beforeResult.routingServer.close()
}
}
}