From 3ed12353aa48b5a933f80042846a8f1c2337fa47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:17:51 +0200 Subject: [PATCH] deps(dev): bump aegir from 38.1.8 to 39.0.10 (#279) * deps(dev): bump aegir from 38.1.8 to 39.0.10 Bumps [aegir](https://github.com/ipfs/aegir) from 38.1.8 to 39.0.10. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipfs/aegir/compare/v38.1.8...v39.0.10) --- updated-dependencies: - dependency-name: aegir dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: fix linting * chore: fix build --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain --- package.json | 3 ++- src/index.ts | 24 ++++++++++-------------- src/listener.ts | 10 +++++----- src/socket-to-conn.ts | 8 ++++---- src/utils.ts | 4 ++-- test/compliance.spec.ts | 4 ++-- test/connection.spec.ts | 6 +++--- test/filter.spec.ts | 2 +- test/listen-dial.spec.ts | 22 +++++++++++----------- test/max-connections-close.spec.ts | 4 ++-- test/max-connections.spec.ts | 4 ++-- test/socket-to-conn.spec.ts | 5 ++--- 12 files changed, 46 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index a38eb06..fd5cf57 100644 --- a/package.json +++ b/package.json @@ -149,12 +149,13 @@ "@libp2p/utils": "^3.0.2", "@multiformats/mafmt": "^12.0.0", "@multiformats/multiaddr": "^12.0.0", + "@types/sinon": "^10.0.15", "stream-to-it": "^0.2.2" }, "devDependencies": { "@libp2p/interface-mocks": "^12.0.1", "@libp2p/interface-transport-compliance-tests": "^4.0.0", - "aegir": "^38.1.0", + "aegir": "^39.0.10", "it-all": "^3.0.1", "it-pipe": "^3.0.1", "p-defer": "^4.0.0", diff --git a/src/index.ts b/src/index.ts index 0b65271..71b5011 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,16 @@ import net from 'net' -import * as mafmt from '@multiformats/mafmt' +import { type CreateListenerOptions, type DialOptions, type Listener, symbol, type Transport } from '@libp2p/interface-transport' +import { AbortError, CodeError } from '@libp2p/interfaces/errors' import { logger } from '@libp2p/logger' +import * as mafmt from '@multiformats/mafmt' +import { CODE_CIRCUIT, CODE_P2P, CODE_UNIX } from './constants.js' +import { type CloseServerOnMaxConnectionsOpts, TCPListener } from './listener.js' import { toMultiaddrConnection } from './socket-to-conn.js' -import { CloseServerOnMaxConnectionsOpts, TCPListener } from './listener.js' import { multiaddrToNetConfig } from './utils.js' -import { AbortError, CodeError } from '@libp2p/interfaces/errors' -import { CODE_CIRCUIT, CODE_P2P, CODE_UNIX } from './constants.js' -import { CreateListenerOptions, DialOptions, Listener, symbol, Transport } from '@libp2p/interface-transport' -import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr' -import type { Socket, IpcSocketConnectOpts, TcpSocketConnectOpts } from 'net' import type { Connection } from '@libp2p/interface-connection' import type { CounterGroup, Metrics } from '@libp2p/interface-metrics' +import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr' +import type { Socket, IpcSocketConnectOpts, TcpSocketConnectOpts } from 'net' const log = logger('libp2p:tcp') @@ -94,13 +94,9 @@ class TCP implements Transport { } } - get [symbol] (): true { - return true - } + readonly [symbol] = true - get [Symbol.toStringTag] (): string { - return '@libp2p/tcp' - } + readonly [Symbol.toStringTag] = '@libp2p/tcp' async dial (ma: Multiaddr, options: TCPDialOptions): Promise { options.keepAlive = options.keepAlive ?? true @@ -149,7 +145,7 @@ class TCP implements Transport { throw new AbortError() } - return await new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const start = Date.now() const cOpts = multiaddrToNetConfig(ma) as (IpcSocketConnectOpts & TcpSocketConnectOpts) const cOptsStr = cOpts.path ?? `${cOpts.host ?? ''}:${cOpts.port}` diff --git a/src/listener.ts b/src/listener.ts index 208ce4e..016f9e4 100644 --- a/src/listener.ts +++ b/src/listener.ts @@ -1,18 +1,18 @@ import net from 'net' +import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events' import { logger } from '@libp2p/logger' -import { toMultiaddrConnection } from './socket-to-conn.js' import { CODE_P2P } from './constants.js' +import { toMultiaddrConnection } from './socket-to-conn.js' import { getMultiaddrs, multiaddrToNetConfig, - NetConfig + type NetConfig } from './utils.js' -import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events' +import type { TCPCreateListenerOptions } from './index.js' import type { MultiaddrConnection, Connection } from '@libp2p/interface-connection' +import type { CounterGroup, MetricGroup, Metrics } from '@libp2p/interface-metrics' import type { Upgrader, Listener, ListenerEvents } from '@libp2p/interface-transport' import type { Multiaddr } from '@multiformats/multiaddr' -import type { TCPCreateListenerOptions } from './index.js' -import type { CounterGroup, MetricGroup, Metrics } from '@libp2p/interface-metrics' const log = logger('libp2p:tcp:listener') diff --git a/src/socket-to-conn.ts b/src/socket-to-conn.ts index 2afb525..993776a 100644 --- a/src/socket-to-conn.ts +++ b/src/socket-to-conn.ts @@ -1,14 +1,14 @@ +import { CodeError } from '@libp2p/interfaces/errors' import { logger } from '@libp2p/logger' +import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' // @ts-expect-error no types import toIterable from 'stream-to-it' -import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' import { CLOSE_TIMEOUT, SOCKET_TIMEOUT } from './constants.js' import { multiaddrToNetConfig } from './utils.js' -import { CodeError } from '@libp2p/interfaces/errors' -import type { Socket } from 'net' -import type { Multiaddr } from '@multiformats/multiaddr' import type { MultiaddrConnection } from '@libp2p/interface-connection' import type { CounterGroup } from '@libp2p/interface-metrics' +import type { Multiaddr } from '@multiformats/multiaddr' +import type { Socket } from 'net' const log = logger('libp2p:tcp:socket') diff --git a/src/utils.ts b/src/utils.ts index 9cd2a92..7db5975 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,8 +1,8 @@ +import os from 'os' +import path from 'path' import { multiaddr } from '@multiformats/multiaddr' import type { Multiaddr } from '@multiformats/multiaddr' import type { ListenOptions, IpcSocketConnectOpts, TcpSocketConnectOpts } from 'net' -import os from 'os' -import path from 'path' const ProtoFamily = { ip4: 'IPv4', ip6: 'IPv6' } diff --git a/test/compliance.spec.ts b/test/compliance.spec.ts index ed50c9c..7c6ba85 100644 --- a/test/compliance.spec.ts +++ b/test/compliance.spec.ts @@ -1,7 +1,7 @@ -import sinon from 'sinon' +import net from 'net' import tests from '@libp2p/interface-transport-compliance-tests' import { multiaddr } from '@multiformats/multiaddr' -import net from 'net' +import sinon from 'sinon' import { tcp } from '../src/index.js' describe('interface-transport compliance', () => { diff --git a/test/connection.spec.ts b/test/connection.spec.ts index 1468f37..67b1d23 100644 --- a/test/connection.spec.ts +++ b/test/connection.spec.ts @@ -1,10 +1,10 @@ +import { mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' +import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' -import { multiaddr } from '@multiformats/multiaddr' -import { mockUpgrader } from '@libp2p/interface-mocks' import type { Connection } from '@libp2p/interface-connection' import type { Transport, Upgrader } from '@libp2p/interface-transport' -import { EventEmitter } from '@libp2p/interfaces/events' describe('valid localAddr and remoteAddr', () => { let transport: Transport diff --git a/test/filter.spec.ts b/test/filter.spec.ts index 23b8877..ce345a4 100644 --- a/test/filter.spec.ts +++ b/test/filter.spec.ts @@ -1,6 +1,6 @@ +import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' -import { multiaddr } from '@multiformats/multiaddr' import type { Transport } from '@libp2p/interface-transport' describe('filter addrs', () => { diff --git a/test/listen-dial.spec.ts b/test/listen-dial.spec.ts index 0cbdc14..f1c54b8 100644 --- a/test/listen-dial.spec.ts +++ b/test/listen-dial.spec.ts @@ -1,16 +1,16 @@ -import { expect } from 'aegir/chai' -import { tcp } from '../src/index.js' import os from 'os' import path from 'path' +import { mockRegistrar, mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' import { multiaddr } from '@multiformats/multiaddr' -import { pipe } from 'it-pipe' +import { expect } from 'aegir/chai' import all from 'it-all' -import { mockRegistrar, mockUpgrader } from '@libp2p/interface-mocks' -import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import type { Transport, Upgrader } from '@libp2p/interface-transport' +import { pipe } from 'it-pipe' import pDefer from 'p-defer' +import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' +import { tcp } from '../src/index.js' import type { MultiaddrConnection } from '@libp2p/interface-connection' -import { EventEmitter } from '@libp2p/interfaces/events' +import type { Transport, Upgrader } from '@libp2p/interface-transport' const isCI = process.env.CI @@ -196,7 +196,7 @@ describe('dial', () => { const values = await pipe( [uint8ArrayFromString('hey')], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(values[0].subarray()).to.equalBytes(uint8ArrayFromString('hey')) @@ -222,7 +222,7 @@ describe('dial', () => { const values = await pipe( [uint8ArrayFromString('hey')], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(values[0].subarray()).to.equalBytes(uint8ArrayFromString('hey')) await conn.close() @@ -244,7 +244,7 @@ describe('dial', () => { const values = await pipe( [uint8ArrayFromString('hey')], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(values[0].subarray()).to.equalBytes(uint8ArrayFromString('hey')) @@ -326,7 +326,7 @@ describe('dial', () => { const values = await pipe( [uint8ArrayFromString('hey')], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(values[0].subarray()).to.equalBytes(uint8ArrayFromString('hey')) diff --git a/test/max-connections-close.spec.ts b/test/max-connections-close.spec.ts index b588fb4..422a9f8 100644 --- a/test/max-connections-close.spec.ts +++ b/test/max-connections-close.spec.ts @@ -1,11 +1,11 @@ import net from 'node:net' import { promisify } from 'util' -import { expect } from 'aegir/chai' import { mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' import { multiaddr } from '@multiformats/multiaddr' +import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' import type { TCPListener } from '../src/listener.js' -import { EventEmitter } from '@libp2p/interfaces/events' describe('close server on maxConnections', () => { const afterEachCallbacks: Array<() => Promise | any> = [] diff --git a/test/max-connections.spec.ts b/test/max-connections.spec.ts index 3e2d888..4e1634b 100644 --- a/test/max-connections.spec.ts +++ b/test/max-connections.spec.ts @@ -1,10 +1,10 @@ -import { expect } from 'aegir/chai' import net from 'node:net' import { promisify } from 'node:util' import { mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' import { multiaddr } from '@multiformats/multiaddr' +import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' -import { EventEmitter } from '@libp2p/interfaces/events' describe('maxConnections', () => { const afterEachCallbacks: Array<() => Promise | any> = [] diff --git a/test/socket-to-conn.spec.ts b/test/socket-to-conn.spec.ts index 6b63501..e4f8dbf 100644 --- a/test/socket-to-conn.spec.ts +++ b/test/socket-to-conn.spec.ts @@ -1,9 +1,8 @@ +import { createServer, Socket, type Server, type ServerOpts, type SocketConstructorOpts } from 'net' +import os from 'os' import { expect } from 'aegir/chai' -import { createServer, Socket, Server } from 'net' import defer from 'p-defer' import { toMultiaddrConnection } from '../src/socket-to-conn.js' -import os from 'os' -import type { ServerOpts, SocketConstructorOpts } from 'net' async function setup (opts?: { server?: ServerOpts, client?: SocketConstructorOpts }): Promise<{ server: Server, serverSocket: Socket, clientSocket: Socket }> { const serverListening = defer()