2021-01-12 12:58:57 +00:00
|
|
|
import std/unittest
|
2021-01-14 12:54:03 +00:00
|
|
|
import pkg/ipfs/repo
|
2021-01-12 12:58:57 +00:00
|
|
|
|
|
|
|
suite "repo":
|
|
|
|
|
|
|
|
let dag = MerkleDag(data: @[1'u8, 2'u8, 3'u8])
|
|
|
|
var repo: Repo
|
|
|
|
|
|
|
|
setup:
|
|
|
|
repo = Repo()
|
|
|
|
|
|
|
|
test "stores Merkle DAGs":
|
|
|
|
repo.store(dag)
|
|
|
|
|
2021-01-14 12:41:54 +00:00
|
|
|
test "retrieves Merkle DAGs by their root id":
|
2021-01-12 12:58:57 +00:00
|
|
|
repo.store(dag)
|
2021-01-14 12:41:54 +00:00
|
|
|
check repo.retrieve(dag.rootId) == dag
|
2021-01-12 12:58:57 +00:00
|
|
|
|
2021-01-14 12:41:54 +00:00
|
|
|
test "knows which ids are stored":
|
|
|
|
check repo.contains(dag.rootId) == false
|
2021-01-12 12:58:57 +00:00
|
|
|
repo.store(dag)
|
2021-01-14 12:41:54 +00:00
|
|
|
check repo.contains(dag.rootId) == true
|