-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blob-fetcher): use updated blob fetcher (#124)
# Goals Read sharded dag indexes properly, even in the absense of location claims # Implementation - use update blob-fetcher - pass values to enable carpark fallback - add two tests to verify: - that normal index shard fetching works in the presence of location claims - that in the absense of location claims it can fill in the missing values.
- Loading branch information
1 parent
847829b
commit 90bb605
Showing
8 changed files
with
169 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
import http from 'node:http' | ||
import * as PublicBucket from '@web3-storage/public-bucket/server/node' | ||
|
||
/** | ||
* @typedef {import('@web3-storage/public-bucket').Bucket} Bucket | ||
* @typedef {{ | ||
* url: URL | ||
* close: () => void | ||
* getCallCount: () => number | ||
* resetCallCount: () => void | ||
* }} MockBucketService | ||
*/ | ||
|
||
/** | ||
* @param {Bucket} bucket | ||
* @param {import('node:http').Server} server | ||
* @returns {Promise<MockBucketService>} | ||
*/ | ||
export const mockBucketService = async (bucket) => { | ||
export const mockBucketService = async (bucket, server) => { | ||
let callCount = 0 | ||
const getCallCount = () => callCount | ||
const resetCallCount = () => { callCount = 0 } | ||
|
||
const handler = PublicBucket.createHandler({ bucket }) | ||
const server = http.createServer((request, response) => { | ||
server.on('request', (request, response) => { | ||
callCount++ | ||
handler(request, response) | ||
}) | ||
await new Promise(resolve => server.listen(resolve)) | ||
const close = () => { | ||
server.closeAllConnections() | ||
server.close() | ||
} | ||
// @ts-expect-error | ||
const { port } = server.address() | ||
const url = new URL(`http://127.0.0.1:${port}`) | ||
return { close, getCallCount, resetCallCount, url } | ||
return { getCallCount, resetCallCount } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.