mirror of
https://github.com/fluencelabs/js-libp2p-websockets
synced 2025-06-12 15:41:34 +00:00
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:
10
test/node.js
10
test/node.js
@ -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)
|
||||
|
Reference in New Issue
Block a user