|
2 | 2 | import { createVerifiedFetch } from '@helia/verified-fetch'
|
3 | 3 | import { expect } from 'aegir/chai'
|
4 | 4 | import { filetypemime } from 'magic-bytes.js'
|
| 5 | +import sinon from 'sinon' |
5 | 6 | import { createKuboNode } from './fixtures/create-kubo.js'
|
6 | 7 | import { loadFixtureDataCar } from './fixtures/load-fixture-data.js'
|
7 | 8 | import type { VerifiedFetch } from '@helia/verified-fetch'
|
@@ -76,16 +77,22 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
76 | 77 | })
|
77 | 78 |
|
78 | 79 | // TODO: find a smaller car file so the test doesn't timeout locally or flake on CI
|
79 |
| - describe.skip('HAMT-sharded directory', () => { |
| 80 | + describe('HAMT-sharded directory', () => { |
80 | 81 | before(async () => {
|
81 | 82 | // from https://github.com/ipfs/gateway-conformance/blob/193833b91f2e9b17daf45c84afaeeae61d9d7c7e/fixtures/trustless_gateway_car/single-layer-hamt-with-multi-block-files.car
|
82 | 83 | await loadFixtureDataCar(controller, 'bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i-single-layer-hamt-with-multi-block-files.car')
|
83 | 84 | })
|
84 | 85 |
|
85 | 86 | it('loads path /ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt', async () => {
|
86 |
| - const resp = await verifiedFetch('ipfs://bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt') |
| 87 | + const onProgress = sinon.stub() |
| 88 | + const resp = await verifiedFetch('ipfs://bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt', { onProgress }) |
87 | 89 | expect(resp).to.be.ok()
|
88 | 90 | const text = await resp.text()
|
| 91 | + const onProgressEvents = onProgress.getCalls().map(call => call.args[0]) |
| 92 | + const walkEvents = onProgressEvents.filter((e) => e.type.includes('unixfs:exporter:walk')) |
| 93 | + const blockGetEvents = onProgressEvents.filter((e) => e.type === 'blocks:get:providers:get') |
| 94 | + expect(blockGetEvents).to.have.length(7) |
| 95 | + expect(walkEvents).to.have.length.lessThanOrEqual(8) |
89 | 96 | // npx kubo@0.25.0 cat '/ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt'
|
90 | 97 | expect(text).to.equal(`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non imperdiet nunc. Proin ac quam ut nibh eleifend aliquet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed ligula dolor, imperdiet sagittis arcu et, semper tincidunt urna. Donec et tempor augue, quis sollicitudin metus. Curabitur semper ullamcorper aliquet. Mauris hendrerit sodales lectus eget fermentum. Proin sollicitudin vestibulum commodo. Vivamus nec lectus eu augue aliquet dignissim nec condimentum justo. In hac habitasse platea dictumst. Mauris vel sem neque.
|
91 | 98 |
|
|
0 commit comments