Skip to content

Commit

Permalink
test: better assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Nov 29, 2024
1 parent 37d0e57 commit 4383f3f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/upload-client/test/sharding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,23 @@ describe('ShardingStream', () => {
)

assert.equal(shards.length, 2)
assert.ok(shards[0].slices.has(blocks[0].cid.multihash))
assert.ok(shards[0].slices.has(blocks[1].cid.multihash))
assert.ok(shards[1].slices.has(blocks[2].cid.multihash))

const shard0Bytes = new Uint8Array(await shards[0].arrayBuffer())
const shard1Bytes = new Uint8Array(await shards[1].arrayBuffer())

// block 0 and 1 should be in shard 0
const slice0 = shards[0].slices.get(blocks[0].cid.multihash)
assert.ok(slice0)
assert(equals(blocks[0].bytes, shard0Bytes.slice(slice0[0], slice0[0] + slice0[1])))

const slice1 = shards[0].slices.get(blocks[1].cid.multihash)
assert.ok(slice1)
assert(equals(blocks[1].bytes, shard0Bytes.slice(slice1[0], slice1[0] + slice1[1])))

// block 2 should be in shard 1
const slice2 = shards[1].slices.get(blocks[2].cid.multihash)
assert.ok(slice2)
assert(equals(blocks[2].bytes, shard1Bytes.slice(slice2[0], slice2[0] + slice2[1])))
})

it('exceeds shard size when block is encoded with root CID', async () => {
Expand Down

0 comments on commit 4383f3f

Please sign in to comment.