feat: Bring libp2p-websocket-star to the Transports family! 🌟 (#122)

* test: add libp2p-websocket-star tests

* refactor: websocket-star-{signal => rendezvous}

* misc: Apply requested changes

* chore: update deps

* refactor: considerable amount of refactor, clean up test structure

* use right flag

* test: refactor transport tests
This commit is contained in:
Maciej Krüger
2017-11-27 10:10:36 +01:00
committed by David Dias
parent 38a68a01b7
commit 95f029eb7a
23 changed files with 1208 additions and 1087 deletions

45
test/utils/node.js Normal file
View File

@ -0,0 +1,45 @@
/* eslint-env mocha */
'use strict'
const chai = require('chai')
chai.use(require('dirty-chai'))
const Node = require('./bundle.node')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const waterfall = require('async/waterfall')
const pull = require('pull-stream')
function createNode (multiaddrs, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
options = options || {}
if (!Array.isArray(multiaddrs)) {
multiaddrs = [multiaddrs]
}
waterfall([
(cb) => PeerId.create({ bits: 1024 }, cb),
(peerId, cb) => PeerInfo.create(peerId, cb),
(peerInfo, cb) => {
multiaddrs.map((ma) => peerInfo.multiaddrs.add(ma))
cb(null, peerInfo)
},
(peerInfo, cb) => {
const node = new Node(peerInfo, undefined, options)
cb(null, node)
}
], callback)
}
function echo (protocol, conn) {
pull(conn, conn)
}
module.exports = {
createNode: createNode,
echo: echo
}