From 4f5f142a37a736222201a222c7b2a42f96e21b50 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 19 Apr 2022 19:21:32 -0600 Subject: [PATCH] add list block tests --- tests/dagger/stores/testcachestore.nim | 12 ++++++++++++ tests/dagger/stores/testfsstore.nim | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/dagger/stores/testcachestore.nim b/tests/dagger/stores/testcachestore.nim index 01cc18db..ea88ea22 100644 --- a/tests/dagger/stores/testcachestore.nim +++ b/tests/dagger/stores/testcachestore.nim @@ -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 diff --git a/tests/dagger/stores/testfsstore.nim b/tests/dagger/stores/testfsstore.nim index b2879591..86dd0411 100644 --- a/tests/dagger/stores/testfsstore.nim +++ b/tests/dagger/stores/testfsstore.nim @@ -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)