fix: support bufferlist usage (#97)

several it-* modules leverage bufferlist, but ws does not. We need to convert buffer lists to buffers before handing the data off to ws for transmission

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Jacob Heun
2019-10-30 14:23:50 +01:00
committed by GitHub
parent 5b59fc3a47
commit 3bf66d08e4
3 changed files with 17 additions and 1 deletions

View File

@ -13,6 +13,7 @@ const multiaddr = require('multiaddr')
const goodbye = require('it-goodbye')
const { collect } = require('streaming-iterables')
const pipe = require('it-pipe')
const BufferList = require('bl/BufferList')
const WS = require('../src')
@ -301,6 +302,15 @@ describe('dial', () => {
expect(result).to.be.eql([Buffer.from('hey')])
})
it('dial and use BufferList', async () => {
const conn = await ws.dial(ma)
const s = goodbye({ source: [new BufferList('hey')], sink: collect })
const result = await pipe(s, conn, s)
expect(result).to.be.eql([Buffer.from('hey')])
})
it('dial with p2p Id', async () => {
const ma = multiaddr('/ip6/::1/tcp/9091/ws/p2p/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const conn = await ws.dial(ma)