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

View File

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