mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 21:22:33 +00:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
var streamPair = require('stream-pair')
|
|
|
|
module.exports.all = function (test, common) {
|
|
|
|
test('Open a stream from the dealer', function (t) {
|
|
common.setup(test, function (err, Muxer) {
|
|
t.plan(4)
|
|
t.ifError(err, 'Should not throw')
|
|
|
|
var pair = streamPair.create()
|
|
var dialer = new Muxer()
|
|
var listener = new Muxer()
|
|
|
|
var connDialer = dialer.attach(pair)
|
|
var connListener = listener.attach(pair.other)
|
|
|
|
connDialer.dialStream(function (err, stream) {
|
|
t.ifError(err, 'Should not throw')
|
|
t.pass('dialed stream')
|
|
})
|
|
|
|
connListener.on('stream', function (stream) {
|
|
t.pass('got stream')
|
|
})
|
|
})
|
|
})
|
|
|
|
test('Open a stream from the listener', function (t) {
|
|
common.setup(test, function (err, Muxer) {
|
|
t.plan(4)
|
|
t.ifError(err, 'Should not throw')
|
|
|
|
var pair = streamPair.create()
|
|
var dialer = new Muxer()
|
|
var listener = new Muxer()
|
|
|
|
var connDialer = dialer.attach(pair)
|
|
var connListener = listener.attach(pair.other)
|
|
|
|
connListener.dialStream(function (err, stream) {
|
|
t.ifError(err, 'Should not throw')
|
|
t.pass('dialed stream')
|
|
})
|
|
|
|
connDialer.on('stream', function (stream) {
|
|
t.pass('got stream')
|
|
})
|
|
})
|
|
})
|
|
|
|
}
|