add list block tests

This commit is contained in:
Dmitriy Ryajov 2022-04-19 19:21:32 -06:00
parent 9b729e0d76
commit 4f5f142a37
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 16 additions and 2 deletions

View File

@ -106,3 +106,15 @@ suite "Cache Store tests":
await store.delBlock(newBlock2.cid)
store.currentSize == 200
newBlock2.cid notin store
test "listBlocks":
discard await store.putBlock(newBlock1)
var listed = false
await store.listBlocks(
proc(blk: Block) {.gcsafe, async.} =
check blk.cid in store
listed = true
)
check listed

View File

@ -52,11 +52,13 @@ suite "FS Store":
check store.hasBlock(newBlock.cid)
test "blockList":
test "listBlocks":
createDir(store.blockPath(newBlock.cid).parentDir)
writeFile(store.blockPath(newBlock.cid), newBlock.data)
check (await store.blockList()) == @[newBlock.cid]
await store.listBlocks(
proc(blk: Block) {.gcsafe, async.} =
check blk.cid == newBlock.cid)
test "fail hasBlock":
check not store.hasBlock(newBlock.cid)