mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 20:02:20 +00:00
fix(dial-test): ensure goodbye works over tcp
This commit is contained in:
parent
95d2a2c4d1
commit
e1346da0f1
@ -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>"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user