2023-03-13 13:05:02 +01:00
|
|
|
import pkg/questionable/results
|
|
|
|
|
|
|
|
|
|
import pkg/chronos
|
|
|
|
|
import pkg/asynctest
|
|
|
|
|
import pkg/libp2p
|
|
|
|
|
|
|
|
|
|
import pkg/codex/stores/cachestore
|
|
|
|
|
import pkg/codex/chunker
|
|
|
|
|
import pkg/codex/stores
|
|
|
|
|
import pkg/codex/blocktype as bt
|
|
|
|
|
|
|
|
|
|
import ../helpers
|
|
|
|
|
import ./commonstoretests
|
|
|
|
|
|
|
|
|
|
suite "MemoryStore":
|
2023-03-13 14:48:09 +01:00
|
|
|
test "Should store initial blocks":
|
|
|
|
|
let
|
|
|
|
|
capacity = 100
|
|
|
|
|
blk = createTestBlock(10)
|
2023-03-13 13:05:02 +01:00
|
|
|
|
2023-03-13 16:16:45 +01:00
|
|
|
let store = MemoryStore.new([blk], capacity)
|
2023-03-13 13:05:02 +01:00
|
|
|
|
2023-03-13 14:48:09 +01:00
|
|
|
let receivedBlk = await store.getBlock(blk.cid)
|
2023-03-13 13:05:02 +01:00
|
|
|
|
2023-03-13 14:48:09 +01:00
|
|
|
check receivedBlk.tryGet() == blk
|
2023-03-13 13:05:02 +01:00
|
|
|
|
|
|
|
|
commonBlockStoreTests(
|
|
|
|
|
"MemoryStore", proc: BlockStore =
|
2023-03-13 14:48:09 +01:00
|
|
|
BlockStore(MemoryStore.new([]))
|
2023-03-13 13:05:02 +01:00
|
|
|
)
|