Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
deps: update @multiformats/multiaddr to 11.0.0 (#4217)
Browse files Browse the repository at this point in the history
Updates all use and dependent modules.
  • Loading branch information
achingbrain authored Sep 21, 2022
1 parent 79cadcf commit 7c676f6
Show file tree
Hide file tree
Showing 60 changed files with 157 additions and 151 deletions.
6 changes: 3 additions & 3 deletions packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@libp2p/peer-id": "^1.1.10",
"@libp2p/peer-id-factory": "^1.0.10",
"@libp2p/websockets": "^3.0.0",
"@multiformats/multiaddr": "^10.4.0",
"@multiformats/multiaddr": "^11.0.0",
"@types/node": "^18.0.0",
"@types/pako": "^2.0.0",
"@types/readable-stream": "^2.3.13",
Expand All @@ -86,10 +86,10 @@
"err-code": "^3.0.1",
"ipfs-core-types": "^0.12.0",
"ipfs-unixfs": "^7.0.0",
"ipfs-unixfs-importer": "^10.0.1",
"ipfs-unixfs-importer": "^10.0.2",
"ipfs-utils": "^9.0.6",
"ipns": "^2.0.2",
"is-ipfs": "^6.0.1",
"is-ipfs": "^7.0.0",
"iso-random-stream": "^2.0.2",
"it-all": "^1.0.4",
"it-buffer-stream": "^2.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/interface-ipfs-core/src/bootstrap/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr, isMultiaddr } from '@multiformats/multiaddr'

const invalidArg = 'this/Is/So/Invalid/'
const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')
const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')

/**
* @typedef {import('ipfsd-ctl').Factory} Factory
Expand Down Expand Up @@ -59,15 +59,15 @@ export function testAdd (factory, options) {
})

it('add a peer to the bootstrap list', async () => {
const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb')
const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb')

const res = await ipfs.bootstrap.add(peer)
expect(res).to.be.eql({ Peers: [peer] })

const list = await ipfs.bootstrap.list()
expect(list.Peers).to.deep.include(peer)

expect(list.Peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true()
expect(list.Peers.every(ma => isMultiaddr(ma))).to.be.true()
})
})
}
6 changes: 3 additions & 3 deletions packages/interface-ipfs-core/src/bootstrap/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr, isMultiaddr } from '@multiformats/multiaddr'

/**
* @typedef {import('ipfsd-ctl').Factory} Factory
Expand All @@ -16,7 +16,7 @@ export function testClear (factory, options) {
const describe = getDescribe(options)
const it = getIt(options)

const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')
const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')

describe('.bootstrap.clear', function () {
this.timeout(100 * 1000)
Expand Down Expand Up @@ -50,7 +50,7 @@ export function testClear (factory, options) {

expect(removedPeers.sort()).to.deep.equal(addedPeers.sort())

expect(removedPeers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true()
expect(removedPeers.every(ma => isMultiaddr(ma))).to.be.true()
})
})
}
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/bootstrap/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { isMultiaddr } from '@multiformats/multiaddr'

/**
* @typedef {import('ipfsd-ctl').Factory} Factory
Expand Down Expand Up @@ -31,7 +31,7 @@ export function testList (factory, options) {

const peers = res.Peers
expect(peers).to.be.an('Array')
expect(peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true()
expect(peers.every(ma => isMultiaddr(ma))).to.be.true()
})
})
}
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/bootstrap/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { isMultiaddr } from '@multiformats/multiaddr'

/**
* @typedef {import('ipfsd-ctl').Factory} Factory
Expand Down Expand Up @@ -43,7 +43,7 @@ export function testReset (factory, options) {
const removedPeers = rmRes.Peers

expect(removedPeers.sort()).to.deep.equal(addedPeers.sort())
expect(addedPeers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true()
expect(addedPeers.every(ma => isMultiaddr(ma))).to.be.true()
})
})
}
8 changes: 4 additions & 4 deletions packages/interface-ipfs-core/src/bootstrap/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr, isMultiaddr } from '@multiformats/multiaddr'

/**
* @typedef {import('ipfsd-ctl').Factory} Factory
Expand All @@ -17,7 +17,7 @@ export function testRm (factory, options) {
const it = getIt(options)

const invalidArg = 'this/Is/So/Invalid/'
const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')
const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z')

describe('.bootstrap.rm', function () {
this.timeout(100 * 1000)
Expand Down Expand Up @@ -47,7 +47,7 @@ export function testRm (factory, options) {
})

it('removes a peer from the bootstrap list', async () => {
const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb')
const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb')
await ipfs.bootstrap.add(peer)
let list = await ipfs.bootstrap.list()
expect(list.Peers).to.deep.include(peer)
Expand All @@ -57,7 +57,7 @@ export function testRm (factory, options) {

list = await ipfs.bootstrap.list()
expect(list.Peers).to.not.deep.include(peer)
expect(res.Peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true()
expect(res.Peers.every(ma => isMultiaddr(ma))).to.be.true()
})
})
}
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/miscellaneous/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { Multiaddr } from '@multiformats/multiaddr'
import { isMultiaddr } from '@multiformats/multiaddr'
import { isWebWorker } from 'ipfs-utils/src/env.js'
import retry from 'p-retry'

Expand Down Expand Up @@ -38,7 +38,7 @@ export function testId (factory, options) {
expect(res).to.have.a.property('addresses').that.is.an('array')

for (const ma of res.addresses) {
expect(Multiaddr.isMultiaddr(ma)).to.be.true()
expect(isMultiaddr(ma)).to.be.true()
}
})

Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/miscellaneous/resolve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env mocha */

import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import isIpfs from 'is-ipfs'
import * as isIpfs from 'is-ipfs'
import { nanoid } from 'nanoid'
import { base64url } from 'multiformats/bases/base64'
import { expect } from 'aegir/chai'
Expand Down
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/swarm/addrs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env mocha */

import { Multiaddr } from '@multiformats/multiaddr'
import { isMultiaddr } from '@multiformats/multiaddr'
import { expect } from 'aegir/chai'
import { getDescribe, getIt } from '../utils/mocha.js'
import { isWebWorker } from 'ipfs-utils/src/env.js'
Expand Down Expand Up @@ -47,7 +47,7 @@ export function testAddrs (factory, options) {
expect(peer).to.have.a.property('addrs').that.is.an('array')

for (const ma of peer.addrs) {
expect(Multiaddr.isMultiaddr(ma)).to.be.true()
expect(isMultiaddr(ma)).to.be.true()
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions packages/interface-ipfs-core/src/swarm/peers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env mocha */

import { Multiaddr } from '@multiformats/multiaddr'
import { isMultiaddr } from '@multiformats/multiaddr'
import delay from 'delay'
import { isBrowser, isWebWorker } from 'ipfs-utils/src/env.js'
import { expect } from 'aegir/chai'
Expand Down Expand Up @@ -60,7 +60,7 @@ export function testPeers (factory, options) {
const peer = peers[0]

expect(peer).to.have.a.property('addr')
expect(Multiaddr.isMultiaddr(peer.addr)).to.equal(true)
expect(isMultiaddr(peer.addr)).to.equal(true)
expect(peer).to.have.a.property('peer')
expect(peer.peer).to.be.ok()
expect(peer).to.not.have.a.property('latency')
Expand All @@ -77,7 +77,7 @@ export function testPeers (factory, options) {

const peer = peers[0]
expect(peer).to.have.a.property('addr')
expect(Multiaddr.isMultiaddr(peer.addr)).to.equal(true)
expect(isMultiaddr(peer.addr)).to.equal(true)
expect(peer).to.have.a.property('peer')
expect(peer).to.have.a.property('latency')
expect(peer.latency).to.match(/n\/a|[0-9]+[mµ]?s/) // n/a or 3ms or 3µs or 3s
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.10",
"@multiformats/mafmt": "^11.0.2",
"@multiformats/multiaddr": "^10.4.0",
"@multiformats/multiaddr": "^11.0.0",
"@multiformats/multiaddr-to-uri": "^9.0.1",
"byteman": "^1.3.5",
"execa": "^6.1.0",
Expand Down Expand Up @@ -107,7 +107,7 @@
"@types/rimraf": "^3.0.1",
"@types/yargs": "^17.0.10",
"aegir": "^37.0.11",
"ipfs-repo": "^15.0.0",
"ipfs-repo": "^15.0.3",
"it-all": "^1.0.4",
"it-first": "^1.0.4",
"it-to-buffer": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/src/commands/swarm/peers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IPFS } from '@multiformats/mafmt'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'
import parseDuration from 'parse-duration'

/**
Expand Down Expand Up @@ -31,7 +31,7 @@ const command = {
})

result.forEach((item) => {
let ma = new Multiaddr(`${item.addr}`)
let ma = multiaddr(`${item.addr}`)

if (!IPFS.matches(ma)) {
ma = ma.encapsulate(`/ipfs/${item.peer}`)
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Progress from 'progress'
import byteman from 'byteman'
import { create } from 'ipfs-core'
import { CID } from 'multiformats/cid'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { create as httpClient } from 'ipfs-http-client'
import { peerIdFromString } from '@libp2p/peer-id'
Expand Down Expand Up @@ -267,7 +267,7 @@ export const coerceMultiaddr = (value) => {
return undefined
}

return new Multiaddr(value)
return multiaddr(value)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/test/bootstrap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import { expect } from 'aegir/chai'
import { cli } from './utils/cli.js'
import sinon from 'sinon'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'

describe('bootstrap', () => {
const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD')
const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD')
let ipfs

before(() => {
Expand Down
46 changes: 23 additions & 23 deletions packages/ipfs-cli/test/swarm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { expect } from 'aegir/chai'
import { cli, fail } from './utils/cli.js'
import sinon from 'sinon'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'
import { peerIdFromString } from '@libp2p/peer-id'

describe('swarm', () => {
Expand All @@ -28,33 +28,33 @@ describe('swarm', () => {
}

it('connect online', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')

ipfs.swarm.connect.withArgs(multiaddr, defaultOptions).resolves()
ipfs.swarm.connect.withArgs(ma, defaultOptions).resolves()

const out = await cli(`swarm connect ${multiaddr}`, { ipfs, isDaemon: true })
expect(out).to.equal(`${multiaddr}\n`)
const out = await cli(`swarm connect ${ma}`, { ipfs, isDaemon: true })
expect(out).to.equal(`${ma}\n`)
})

it('connect offline', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')

const out = await fail(`swarm connect ${multiaddr}`, { ipfs, isDaemon: false })
const out = await fail(`swarm connect ${ma}`, { ipfs, isDaemon: false })
expect(out).to.include('This command must be run in online mode')

expect(ipfs.swarm.connect.called).to.be.false()
})

it('connect with timeout', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')

ipfs.swarm.connect.withArgs(multiaddr, {
ipfs.swarm.connect.withArgs(ma, {
...defaultOptions,
timeout: 1000
}).resolves()

const out = await cli(`swarm connect ${multiaddr} --timeout=1s`, { ipfs, isDaemon: true })
expect(out).to.equal(`${multiaddr}\n`)
const out = await cli(`swarm connect ${ma} --timeout=1s`, { ipfs, isDaemon: true })
expect(out).to.equal(`${ma}\n`)
})
})

Expand Down Expand Up @@ -110,7 +110,7 @@ describe('swarm', () => {
ipfs.swarm.addrs.withArgs(defaultOptions).resolves([{
id: peer,
addrs: [
new Multiaddr(addr)
multiaddr(addr)
]
}])

Expand All @@ -128,7 +128,7 @@ describe('swarm', () => {
}).resolves([{
id: peer,
addrs: [
new Multiaddr(addr)
multiaddr(addr)
]
}])

Expand Down Expand Up @@ -175,26 +175,26 @@ describe('swarm', () => {
}

it('disconnect online', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
ipfs.swarm.disconnect.withArgs(multiaddr, defaultOptions).resolves()
const out = await cli(`swarm disconnect ${multiaddr}`, { ipfs, isDaemon: true })
expect(out).to.equal(`${multiaddr}\n`)
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')
ipfs.swarm.disconnect.withArgs(ma, defaultOptions).resolves()
const out = await cli(`swarm disconnect ${ma}`, { ipfs, isDaemon: true })
expect(out).to.equal(`${ma}\n`)
})

it('disconnect offline', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
const out = await fail(`swarm disconnect ${multiaddr}`, { ipfs, isDaemon: false })
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')
const out = await fail(`swarm disconnect ${ma}`, { ipfs, isDaemon: false })
expect(out).to.include('This command must be run in online mode')
})

it('disconnect with timeout', async () => {
const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482')
ipfs.swarm.disconnect.withArgs(multiaddr, {
const ma = multiaddr('/ip4/123.123.123.123/tcp/482')
ipfs.swarm.disconnect.withArgs(ma, {
...defaultOptions,
timeout: 1000
}).resolves()
const out = await cli(`swarm disconnect ${multiaddr} --timeout=1s`, { ipfs, isDaemon: true })
expect(out).to.equal(`${multiaddr}\n`)
const out = await cli(`swarm disconnect ${ma} --timeout=1s`, { ipfs, isDaemon: true })
expect(out).to.equal(`${ma}\n`)
})
})
})
Loading

0 comments on commit 7c676f6

Please sign in to comment.