mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 17:52:21 +00:00
add timed-tape
This commit is contained in:
parent
d566f9f96c
commit
a454989cf8
@ -26,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/diasdavid/abstract-stream-muxer",
|
"homepage": "https://github.com/diasdavid/abstract-stream-muxer",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"stream-pair": "^1.0.3"
|
"stream-pair": "^1.0.3",
|
||||||
|
"timed-tape": "^0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,51 @@ module.exports.all = function (test, common) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Open a stream on one side, write, open a stream in the other side', function (t) {
|
||||||
|
common.setup(test, function (err, Muxer) {
|
||||||
|
t.plan(9)
|
||||||
|
t.ifError(err, 'Should not throw')
|
||||||
|
|
||||||
|
var pair = streamPair.create()
|
||||||
|
var dialer = new Muxer()
|
||||||
|
var listener = new Muxer()
|
||||||
|
|
||||||
|
var connDialer = dialer.attach(pair, false)
|
||||||
|
var connListener = listener.attach(pair.other, true)
|
||||||
|
|
||||||
|
connDialer.dialStream(function (err, stream) {
|
||||||
|
t.ifError(err, 'Should not throw')
|
||||||
|
t.pass('dialed stream from dialer')
|
||||||
|
|
||||||
|
stream.write('hey')
|
||||||
|
})
|
||||||
|
|
||||||
|
connListener.on('stream', function (stream) {
|
||||||
|
t.pass('listener got stream')
|
||||||
|
|
||||||
|
stream.on('data', function (chunk) {
|
||||||
|
t.equal(chunk.toString(), 'hey')
|
||||||
|
})
|
||||||
|
|
||||||
|
connListener.dialStream(function (err, stream) {
|
||||||
|
t.ifError(err, 'Should not throw')
|
||||||
|
t.pass('dialed stream from listener')
|
||||||
|
|
||||||
|
stream.write('hello')
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
connDialer.on('stream', function (stream) {
|
||||||
|
t.pass('dialer got stream')
|
||||||
|
|
||||||
|
stream.on('data', function (chunk) {
|
||||||
|
t.equal(chunk.toString(), 'hello')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
test('Open a stream using the net.connect pattern', function (t) {
|
test('Open a stream using the net.connect pattern', function (t) {
|
||||||
common.setup(test, function (err, Muxer) {
|
common.setup(test, function (err, Muxer) {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
var timed = require('timed-tape')
|
||||||
|
|
||||||
module.exports = function (test, common, mega) {
|
module.exports = function (test, common, mega) {
|
||||||
|
test = timed(test)
|
||||||
require('./base-test.js').all(test, common)
|
require('./base-test.js').all(test, common)
|
||||||
require('./stress-test.js').all(test, common)
|
require('./stress-test.js').all(test, common)
|
||||||
if (mega) {
|
if (mega) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user