Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
chore: address review
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Feb 14, 2020
1 parent 128e4a1 commit d34c063
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"it-pair": "^1.0.0",
"multiaddr": "^7.3.0"
"it-pipe": "^1.1.0",
"multiaddr": "^7.3.0",
"streaming-iterables": "^4.1.2"
},
"dependencies": {
"abortable-iterator": "^3.0.0",
Expand Down
18 changes: 18 additions & 0 deletions test/stream-to-ma-conn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const expect = chai.expect
chai.use(dirtyChai)

const pair = require('it-pair')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')
const multiaddr = require('multiaddr')

const streamToMaConn = require('../src/stream-to-ma-conn')
Expand Down Expand Up @@ -35,4 +37,20 @@ describe('Convert stream into a multiaddr connection', () => {
maConn.close()
expect(maConn.timeline.close).to.exist()
})

it('can stream data over the multiaddr connection', async () => {
const stream = pair()
const maConn = streamToMaConn({ stream })

const data = 'hey'
const streamData = await pipe(
[data],
maConn,
collect
)

expect(streamData).to.eql([data])
// underlying stream end closes the connection
expect(maConn.timeline.close).to.exist()
})
})

0 comments on commit d34c063

Please sign in to comment.