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

Commit

Permalink
deps: update @multiformats/multiaddr to 11.0.0 (#26)
Browse files Browse the repository at this point in the history
Updates all usage of @multiformats/multiaddr
  • Loading branch information
achingbrain authored Sep 21, 2022
1 parent cca2319 commit 9b6f719
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.13",
"@libp2p/utils": "^3.0.0",
"@multiformats/multiaddr": "^10.1.5",
"@multiformats/multiaddr": "^11.0.0",
"err-code": "^3.0.1",
"interface-datastore": "^7.0.0",
"it-all": "^1.0.6",
Expand Down
5 changes: 3 additions & 2 deletions src/peer-record/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Multiaddr } from '@multiformats/multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { PeerId } from '@libp2p/interface-peer-id'
import { multiaddr } from '@multiformats/multiaddr'
import { arrayEquals } from '@libp2p/utils/array-equals'
import { peerIdFromBytes } from '@libp2p/peer-id'
import { PeerRecord as Protobuf } from './peer-record.js'
Expand Down Expand Up @@ -34,7 +35,7 @@ export class PeerRecord {
static createFromProtobuf = (buf: Uint8Array | Uint8ArrayList): PeerRecord => {
const peerRecord = Protobuf.decode(buf)
const peerId = peerIdFromBytes(peerRecord.peerId)
const multiaddrs = (peerRecord.addresses ?? []).map((a) => new Multiaddr(a.multiaddr))
const multiaddrs = (peerRecord.addresses ?? []).map((a) => multiaddr(a.multiaddr))
const seqNumber = peerRecord.seq

return new PeerRecord({ peerId, multiaddrs, seqNumber })
Expand Down
12 changes: 6 additions & 6 deletions test/peer-record.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { expect } from 'aegir/chai'
import tests from '@libp2p/interface-record-compliance-tests'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'
import { peerIdFromKeys } from '@libp2p/peer-id'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { RecordEnvelope } from '../src/envelope/index.js'
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('PeerRecord', () => {

it('creates a peer record with provided data', () => {
const multiaddrs = [
new Multiaddr('/ip4/127.0.0.1/tcp/2000')
multiaddr('/ip4/127.0.0.1/tcp/2000')
]
const seqNumber = BigInt(Date.now())
const peerRecord = new PeerRecord({ peerId, multiaddrs, seqNumber })
Expand All @@ -74,7 +74,7 @@ describe('PeerRecord', () => {

it('marshals and unmarshals a peer record', () => {
const multiaddrs = [
new Multiaddr('/ip4/127.0.0.1/tcp/2000')
multiaddr('/ip4/127.0.0.1/tcp/2000')
]
const seqNumber = BigInt(Date.now())
const peerRecord = new PeerRecord({ peerId, multiaddrs, seqNumber })
Expand Down Expand Up @@ -114,12 +114,12 @@ describe('PeerRecord', () => {

it('equals returns false if the peer record has a different multiaddrs', () => {
const multiaddrs = [
new Multiaddr('/ip4/127.0.0.1/tcp/2000')
multiaddr('/ip4/127.0.0.1/tcp/2000')
]
const peerRecord0 = new PeerRecord({ peerId, multiaddrs })

const multiaddrs1 = [
new Multiaddr('/ip4/127.0.0.1/tcp/2001')
multiaddr('/ip4/127.0.0.1/tcp/2001')
]
const peerRecord1 = new PeerRecord({ peerId, multiaddrs: multiaddrs1 })

Expand All @@ -135,7 +135,7 @@ describe('PeerRecord inside Envelope', () => {
before(async () => {
peerId = await createEd25519PeerId()
const multiaddrs = [
new Multiaddr('/ip4/127.0.0.1/tcp/2000')
multiaddr('/ip4/127.0.0.1/tcp/2000')
]
const seqNumber = BigInt(Date.now())
peerRecord = new PeerRecord({ peerId, multiaddrs, seqNumber })
Expand Down

0 comments on commit 9b6f719

Please sign in to comment.