forked from libp2p/js-libp2p-secio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (34 loc) · 883 Bytes
/
gulpfile.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
'use strict'
const gulp = require('gulp')
const multiaddr = require('multiaddr')
const pull = require('pull-stream')
const WS = require('libp2p-websockets')
const PeerId = require('peer-id')
const peerNodeJSON = require('./test/peer-node.json')
const secio = require('./src')
let listener
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ws')
gulp.task('test:browser:before', (done) => {
PeerId.createFromJSON(peerNodeJSON, (err, id) => {
if (err) {
throw err
}
const ws = new WS()
listener = ws.createListener((conn) => {
const encrypted = secio.encrypt(id, id._privKey, conn, (err) => {
if (err) {
throw err
}
})
pull(
encrypted,
encrypted
)
})
listener.listen(ma, done)
})
})
gulp.task('test:browser:after', (done) => {
listener.close(done)
})
require('aegir/gulp')(gulp)