From 71647584244393800590c7b80efd3ab40535ab85 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 26 May 2022 09:07:39 +0100 Subject: [PATCH 1/2] fix: update to latest libp2p interfaces Update all deps to `@libp2p/interfaces@2.x.x` --- packages/ipfs-core/package.json | 4 ++-- packages/ipfs-core/src/components/libp2p.js | 6 ++++-- packages/ipfs-daemon/package.json | 2 +- packages/ipfs-http-server/package.json | 2 +- packages/ipfs-message-port-server/src/server.js | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index e4ecde008e..3af52d4472 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -75,7 +75,7 @@ "@libp2p/crypto": "^0.22.9", "@libp2p/delegated-content-routing": "^1.0.3", "@libp2p/delegated-peer-routing": "^1.0.3", - "@libp2p/interfaces": "^1.3.32", + "@libp2p/interfaces": "^2.0.2", "@libp2p/kad-dht": "^1.0.3", "@libp2p/logger": "^1.1.4", "@libp2p/mplex": "^1.0.5", @@ -125,7 +125,7 @@ "it-tar": "^5.0.0", "it-to-buffer": "^2.0.0", "just-safe-set": "^4.0.2", - "libp2p": "^0.37.0", + "libp2p": "^0.37.1", "merge-options": "^3.0.4", "mortice": "^3.0.0", "multiformats": "^9.5.1", diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index d6590467b0..0c4d752c35 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -115,8 +115,10 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, minConnections: get(options, 'config.Swarm.ConnMgr.LowWater', get(config, 'Swarm.ConnMgr.LowWater')) }), keychain: keychainConfig, - host: { - agentVersion: `js-ipfs/${pkgversion}` + identify: { + host: { + agentVersion: `js-ipfs/${pkgversion}` + } }, contentRouters: [], peerRouters: [], diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index 6d3fa15807..c80a1cec1d 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -49,7 +49,7 @@ "ipfs-http-gateway": "^0.9.2", "ipfs-http-server": "^0.11.2", "ipfs-utils": "^9.0.6", - "libp2p": "^0.37.0" + "libp2p": "^0.37.1" }, "devDependencies": { "aegir": "^37.0.11", diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index 021b1a651f..4ae5d3a173 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -45,7 +45,7 @@ "@hapi/content": "^5.0.2", "@hapi/hapi": "^20.0.0", "@ipld/dag-pb": "^2.1.3", - "@libp2p/interfaces": "^1.3.32", + "@libp2p/interfaces": "^2.0.2", "@libp2p/logger": "^1.1.4", "@libp2p/peer-id": "^1.1.10", "any-signal": "^3.0.0", diff --git a/packages/ipfs-message-port-server/src/server.js b/packages/ipfs-message-port-server/src/server.js index af42aae972..85cbb2e2b6 100644 --- a/packages/ipfs-message-port-server/src/server.js +++ b/packages/ipfs-message-port-server/src/server.js @@ -253,10 +253,10 @@ export class Server { query.fail(error) } } else { - query.fail(new RangeError(`Method '${method}' is not found`)) + query.fail(new RangeError(`Method '${String(method)}' is not found`)) } } else { - query.fail(new RangeError(`Namespace '${namespace}' is not found`)) + query.fail(new RangeError(`Namespace '${String(namespace)}' is not found`)) } } From e8dfa1341028cd325bb70a12fa147aec41a4ffee Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 26 May 2022 17:34:36 +0100 Subject: [PATCH 2/2] chore: update tests --- packages/ipfs-core/test/create-node.spec.js | 30 +++++++-------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/ipfs-core/test/create-node.spec.js b/packages/ipfs-core/test/create-node.spec.js index a9e8bd187b..c67468276c 100644 --- a/packages/ipfs-core/test/create-node.spec.js +++ b/packages/ipfs-core/test/create-node.spec.js @@ -27,7 +27,6 @@ describe('create node', function () { const node = await IPFS.create({ repo: tmpDir(), - init: { bits: 512 }, config: { Addresses: { Swarm: [] @@ -47,7 +46,6 @@ describe('create node', function () { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, config: { Addresses: { Swarm: [] @@ -81,7 +79,6 @@ describe('create node', function () { it('should create and initialize but not start', async () => { const ipfs = await IPFS.create({ - init: { bits: 512 }, start: false, repo: tempRepo, config: { Addresses: { Swarm: [] } } @@ -111,7 +108,7 @@ describe('create node', function () { })).to.eventually.be.rejected() }) - it('should init with 1024 key bits', async function () { + it('should init RSA key with 1024 key bits', async function () { this.timeout(80 * 1000) const node = await IPFS.create({ @@ -144,7 +141,6 @@ describe('create node', function () { const ipfs = await IPFS.create({ silent: true, repo: tempRepo, - init: { bits: 512 }, config: { Addresses: { Swarm: [] @@ -166,7 +162,6 @@ describe('create node', function () { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, config: { Addresses: { Swarm: ['/ip4/127.0.0.1/tcp/9977'] @@ -188,8 +183,11 @@ describe('create node', function () { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, config: { + Addresses: { + Swarm: [] + }, + Bootstrap: [], Pubsub: { Enabled: false } @@ -208,7 +206,6 @@ describe('create node', function () { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, config: { Addresses: { Swarm: [] @@ -226,29 +223,22 @@ describe('create node', function () { it('should not share identity with a simultaneously created node', async function () { this.timeout(2 * 60 * 1000) - let _nodeNumber = 0 /** * @param {import('ipfs-repo').IPFSRepo} repo * @returns */ function createNode (repo) { - _nodeNumber++ return IPFS.create({ repo, - init: { bits: 512, emptyRepo: true }, + init: { emptyRepo: true }, config: { Addresses: { - API: `/ip4/127.0.0.1/tcp/${5010 + _nodeNumber}`, - Gateway: `/ip4/127.0.0.1/tcp/${9090 + _nodeNumber}`, - Swarm: isNode - ? [ - `/ip4/0.0.0.0/tcp/${4010 + _nodeNumber * 2}` - ] - : [] + Swarm: [] }, Bootstrap: [] }, - preload: { enabled: false } + preload: { enabled: false }, + start: false }) } @@ -267,7 +257,6 @@ describe('create node', function () { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, config: { Addresses: { Swarm: [] @@ -283,7 +272,6 @@ describe('create node', function () { it('should error when receiving websocket-star swarm addresses', async () => { const node = await IPFS.create({ repo: tempRepo, - init: { bits: 512 }, start: false, config: { Addresses: {