Alan Shaw 24d0a6132a
fix: tests
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
2019-04-17 12:34:56 +01:00

29 lines
544 B
JavaScript

'use strict'
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const WS = require('./src')
let listener
function boot (done) {
const ws = new WS()
const ma = multiaddr('/ip4/127.0.0.1/tcp/9095/ws')
listener = ws.createListener(conn => pipe(conn, conn))
listener.listen(ma).then(() => done()).catch(done)
listener.on('error', console.error)
}
function shutdown (done) {
listener.close().then(done).catch(done)
}
module.exports = {
hooks: {
browser: {
pre: boot,
post: shutdown
}
}
}