From 42817984e113bd49d5621040c0eceef90b2fd0a3 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 17 May 2024 14:36:52 +0100 Subject: [PATCH] chore: appease linter --- packages/upload-api/src/types.ts | 2 +- .../upload-api/test/handlers/web3.storage.js | 4 +- .../test/storage/allocations-storage-tests.js | 10 ++++- .../test/storage/blobs-storage-tests.js | 44 ++++++++++--------- .../upload-api/test/storage/blobs-storage.js | 2 +- .../w3up-client/test/capability/blob.test.js | 9 ++-- packages/w3up-client/test/client.test.js | 5 +-- 7 files changed, 40 insertions(+), 36 deletions(-) diff --git a/packages/upload-api/src/types.ts b/packages/upload-api/src/types.ts index e785e88bd..ad1d2c7c7 100644 --- a/packages/upload-api/src/types.ts +++ b/packages/upload-api/src/types.ts @@ -199,7 +199,7 @@ export type { IPNIService, BlobRetriever, BlobNotFound, - ShardedDAGIndex + ShardedDAGIndex, } from './types/index.js' export interface Service extends StorefrontService, W3sService { diff --git a/packages/upload-api/test/handlers/web3.storage.js b/packages/upload-api/test/handlers/web3.storage.js index 2d1d2ec24..60fd59ad4 100644 --- a/packages/upload-api/test/handlers/web3.storage.js +++ b/packages/upload-api/test/handlers/web3.storage.js @@ -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': diff --git a/packages/upload-api/test/storage/allocations-storage-tests.js b/packages/upload-api/test/storage/allocations-storage-tests.js index 213830fe2..910093c6b 100644 --- a/packages/upload-api/test/storage/allocations-storage-tests.js +++ b/packages/upload-api/test/storage/allocations-storage-tests.js @@ -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) @@ -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) }, diff --git a/packages/upload-api/test/storage/blobs-storage-tests.js b/packages/upload-api/test/storage/blobs-storage-tests.js index 21703da6c..9596533ef 100644 --- a/packages/upload-api/test/storage/blobs-storage-tests.js +++ b/packages/upload-api/test/storage/blobs-storage-tests.js @@ -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)) + }, } diff --git a/packages/upload-api/test/storage/blobs-storage.js b/packages/upload-api/test/storage/blobs-storage.js index c4622e85c..f1f7489dd 100644 --- a/packages/upload-api/test/storage/blobs-storage.js +++ b/packages/upload-api/test/storage/blobs-storage.js @@ -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())) } diff --git a/packages/w3up-client/test/capability/blob.test.js b/packages/w3up-client/test/capability/blob.test.js index 794626933..d275f307a 100644 --- a/packages/w3up-client/test/capability/blob.test.js +++ b/packages/w3up-client/test/capability/blob.test.js @@ -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) }, diff --git a/packages/w3up-client/test/client.test.js b/packages/w3up-client/test/client.test.js index 0b4d81d71..dac64827b 100644 --- a/packages/w3up-client/test/client.test.js +++ b/packages/w3up-client/test/client.test.js @@ -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, }