Merge pull request #10 from libp2p/fix-tcp

fix(dial-test): ensure goodbye works over tcp
This commit is contained in:
David Dias 2016-09-06 08:29:18 -04:00 committed by GitHub
commit 4eea5bb4a8
2 changed files with 13 additions and 16 deletions

View File

@ -38,6 +38,7 @@
"chai": "^3.5.0", "chai": "^3.5.0",
"multiaddr": "^2.0.2", "multiaddr": "^2.0.2",
"pull-goodbye": "0.0.1", "pull-goodbye": "0.0.1",
"pull-serializer": "^0.3.2",
"pull-stream": "^3.4.4" "pull-stream": "^3.4.4"
}, },
"contributors": [ "contributors": [
@ -46,4 +47,4 @@
"Richard Littauer <richard.littauer@gmail.com>", "Richard Littauer <richard.littauer@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>" "greenkeeperio-bot <support@greenkeeper.io>"
] ]
} }

View File

@ -4,6 +4,7 @@
const expect = require('chai').expect const expect = require('chai').expect
const pull = require('pull-stream') const pull = require('pull-stream')
const goodbye = require('pull-goodbye') const goodbye = require('pull-goodbye')
const serializer = require('pull-serializer')
module.exports = (common) => { module.exports = (common) => {
describe('dial', () => { describe('dial', () => {
@ -26,16 +27,7 @@ module.exports = (common) => {
beforeEach((done) => { beforeEach((done) => {
listener = transport.createListener((conn) => { listener = transport.createListener((conn) => {
pull( pull(conn, conn)
conn,
pull.map((x) => {
if (x.toString() !== 'GOODBYE') {
return new Buffer(x.toString() + '!')
}
return x
}),
conn
)
}) })
listener.listen(addrs[0], done) listener.listen(addrs[0], done)
}) })
@ -45,20 +37,24 @@ module.exports = (common) => {
}) })
it('simple', (done) => { it('simple', (done) => {
const s = goodbye({ const s = serializer(goodbye({
source: pull.values([new Buffer('hey')]), source: pull.values(['hey']),
sink: pull.collect((err, values) => { sink: pull.collect((err, values) => {
expect(err).to.not.exist expect(err).to.not.exist
expect( expect(
values values
).to.be.eql( ).to.be.eql(
[new Buffer('hey!')] ['hey']
) )
done() done()
}) })
}) }))
pull(s, transport.dial(addrs[0]), s) pull(
s,
transport.dial(addrs[0]),
s
)
}) })
it('to non existent listener', (done) => { it('to non existent listener', (done) => {