Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Jun 17, 2024
1 parent bd9cbf7 commit 664e354
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/w3up-client/src/capability/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BlobClient extends Base {
options.connection = this._serviceConf.upload
const bytes = new Uint8Array(await blob.arrayBuffer())
const digest = await sha256.digest(bytes)
return Blob.add(conf, digest, bytes, options)
return { digest, ...(await Blob.add(conf, digest, bytes, options)) }
}

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/w3up-client/test/capability/blob.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export const BlobClient = Test.withContext({

const bytes = await randomBytes(128)
const bytesHash = await sha256.digest(bytes)
const { multihash } = await alice.capability.blob.add(new Blob([bytes]), {
const { digest } = await alice.capability.blob.add(new Blob([bytes]), {
receiptsEndpoint,
})

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

assert.deepEqual(multihash.bytes, bytesHash.bytes)
assert.deepEqual(digest.bytes, bytesHash.bytes)
},
'should list stored blobs': async (
assert,
Expand Down Expand Up @@ -71,10 +71,10 @@ export const BlobClient = Test.withContext({

const bytes = await randomBytes(128)
const bytesHash = await sha256.digest(bytes)
const { multihash } = await alice.capability.blob.add(new Blob([bytes]), {
const { digest } = await alice.capability.blob.add(new Blob([bytes]), {
receiptsEndpoint,
})
assert.deepEqual(multihash.bytes, bytesHash.bytes)
assert.deepEqual(digest.bytes, bytesHash.bytes)

const {
results: [entry],
Expand Down Expand Up @@ -109,11 +109,11 @@ export const BlobClient = Test.withContext({
})

const bytes = await randomBytes(128)
const { multihash } = await alice.capability.blob.add(new Blob([bytes]), {
const { digest } = await alice.capability.blob.add(new Blob([bytes]), {
receiptsEndpoint,
})

const result = await alice.capability.blob.remove(multihash)
const result = await alice.capability.blob.remove(digest)
assert.ok(result.ok)
},
'should get a stored blob': async (
Expand Down Expand Up @@ -142,11 +142,11 @@ export const BlobClient = Test.withContext({
})

const bytes = await randomBytes(128)
const { multihash } = await alice.capability.blob.add(new Blob([bytes]), {
const { digest } = await alice.capability.blob.add(new Blob([bytes]), {
receiptsEndpoint,
})

const result = await alice.capability.blob.get(multihash)
const result = await alice.capability.blob.get(digest)
assert.ok(result.ok)
},
})
Expand Down

0 comments on commit 664e354

Please sign in to comment.