Skip to content

Commit

Permalink
chore: appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed May 17, 2024
1 parent e691265 commit 4281798
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/upload-api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export type {
IPNIService,
BlobRetriever,
BlobNotFound,
ShardedDAGIndex
ShardedDAGIndex,
} from './types/index.js'

export interface Service extends StorefrontService, W3sService {
Expand Down
4 changes: 3 additions & 1 deletion packages/upload-api/test/handlers/web3.storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ export const test = {
const locations = delegation.capabilities[0].nb.location
assert.equal(locations.length, 1)

const loc = Result.unwrap(await context.blobsStorage.createDownloadUrl(content.multihash))
const loc = Result.unwrap(
await context.blobsStorage.createDownloadUrl(content.multihash)
)
assert.ok(locations.includes(loc))
},
'web3.storage/blob/accept fails to provide site delegation when blob was not stored':
Expand Down
10 changes: 8 additions & 2 deletions packages/upload-api/test/storage/allocations-storage-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ export const test = {
const digest = multihash.bytes
const size = data.byteLength

const allocationExist0 = await allocationsStorage.exists(spaceDid, multihash)
const allocationExist0 = await allocationsStorage.exists(
spaceDid,
multihash
)
assert.ok(!allocationExist0.error)
assert.ok(!allocationExist0.ok)

Expand Down Expand Up @@ -180,7 +183,10 @@ export const test = {
assert.ok(allocationInsert.ok)
assert.ok(allocationInsert.ok?.blob)

const allocationExist1 = await allocationsStorage.exists(spaceDid, multihash)
const allocationExist1 = await allocationsStorage.exists(
spaceDid,
multihash
)
assert.ok(allocationExist1.ok)
assert.ok(!allocationExist1.error)
},
Expand Down
44 changes: 23 additions & 21 deletions packages/upload-api/test/storage/blobs-storage-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,30 @@ export const test = {
assert.ok(hasBlob.ok)
},

'should create valid download URL for blobs that can be used to read':
async (assert, { blobsStorage }) => {
const data = new Uint8Array([11, 22, 34, 44, 55])
const digest = await sha256.digest(data)
const expires = 60 * 60 * 24 // 1 day
'should create valid download URL for blobs that can be used to read': async (
assert,
{ blobsStorage }
) => {
const data = new Uint8Array([11, 22, 34, 44, 55])
const digest = await sha256.digest(data)
const expires = 60 * 60 * 24 // 1 day

const upload = Result.unwrap(
await blobsStorage.createUploadUrl(digest, data.length, expires)
)
const upload = Result.unwrap(
await blobsStorage.createUploadUrl(digest, data.length, expires)
)

await fetch(upload.url, {
method: 'PUT',
mode: 'cors',
body: data,
headers: upload.headers,
})
const downloadUrl = Result.unwrap(
await blobsStorage.createDownloadUrl(digest)
)
await fetch(upload.url, {
method: 'PUT',
mode: 'cors',
body: data,
headers: upload.headers,
})

const downloadUrl = Result.unwrap(
await blobsStorage.createDownloadUrl(digest)
)

const res = await fetch(downloadUrl)
assert.ok(equals(new Uint8Array(await res.arrayBuffer()), data))
}
const res = await fetch(downloadUrl)
assert.ok(equals(new Uint8Array(await res.arrayBuffer()), data))
},
}
2 changes: 1 addition & 1 deletion packages/upload-api/test/storage/blobs-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class BlobsStorage {
}

/** @param {Types.MultihashDigest} digest */
async createDownloadUrl (digest) {
async createDownloadUrl(digest) {
const url = new URL(this.#bucketPath(digest), this.baseURL)
return ok(/** @type {Types.URI} */ (url.toString()))
}
Expand Down
9 changes: 3 additions & 6 deletions packages/w3up-client/test/capability/blob.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ export const BlobClient = Test.withContext({
const multihash = await alice.capability.blob.add(new Blob([bytes]))

// TODO we should check blobsStorage as well
assert.deepEqual(
await allocationsStorage.exists(space.did(), multihash),
{
ok: true,
}
)
assert.deepEqual(await allocationsStorage.exists(space.did(), multihash), {
ok: true,
})

assert.deepEqual(multihash, bytesHash)
},
Expand Down
5 changes: 1 addition & 4 deletions packages/w3up-client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ export const testClient = {
})

assert.deepEqual(
await allocationsStorage.exists(
space.did(),
expectedCar.cid.multihash
),
await allocationsStorage.exists(space.did(), expectedCar.cid.multihash),
{
ok: true,
}
Expand Down

0 comments on commit 4281798

Please sign in to comment.