diff --git a/packages/client/src/routings.ts b/packages/client/src/routings.ts index a6658c6..8c9a382 100644 --- a/packages/client/src/routings.ts +++ b/packages/client/src/routings.ts @@ -6,7 +6,7 @@ import { CID } from 'multiformats/cid' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import type { DelegatedRoutingV1HttpApiClient } from './index.js' -import type { ContentRouting, PeerRouting, AbortOptions, PeerId, PeerInfo } from '@libp2p/interface' +import type { ContentRouting, PeerRouting, AbortOptions, PeerId, PeerInfo, Provider } from '@libp2p/interface' const IPNS_PREFIX = uint8ArrayFromString('/ipns/') @@ -24,12 +24,13 @@ export class DelegatedRoutingV1HttpApiClientContentRouting implements ContentRou this.client = client } - async * findProviders (cid: CID, options: AbortOptions = {}): AsyncIterable { + async * findProviders (cid: CID, options: AbortOptions = {}): AsyncIterable { try { yield * map(this.client.getProviders(cid, options), (record) => { return { id: record.ID, - multiaddrs: record.Addrs ?? [] + multiaddrs: record.Addrs ?? [], + routing: 'delegated-http-routing-v1' } }) } catch (err) { diff --git a/packages/server/test/index.spec.ts b/packages/server/test/index.spec.ts index 8e45be3..c2179c1 100644 --- a/packages/server/test/index.spec.ts +++ b/packages/server/test/index.spec.ts @@ -9,7 +9,7 @@ import { CID } from 'multiformats' import { stubInterface } from 'sinon-ts' import { createDelegatedRoutingV1HttpApiServer } from '../src/index.js' import type { Helia } from '@helia/interface' -import type { PeerInfo } from '@libp2p/interface' +import type { PeerInfo, Provider } from '@libp2p/interface' import type { FastifyInstance } from 'fastify' import type { StubbedInstance } from 'sinon-ts' @@ -94,17 +94,19 @@ describe('delegated-routing-v1-http-api-server', () => { }) it('GET providers returns providers', async () => { - const provider1: PeerInfo = { + const provider1: Provider = { id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/123.123.123.123/tcp/123') - ] + ], + routing: 'test-routing' } - const provider2: PeerInfo = { + const provider2: Provider = { id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/123.123.123.123/tcp/123') - ] + ], + routing: 'test-routing' } helia.routing.findProviders = async function * () { @@ -129,17 +131,19 @@ describe('delegated-routing-v1-http-api-server', () => { }) it('GET providers returns provider stream', async () => { - const provider1: PeerInfo = { + const provider1: Provider = { id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/123.123.123.123/tcp/123') - ] + ], + routing: 'test-routing' } - const provider2: PeerInfo = { + const provider2: Provider = { id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/123.123.123.123/tcp/123') - ] + ], + routing: 'test-routing' } helia.routing.findProviders = async function * () {