This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cc3130f
feat(pull): migration to pull streams. Upgrade tests to use mocha as
dignifiedquire 99d07ad
docs(readme): update it to reference pull-streams
daviddias 5069679
feat(api): update the interface usage from dial to dialer and listen …
daviddias c06da3b
feat(tests): add closing tests, make sure errors are propagated
dignifiedquire 98b08fd
docs(readme): update spec and code accordingly
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
**/node_modules/ | ||
**/*.log | ||
test/repo-tests* | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
coverage | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
build | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "stable" | ||
|
||
before_install: | ||
- npm install -g npm | ||
|
||
script: | ||
- npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('chai-checkmark')) | ||
const expect = chai.expect | ||
const pair = require('pull-pair/duplex') | ||
const pull = require('pull-stream') | ||
|
||
function closeAndWait (stream) { | ||
pull( | ||
pull.empty(), | ||
stream, | ||
pull.onEnd((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
) | ||
} | ||
|
||
module.exports = (common) => { | ||
describe('base', () => { | ||
let muxer | ||
|
||
beforeEach((done) => { | ||
common.setup((err, _muxer) => { | ||
if (err) return done(err) | ||
muxer = _muxer | ||
done() | ||
}) | ||
}) | ||
|
||
it('Open a stream from the dialer', (done) => { | ||
const p = pair() | ||
const dialer = muxer.dialer(p[0]) | ||
const listener = muxer.listener(p[1]) | ||
|
||
expect(4).checks(done) | ||
|
||
listener.on('stream', (stream) => { | ||
expect(stream).to.exist.mark() | ||
closeAndWait(stream) | ||
}) | ||
|
||
const conn = dialer.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
closeAndWait(conn) | ||
}) | ||
|
||
it('Open a stream from the listener', (done) => { | ||
const p = pair() | ||
const dialer = muxer.dialer(p[0]) | ||
const listener = muxer.listener(p[1]) | ||
|
||
expect(4).check(done) | ||
|
||
dialer.on('stream', (stream) => { | ||
expect(stream).to.exist.mark() | ||
closeAndWait(stream) | ||
}) | ||
|
||
const conn = listener.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
closeAndWait(conn) | ||
}) | ||
|
||
it('Open a stream on both sides', (done) => { | ||
const p = pair() | ||
const dialer = muxer.dialer(p[0]) | ||
const listener = muxer.listener(p[1]) | ||
|
||
expect(8).check(done) | ||
|
||
dialer.on('stream', (stream) => { | ||
expect(stream).to.exist.mark() | ||
closeAndWait(stream) | ||
}) | ||
|
||
const listenerConn = listener.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
listener.on('stream', (stream) => { | ||
expect(stream).to.exist.mark() | ||
closeAndWait(stream) | ||
}) | ||
|
||
const dialerConn = dialer.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
closeAndWait(dialerConn) | ||
closeAndWait(listenerConn) | ||
}) | ||
|
||
it('Open a stream on one side, write, open a stream in the other side', (done) => { | ||
const p = pair() | ||
const dialer = muxer.dialer(p[0]) | ||
const listener = muxer.listener(p[1]) | ||
|
||
expect(6).check(done) | ||
|
||
const dialerConn = dialer.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
pull( | ||
pull.values(['hey']), | ||
dialerConn | ||
) | ||
|
||
listener.on('stream', (stream) => { | ||
pull( | ||
stream, | ||
pull.collect((err, chunks) => { | ||
expect(err).to.not.exist.mark() | ||
expect(chunks).to.be.eql([Buffer('hey')]).mark() | ||
}) | ||
) | ||
|
||
const listenerConn = listener.newStream((err) => { | ||
expect(err).to.not.exist.mark() | ||
}) | ||
|
||
pull( | ||
pull.values(['hello']), | ||
listenerConn | ||
) | ||
|
||
dialer.on('stream', onDialerStream) | ||
function onDialerStream (stream) { | ||
pull( | ||
stream, | ||
pull.collect((err, chunks) => { | ||
expect(err).to.not.exist.mark() | ||
expect(chunks).to.be.eql([Buffer('hello')]).mark() | ||
}) | ||
) | ||
} | ||
}) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚲🏚👮🏽