Skip to content

Commit

Permalink
chore: do not assume bitswap
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Oct 24, 2023
1 parent ab5e8fd commit 1115ac8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/interop/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { CID } from 'multiformats/cid'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'
import { createHelia } from './fixtures/create-helia.js'
import type { Helia } from '@helia/interface'
import type { DelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import type { Helia } from '@helia/interface'
import type { Libp2p } from '@libp2p/interface'
import type { KadDHT } from '@libp2p/kad-dht'
import type { FastifyInstance } from 'fastify'
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/routes/routing/v1/peers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default function getPeersV1 (fastify: FastifyInstance, helia: Helia): voi
const peerInfo = await helia.libp2p.peerRouting.findPeer(peerId)
const peerRecord = {
Schema: 'peer',
Protocols: ['transport-bitswap'],
ID: peerInfo.id.toString(),
Addrs: peerInfo.multiaddrs.map(ma => ma.toString())
}
Expand Down
4 changes: 1 addition & 3 deletions packages/server/src/routes/routing/v1/providers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Params {

interface PeerRecord {
Schema: string
Protocols: string[]
Protocols?: string[]
ID: string
Addrs: string[]
}
Expand Down Expand Up @@ -95,7 +95,6 @@ async function * streamingHandler (cid: CID, helia: Helia, options?: AbortOption
for await (const prov of helia.libp2p.contentRouting.findProviders(cid, options)) {
yield {
Schema: 'peer',
Protocols: ['transport-bitswap'],
ID: prov.id.toString(),
Addrs: prov.multiaddrs.map(ma => ma.toString())
}
Expand All @@ -115,7 +114,6 @@ async function nonStreamingHandler (cid: CID, helia: Helia, options?: AbortOptio
for await (const prov of helia.libp2p.contentRouting.findProviders(cid, options)) {
providers.push({
Schema: 'peer',
Protocols: ['transport-bitswap'],
ID: prov.id.toString(),
Addrs: prov.multiaddrs.map(ma => ma.toString())
})
Expand Down
5 changes: 0 additions & 5 deletions packages/server/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,9 @@ describe('routing-v1-http-api-server', () => {

const json = await res.json()

expect(json).to.have.nested.property('Providers[0].Protocols[0]', 'transport-bitswap')
expect(json).to.have.nested.property('Providers[0].Schema', 'peer')
expect(json).to.have.nested.property('Providers[0].ID', provider1.id.toString())
expect(json).to.have.deep.nested.property('Providers[0].Addrs', provider1.multiaddrs.map(ma => ma.toString()))
expect(json).to.have.nested.property('Providers[1].Protocols[0]', 'transport-bitswap')
expect(json).to.have.nested.property('Providers[1].Schema', 'peer')
expect(json).to.have.nested.property('Providers[1].ID', provider2.id.toString())
expect(json).to.have.deep.nested.property('Providers[1].Addrs', provider2.multiaddrs.map(ma => ma.toString()))
Expand Down Expand Up @@ -182,11 +180,9 @@ describe('routing-v1-http-api-server', () => {
.filter(Boolean)
.map(str => JSON.parse(str))

expect(json).to.have.nested.property('[0].Protocols[0]', 'transport-bitswap')
expect(json).to.have.nested.property('[0].Schema', 'peer')
expect(json).to.have.nested.property('[0].ID', provider1.id.toString())
expect(json).to.have.deep.nested.property('[0].Addrs', provider1.multiaddrs.map(ma => ma.toString()))
expect(json).to.have.nested.property('[1].Protocols[0]', 'transport-bitswap')
expect(json).to.have.nested.property('[1].Schema', 'peer')
expect(json).to.have.nested.property('[1].ID', provider2.id.toString())
expect(json).to.have.deep.nested.property('[1].Addrs', provider2.multiaddrs.map(ma => ma.toString()))
Expand Down Expand Up @@ -232,7 +228,6 @@ describe('routing-v1-http-api-server', () => {
expect(res.status).to.equal(200)

const json = await res.json()
expect(json).to.have.nested.property('Peers[0].Protocols[0]', 'transport-bitswap')
expect(json).to.have.nested.property('Peers[0].Schema', 'peer')
expect(json).to.have.nested.property('Peers[0].ID', peer.id.toString())
expect(json).to.have.deep.nested.property('Peers[0].Addrs', peer.multiaddrs.map(ma => ma.toString()))
Expand Down

0 comments on commit 1115ac8

Please sign in to comment.