Skip to content

Commit 80bdaa7

Browse files
authored
fix: configure dummy router (#182)
To avoid network failures during the test, configure a dummy router that always returns a result
1 parent 5be716c commit 80bdaa7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

examples/js-libp2p-example-delegated-routing/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"vite": "^5.3.1"
3030
},
3131
"devDependencies": {
32+
"@libp2p/peer-id": "^5.0.4",
3233
"eslint-config-ipfs": "^7.0.2",
3334
"helia": "^5.0.0",
3435
"test-ipfs-example": "^1.0.0"

examples/js-libp2p-example-delegated-routing/test/index.spec.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-console */
22
import { createDelegatedRoutingV1HttpApiServer } from '@helia/delegated-routing-v1-http-api-server'
3+
import { peerIdFromString } from '@libp2p/peer-id'
34
import { createHelia } from 'helia'
45
import { setup, expect } from 'test-ipfs-example/browser'
56

@@ -17,7 +18,18 @@ let url
1718

1819
// start a libp2p node to delegate to
1920
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+
})
2133
const fastify = await createDelegatedRoutingV1HttpApiServer(helia, {
2234
listen: {
2335
host: '127.0.0.1',
@@ -52,8 +64,8 @@ test.describe('delegated routing example:', () => {
5264
})
5365

5466
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')
5769
await page.click(findProvidersBtn)
5870

5971
const outputLocator = page.locator(output)

0 commit comments

Comments
 (0)