forked from ChainSafe/js-libp2p-gossipsub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aegir.js
66 lines (56 loc) · 1.15 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
'use strict'
/**
* This file uses aegir hooks to
* set up a libp2p instance for browser nodes to relay through
* before tests start
*/
const Libp2p = require('libp2p')
const PeerId = require('peer-id')
const WS = require('libp2p-websockets')
const MPLEX = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const RelayPeer = require('./test/fixtures/relay')
let libp2p
const before = async () => {
// Use the last peer
const peerId = await PeerId.createFromJSON(RelayPeer)
libp2p = new Libp2p({
addresses: {
listen: [RelayPeer.multiaddr]
},
peerId,
modules: {
transport: [WS],
streamMuxer: [MPLEX],
connEncryption: [NOISE]
},
config: {
relay: {
enabled: true,
hop: {
enabled: true,
active: false
}
},
pubsub: {
enabled: false
}
}
})
await libp2p.start()
}
const after = async () => {
await libp2p.stop()
}
module.exports = {
hooks: {
pre: before,
post: after
},
webpack: {
node: {
// this is needed until bcrypto stops using node buffers in browser code
Buffer: true
}
}
}