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

Commit

Permalink
fix: update all deps (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Aug 10, 2022
1 parent 04f162d commit 4825cd7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"release": "aegir release"
},
"dependencies": {
"@libp2p/interface-connection": "^2.0.0",
"@libp2p/interface-connection": "^3.0.1",
"@libp2p/interface-transport": "^1.0.0",
"@libp2p/interfaces": "^3.0.1",
"@libp2p/logger": "^2.0.0",
Expand All @@ -166,21 +166,23 @@
"err-code": "^3.0.1",
"it-ws": "^5.0.0",
"p-defer": "^4.0.0",
"p-timeout": "^5.0.2",
"p-timeout": "^6.0.0",
"wherearewe": "^1.0.0"
},
"devDependencies": {
"@libp2p/interface-mocks": "^3.0.1",
"@libp2p/interface-transport-compliance-tests": "^2.0.0",
"@libp2p/interface-mocks": "^4.0.1",
"@libp2p/interface-transport-compliance-tests": "^2.0.5",
"@types/ws": "^8.2.2",
"aegir": "^37.2.0",
"is-loopback-addr": "^2.0.1",
"it-all": "^1.0.6",
"it-drain": "^1.0.5",
"it-goodbye": "^4.0.1",
"it-pipe": "^2.0.3",
"it-stream-types": "^1.0.4",
"it-take": "^1.0.2",
"p-wait-for": "^4.1.0",
"p-wait-for": "^5.0.0",
"uint8arraylist": "^2.3.2",
"uint8arrays": "^3.0.0"
},
"browser": {
Expand Down
4 changes: 3 additions & 1 deletion src/socket-to-conn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export function socketToMaConn (stream: DuplexWebSocket, remoteAddr: Multiaddr,
const start = Date.now()

try {
await pTimeout(stream.close(), CLOSE_TIMEOUT)
await pTimeout(stream.close(), {
milliseconds: CLOSE_TIMEOUT
})
} catch (err) {
const { host, port } = maConn.remoteAddr.toOptions()
log('timeout closing stream to %s:%s after %dms, destroying it manually',
Expand Down
6 changes: 3 additions & 3 deletions test/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('libp2p-websockets', () => {
async (source) => await all(source)
)

expect(res).to.deep.equal([data])
expect(res[0].subarray()).to.equalBytes(data)
})

it('should filter out no DNS websocket addresses', function () {
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('libp2p-websockets', () => {
async (source) => await all(source)
)

expect(res).to.deep.equal([data])
expect(res[0].subarray()).to.deep.equal(data)
})

it('many writes', async function () {
Expand All @@ -81,7 +81,7 @@ describe('libp2p-websockets', () => {
async (source) => await all(source)
)

expect(res).to.deep.equal(data)
expect(res.map(list => list.subarray())).to.deep.equal(data)
})
})

Expand Down
26 changes: 19 additions & 7 deletions test/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ import { WebSockets } from '../src/index.js'
import * as filters from '../src/filters.js'
import drain from 'it-drain'
import type { Listener } from '@libp2p/interface-transport'

import type { Uint8ArrayList } from 'uint8arraylist'
import type { Source } from 'it-stream-types'
import './compliance.node.js'

async function * toBuffers (source: Source<Uint8ArrayList>) {
for await (const list of source) {
yield * list
}
}

const protocol = '/say-hello/1.0.0'
const registrar = mockRegistrar()
void registrar.handle(protocol, (evt) => {
Expand Down Expand Up @@ -238,7 +245,7 @@ describe('dial', () => {
const conn = await ws.dial(ma, { upgrader })
const stream = await conn.newStream([protocol])

await expect(all(stream.source)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
expect((await all(stream.source)).map(list => list.subarray())).to.deep.equal([uint8ArrayFromString('hey')])
await conn.close()
})

Expand All @@ -247,7 +254,7 @@ describe('dial', () => {
const conn = await ws.dial(ma, { upgrader })
const stream = await conn.newStream([protocol])

await expect(all(stream.source)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
expect((await all(stream.source)).map(list => list.subarray())).to.deep.equal([uint8ArrayFromString('hey')])
await conn.close()
})

Expand Down Expand Up @@ -319,7 +326,12 @@ describe('dial', () => {
const s = goodbye({ source: [uint8ArrayFromString('hey')], sink: all })
const stream = await conn.newStream([protocol])

await expect(pipe(s, stream, s)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
await expect(pipe(
s,
stream,
toBuffers,
s
)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
})
})

Expand Down Expand Up @@ -363,7 +375,7 @@ describe('dial', () => {
const s = goodbye({ source: [uint8ArrayFromString('hey')], sink: all })
const stream = await conn.newStream([protocol])

const res = await pipe(s, stream, s)
const res = await pipe(s, stream, toBuffers, s)

expect(res[0]).to.equalBytes(uint8ArrayFromString('hey'))
await conn.close()
Expand Down Expand Up @@ -395,7 +407,7 @@ describe('dial', () => {
const s = goodbye({ source: [uint8ArrayFromString('hey')], sink: all })
const stream = await conn.newStream([protocol])

await expect(pipe(s, stream, s)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
await expect(pipe(s, stream, toBuffers, s)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
})

it('dial with p2p Id', async () => {
Expand All @@ -408,7 +420,7 @@ describe('dial', () => {
})
const stream = await conn.newStream([protocol])

await expect(pipe(s, stream, s)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
await expect(pipe(s, stream, toBuffers, s)).to.eventually.deep.equal([uint8ArrayFromString('hey')])
})
})
})
Expand Down

0 comments on commit 4825cd7

Please sign in to comment.