forked from libp2p/js-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aegir.js
46 lines (42 loc) · 1.17 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
import { pipe } from 'it-pipe'
/** @type {import('aegir/types').PartialOptions} */
export default {
test: {
async before () {
const { multiaddr } = await import('@multiformats/multiaddr')
const { mockRegistrar, mockUpgrader } = await import('@libp2p/interface-compliance-tests/mocks')
const { EventEmitter } = await import('@libp2p/interface/events')
const { webSockets } = await import('./dist/src/index.js')
const protocol = '/echo/1.0.0'
const registrar = mockRegistrar()
registrar.handle(protocol, ({ stream }) => {
void pipe(
stream,
stream
)
})
const upgrader = mockUpgrader({
registrar,
events: new EventEmitter()
})
const ws = webSockets()()
const ma = multiaddr('/ip4/127.0.0.1/tcp/9095/ws')
const listener = ws.createListener({
upgrader
})
await listener.listen(ma)
listener.addEventListener('error', (evt) => {
console.error(evt.detail)
})
return {
listener
}
},
async after (_, before) {
await before.listener.close()
}
},
build: {
bundlesizeMax: '18kB'
}
}