mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 18:02:28 +00:00
base tests
This commit is contained in:
parent
30a754b92d
commit
1d0cc68645
@ -24,5 +24,8 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/diasdavid/abstract-stream-muxer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/diasdavid/abstract-stream-muxer"
|
||||
"homepage": "https://github.com/diasdavid/abstract-stream-muxer",
|
||||
"dependencies": {
|
||||
"stream-pair": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,51 @@
|
||||
var streamPair = require('stream-pair')
|
||||
|
||||
module.exports.all = function (test, common) {
|
||||
test('see if this works', function (t) {
|
||||
common.setup(test, function (err, muxer) {
|
||||
|
||||
test('Open a stream from the dealer', function (t) {
|
||||
common.setup(test, function (err, Muxer) {
|
||||
t.plan(4)
|
||||
t.ifError(err, 'Should not throw')
|
||||
// write test here
|
||||
t.end()
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
module.exports = function (test, common) {
|
||||
require('./base-test.js').all(test, common)
|
||||
require('./stress-test.js').all(test, common)
|
||||
}
|
||||
|
30
tests/stress-test.js
Normal file
30
tests/stress-test.js
Normal file
@ -0,0 +1,30 @@
|
||||
/* knobs - nStreams, nMsg, sizeMsg[low, high] */
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user