more tests and readme up

This commit is contained in:
David Dias 2015-07-11 19:17:33 -07:00
parent 1d0cc68645
commit 43e6ccf0f6
3 changed files with 13 additions and 20 deletions

View File

@ -13,7 +13,7 @@ The API is presented with both Node.js and Go primitives, however, there is not
# Modules that implement the interface # Modules that implement the interface
- - [https://github.com/diasdavid/node-spdy-stream-muxer](Node.js spdy-stream-muxer) - stream-muxer abstraction on top of [spdy-transport](https://github.com/indutny/spdy-transport)
Send a PR to add a new one if you happen to find or write one. Send a PR to add a new one if you happen to find or write one.

View File

@ -26,6 +26,7 @@
}, },
"homepage": "https://github.com/diasdavid/abstract-stream-muxer", "homepage": "https://github.com/diasdavid/abstract-stream-muxer",
"dependencies": { "dependencies": {
"dev-null": "^0.1.1",
"stream-pair": "^1.0.3" "stream-pair": "^1.0.3"
} }
} }

View File

@ -1,30 +1,22 @@
/* knobs - nStreams, nMsg, sizeMsg[low, high] */
var streamPair = require('stream-pair') var streamPair = require('stream-pair')
var devNull = require('dev-null')
module.exports.all = function (test, common) { module.exports.all = function (test, common) {
test('Open a stream from the dealer', function (t) { test('1 stream with 10Mb file', function (t) {
common.setup(test, function (err, Muxer) { common.setup(test, function (err, Muxer) {
t.plan(4) t.ifError(err, 'should not throw')
t.ifError(err, 'Should not throw')
var pair = streamPair.create() var pair = streamPair.create()
var dialer = new Muxer()
var listener = new Muxer()
var connDialer = dialer.attach(pair) spawnGeneration(t, Muxer, pair, pair.other, 1, [10, 10])
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')
})
}) })
}) })
}
function spawnGeneration (t, Muxer, dialerSocket, listenerSocket, nStreams, sizeWindow) {
} }
function randSizeMsg (sizeWindow) {
return Math.floor(Math.random() * (sizeWindow[1] - sizeWindow[0] + 1)) + sizeWindow[0]
}