mirror of
https://github.com/fluencelabs/js-libp2p-websockets
synced 2025-05-02 10:42:26 +00:00
fix: tests
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
This commit is contained in:
parent
f674122b6f
commit
24d0a6132a
@ -2,13 +2,11 @@
|
||||
|
||||
const multiaddr = require('multiaddr')
|
||||
const pipe = require('it-pipe')
|
||||
|
||||
const WS = require('./src')
|
||||
|
||||
let listener
|
||||
|
||||
function boot (done) {
|
||||
console.log('boot!')
|
||||
const ws = new WS()
|
||||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9095/ws')
|
||||
listener = ws.createListener(conn => pipe(conn, conn))
|
||||
@ -17,7 +15,6 @@ function boot (done) {
|
||||
}
|
||||
|
||||
function shutdown (done) {
|
||||
console.log('shutdown')
|
||||
listener.close().then(done).catch(done)
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
"chai": "^4.1.2",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"interface-transport": "github:libp2p/interface-transport#feat/async-await",
|
||||
"it-goodbye": "^1.0.0",
|
||||
"it-goodbye": "^2.0.0",
|
||||
"it-pipe": "^1.0.0",
|
||||
"multiaddr": "^6.0.3",
|
||||
"pull-goodbye": "0.0.2",
|
||||
|
@ -11,7 +11,7 @@ const createListener = require('./listener')
|
||||
class WebSockets {
|
||||
async dial (ma, options) {
|
||||
log('dialing %s', ma)
|
||||
const socket = connect(toUri(ma), { binary: true })
|
||||
const socket = connect(toUri(ma), Object.assign({ binary: true }, options))
|
||||
await socket.connected()
|
||||
socket.getObservedAddrs = () => [ma]
|
||||
log('connected %s', ma)
|
||||
|
@ -74,8 +74,8 @@ describe('adapter libp2p-websockets', () => {
|
||||
pull(s, conn, s)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('.createServer throws in browser', () => {
|
||||
expect(new WS().createListener).to.throw()
|
||||
it('.createServer throws in browser', () => {
|
||||
expect(new WS().createListener).to.throw()
|
||||
})
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ const { collect, take } = require('streaming-iterables')
|
||||
|
||||
const WS = require('../src')
|
||||
|
||||
// require('./adapter/browser')
|
||||
require('./adapter/browser')
|
||||
|
||||
describe('libp2p-websockets', () => {
|
||||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9095/ws')
|
||||
@ -26,7 +26,7 @@ describe('libp2p-websockets', () => {
|
||||
})
|
||||
|
||||
it('echo', async () => {
|
||||
const message = 'Hello World!'
|
||||
const message = Buffer.from('Hello World!')
|
||||
const s = goodbye({ source: [message], sink: collect })
|
||||
|
||||
const results = await pipe(s, conn, s)
|
||||
@ -60,8 +60,8 @@ describe('libp2p-websockets', () => {
|
||||
expect(result).to.have.length(20000)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('.createServer throws in browser', () => {
|
||||
expect(new WS().createListener).to.throw()
|
||||
it('.createServer throws in browser', () => {
|
||||
expect(new WS().createListener).to.throw()
|
||||
})
|
||||
})
|
||||
|
@ -195,7 +195,7 @@ describe('dial', () => {
|
||||
|
||||
const result = await pipe(s, conn, s)
|
||||
|
||||
expect(result).to.be.eql(['hey'])
|
||||
expect(result).to.be.eql([Buffer.from('hey')])
|
||||
})
|
||||
|
||||
it('dial with IPFS Id', async () => {
|
||||
@ -205,7 +205,7 @@ describe('dial', () => {
|
||||
|
||||
const result = await pipe(s, conn, s)
|
||||
|
||||
expect(result).to.be.eql(['hey'])
|
||||
expect(result).to.be.eql([Buffer.from('hey')])
|
||||
})
|
||||
})
|
||||
|
||||
@ -228,7 +228,7 @@ describe('dial', () => {
|
||||
|
||||
const result = await pipe(s, conn, s)
|
||||
|
||||
expect(result).to.be.eql(['hey'])
|
||||
expect(result).to.be.eql([Buffer.from('hey')])
|
||||
})
|
||||
|
||||
it('dial with IPFS Id', async () => {
|
||||
@ -241,7 +241,7 @@ describe('dial', () => {
|
||||
})
|
||||
|
||||
const result = await pipe(s, conn, s)
|
||||
expect(result).to.be.eql(['hey'])
|
||||
expect(result).to.be.eql([Buffer.from('hey')])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user