1
1
/* eslint-disable no-console */
2
2
import { createDelegatedRoutingV1HttpApiServer } from '@helia/delegated-routing-v1-http-api-server'
3
+ import { peerIdFromString } from '@libp2p/peer-id'
3
4
import { createHelia } from 'helia'
4
5
import { setup , expect } from 'test-ipfs-example/browser'
5
6
@@ -17,7 +18,18 @@ let url
17
18
18
19
// start a libp2p node to delegate to
19
20
async function spawnServer ( ) {
20
- const helia = await createHelia ( )
21
+ const helia = await createHelia ( {
22
+ routers : [ {
23
+ // dummy router that always finds providers
24
+ findProviders : async function * ( ) {
25
+ yield {
26
+ id : peerIdFromString ( 'QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN' ) ,
27
+ multiaddrs : [ ] ,
28
+ protocols : [ ]
29
+ }
30
+ }
31
+ } ]
32
+ } )
21
33
const fastify = await createDelegatedRoutingV1HttpApiServer ( helia , {
22
34
listen : {
23
35
host : '127.0.0.1' ,
@@ -52,8 +64,8 @@ test.describe('delegated routing example:', () => {
52
64
} )
53
65
54
66
test ( 'should find providers using the delegate' , async ( { page, context } ) => {
55
- // add the relay multiaddr to the input field and submit
56
- await page . fill ( findProvidersInput , 'bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e ' )
67
+ // add the empty directory CID to the input field and submit
68
+ await page . fill ( findProvidersInput , 'bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354 ' )
57
69
await page . click ( findProvidersBtn )
58
70
59
71
const outputLocator = page . locator ( output )
0 commit comments