Skip to content

Commit 47271a2

Browse files
authored
chore: add truncated hash test (#914)
Adds test to ensure we can load content with truncated hashes, e.g. sha2-512 truncated to 32 bytes. Closes #894
1 parent d62632e commit 47271a2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"@multiformats/dns": "^1.0.10",
7676
"@noble/hashes": "^2.0.1",
7777
"execa": "^9.5.2",
78-
"helia": "^6.0.8",
78+
"helia": "^6.0.10",
7979
"ipfs-css": "^1.4.0",
8080
"ipfsd-ctl": "^16.0.0",
8181
"libp2p": "^3.1.0",
Binary file not shown.

test-e2e/smoke-test.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,15 @@ test.describe('smoke test', () => {
199199
expect(response.status()).toBe(400)
200200
expect(await response.text()).toContain('Could not parse CID')
201201
})
202+
203+
test('supports truncated CID hashes', async ({ page, protocol, rootDomain }) => {
204+
// this is sha2-512-half
205+
const cid = CID.parse('bafkrgihhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zge')
206+
207+
const response = await loadWithServiceWorker(page, `${protocol}//${rootDomain}/ipfs/${cid}`, {
208+
redirect: `${protocol}//${cid}.ipfs.${rootDomain}/`
209+
})
210+
expect(response.status()).toBe(200)
211+
expect(await response.text()).toContain('hello')
212+
})
202213
})

0 commit comments

Comments
 (0)