Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: update multiformats to v11 #101

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,21 @@
"docs": "aegir docs"
},
"dependencies": {
"@libp2p/interface-peer-id": "^1.0.2",
"@libp2p/interface-peer-id": "^2.0.0",
"@libp2p/interface-peer-info": "^1.0.1",
"@libp2p/interface-peer-routing": "^1.0.0",
"@libp2p/interfaces": "^3.0.2",
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.11",
"@libp2p/peer-id": "^2.0.0",
"any-signal": "^3.0.1",
"err-code": "^3.0.1",
"multiformats": "^10.0.0",
"multiformats": "^11.0.0",
"p-defer": "^4.0.0",
"p-queue": "^7.2.0"
},
"devDependencies": {
"@libp2p/peer-id-factory": "^1.0.11",
"aegir": "^37.7.8",
"@libp2p/peer-id-factory": "^2.0.0",
"aegir": "^37.9.1",
"go-ipfs": "^0.15.0",
"ipfs-http-client": "^59.0.0",
"ipfsd-ctl": "^12.0.2",
Expand Down
16 changes: 16 additions & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ function createIpfsClient (opts: Options) {
},
dht: {
async * findPeer (peerId: PeerId, options?: AbortOptions) {
// @ts-expect-error ipfs-http-client types are out of date
yield * client.dht.findPeer(peerId, options)
},
async * query (peerId: PeerId | CID, options?: AbortOptions) {
// @ts-expect-error ipfs-http-client types are out of date
yield * client.dht.query(peerId, options)
}
}
Expand Down Expand Up @@ -117,6 +119,7 @@ describe('DelegatedPeerRouting', function () {
port: 8000,
host: 'localhost'
})
// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(client)()

expect(router).to.have.property('client')
Expand All @@ -135,28 +138,33 @@ describe('DelegatedPeerRouting', function () {
it('should be able to find peers via the delegate with a peer id string', async () => {
const opts = delegatedNode.apiAddr.toOptions()

// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
host: opts.host
}))()

// @ts-expect-error ipfs-http-client types are out of date
const peer = await router.findPeer(peerIdToFind.id)

const { id, multiaddrs } = peer
expect(id).to.exist()
expect(multiaddrs).to.exist()
// @ts-expect-error ipfs-http-client types are out of date
expect(id.equals(peerIdToFind.id)).to.be.true()
})

it('should be able to find peers via the delegate with a peerid', async () => {
const opts = delegatedNode.apiAddr.toOptions()
// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
host: opts.host
}))()

// @ts-expect-error ipfs-http-client types are out of date
const peer = await router.findPeer(peerIdToFind.id)

const { id, multiaddrs } = peer
Expand All @@ -168,13 +176,15 @@ describe('DelegatedPeerRouting', function () {

it('should be able to specify a timeout', async () => {
const opts = delegatedNode.apiAddr.toOptions()
// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
host: opts.host
}))()
const controller = new TimeoutController(5e3)

// @ts-expect-error ipfs-http-client types are out of date
const peer = await router.findPeer(peerIdToFind.id, { signal: controller.signal })

const { id, multiaddrs } = peer
Expand All @@ -188,6 +198,7 @@ describe('DelegatedPeerRouting', function () {

it('should not be able to find peers not on the network', async () => {
const opts = delegatedNode.apiAddr.toOptions()
// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
Expand All @@ -205,6 +216,7 @@ describe('DelegatedPeerRouting', function () {
it('should be able to query for the closest peers', async () => {
const opts = delegatedNode.apiAddr.toOptions()

// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
Expand All @@ -222,6 +234,7 @@ describe('DelegatedPeerRouting', function () {
expect(closerPeers.length).to.equal(2)
closerPeers.forEach(result => {
// shouldn't be the delegate
// @ts-expect-error ipfs-http-client types are out of date
expect(delegatePeerId.equals(result.id)).to.equal(false)
expect(result.multiaddrs).to.be.an('array')
})
Expand All @@ -230,6 +243,7 @@ describe('DelegatedPeerRouting', function () {
it('should find closest peers even if the peer does not exist', async () => {
const opts = delegatedNode.apiAddr.toOptions()

// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
Expand All @@ -246,6 +260,7 @@ describe('DelegatedPeerRouting', function () {
expect(closerPeers.length).to.equal(2)
closerPeers.forEach(result => {
// shouldnt be the delegate
// @ts-expect-error ipfs-http-client types are out of date
expect(delegatePeerId.equals(result.id)).to.equal(false)
expect(result.multiaddrs).to.be.an('array')
})
Expand All @@ -255,6 +270,7 @@ describe('DelegatedPeerRouting', function () {
describe('stop', () => {
it('should cancel in-flight requests when stopping', async () => {
const opts = delegatedNode.apiAddr.toOptions()
// @ts-expect-error ipfs-http-client types are out of date
const router = delegatedPeerRouting(createIpfsClient({
protocol: 'http',
port: opts.port,
Expand Down