Skip to content

Commit d358039

Browse files
Apply suggestions from code review
Co-authored-by: Sean Zellmer <sean@lejeunerenard.com>
1 parent 1116e01 commit d358039

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ module.exports = class Hyperdrive extends ReadyResource {
486486
if (entry) {
487487
const blob = entry.value.blob
488488
if (!blob) return false
489-
return await this._hasEntry(blobs, blob)
489+
return this._hasEntry(blobs, blob)
490490
}
491491
let isDir = false
492492
for await (const entry of this.list(path)) {
@@ -668,7 +668,7 @@ module.exports = class Hyperdrive extends ReadyResource {
668668
}
669669
return true
670670
} else {
671-
return await blobs.core.has(blob.blockOffset, blob.blockOffset + blob.blockLength)
671+
return blobs.core.has(blob.blockOffset, blob.blockOffset + blob.blockLength)
672672
}
673673
}
674674

test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,13 @@ test('drive.download dedup entry', async (t) => {
827827
mirror.swarm.join(drive.discoveryKey, { server: false, client: true })
828828
await mirror.swarm.flush()
829829

830-
const ws = await drive.createWriteStream('/entry', { dedup: true })
830+
const ws = drive.createWriteStream('/entry', { dedup: true })
831831
ws.write(Buffer.alloc(1024))
832832
ws.end()
833833

834834
await ensureDbLength(mirror.drive, drive.version)
835835

836-
const download = await mirror.drive.download('/entry')
836+
const download = mirror.drive.download('/entry')
837837
await download.done()
838838

839839
const mirrorBlobs = await mirror.drive.getBlobs()
@@ -843,7 +843,7 @@ test('drive.download dedup entry', async (t) => {
843843
const driveBlobsHash = await driveBlobs.core.treeHash()
844844

845845
t.is(mirrorBlobs.core.contiguousLength, driveBlobs.core.contiguousLength)
846-
t.is(mirrorBlobsHash.toString('hex'), driveBlobsHash.toString('hex'))
846+
t.alike(mirrorBlobsHash, driveBlobsHash, 'blob hashes match')
847847
})
848848

849849
test('drive.download folder mixed dedup: true and dedup: false', async (t) => {
@@ -858,7 +858,7 @@ test('drive.download folder mixed dedup: true and dedup: false', async (t) => {
858858
await mirror.swarm.flush()
859859

860860
{
861-
const ws = await drive.createWriteStream('/folder/entry', { dedup: true })
861+
const ws = drive.createWriteStream('/folder/entry', { dedup: true })
862862
ws.write(Buffer.alloc(1024))
863863
ws.end()
864864
}
@@ -867,7 +867,7 @@ test('drive.download folder mixed dedup: true and dedup: false', async (t) => {
867867

868868
await ensureDbLength(mirror.drive, drive.version)
869869

870-
const download = await mirror.drive.download('/folder')
870+
const download = mirror.drive.download('/folder')
871871
await download.done()
872872

873873
const mirrorBlobs = await mirror.drive.getBlobs()
@@ -877,7 +877,7 @@ test('drive.download folder mixed dedup: true and dedup: false', async (t) => {
877877
const driveBlobsHash = await driveBlobs.core.treeHash()
878878

879879
t.is(mirrorBlobs.core.contiguousLength, driveBlobs.core.contiguousLength)
880-
t.is(mirrorBlobsHash.toString('hex'), driveBlobsHash.toString('hex'))
880+
t.alike(mirrorBlobsHash, driveBlobsHash, 'blob hashes match')
881881
})
882882

883883
test('drive.has(path)', async (t) => {
@@ -930,7 +930,7 @@ test('drive.has dedup entry is false after getting the blockMap', async (t) => {
930930
mirror.swarm.join(drive.discoveryKey, { server: false, client: true })
931931
await mirror.swarm.flush()
932932

933-
const ws = await drive.createWriteStream('/entry', { dedup: true })
933+
const ws = drive.createWriteStream('/entry', { dedup: true })
934934
ws.write(Buffer.alloc(1024))
935935
ws.write(Buffer.alloc(1024))
936936
ws.write(Buffer.alloc(1024))
@@ -942,7 +942,7 @@ test('drive.has dedup entry is false after getting the blockMap', async (t) => {
942942
await mirror.drive.getBlobs()
943943
await mirror.drive.blobs.core.get(1) // get map block
944944

945-
t.is(await mirror.drive.has('/entry'), false)
945+
t.absent(await mirror.drive.has('/entry'), 'has() is false w/ map, but w/o blocks')
946946
})
947947

948948
test('drive.batch() & drive.flush()', async (t) => {

0 commit comments

Comments
 (0)