mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-06-13 03:41:35 +00:00
base tests
This commit is contained in:
@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
Reference in New Issue
Block a user