From 8481e301d5c8445c309e8db0c25ab40ead85e7fb Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 5 Dec 2022 09:00:13 -0600 Subject: [PATCH] add missed repo store test (#324) --- tests/codex/stores/testrepostore.nim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/codex/stores/testrepostore.nim b/tests/codex/stores/testrepostore.nim index d576cd9b..530dd2c4 100644 --- a/tests/codex/stores/testrepostore.nim +++ b/tests/codex/stores/testrepostore.nim @@ -61,6 +61,22 @@ suite "Test RepoStore Quota": repo.quotaUsedBytes == 0 uint64.fromBytesBE((await metaDs.get(QuotaUsedKey)).tryGet) == 0'u + test "Should not update current used bytes if block exist": + let + blk = bt.Block.new('a'.repeat(100).toBytes).tryGet() + repo = RepoStore.new(repoDs, metaDs, quotaMaxBytes = 200) + + check repo.quotaUsedBytes == 0 + (await repo.putBlock(blk)).tryGet + check repo.quotaUsedBytes == 100 + + # put again + (await repo.putBlock(blk)).tryGet + check repo.quotaUsedBytes == 100 + + check: + uint64.fromBytesBE((await metaDs.get(QuotaUsedKey)).tryGet) == 100'u + test "Should fail storing passed the quota": let blk = bt.Block.new('a'.repeat(200).toBytes).tryGet()