diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-08-01 01:27:42 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-08-01 01:27:42 +0000 |
| commit | b7a09b8c8913b26eb22b98aa77a324a1c23736e2 (patch) | |
| tree | 366688654cf0a38b302c22b5151a11f6734dc6d8 /test/unit | |
| parent | 9cbaf09aaefb7e358bb18ac2eb31b0493f4b2fbb (diff) | |
| download | RNT-b7a09b8c8913b26eb22b98aa77a324a1c23736e2.tar.gz RNT-b7a09b8c8913b26eb22b98aa77a324a1c23736e2.zip | |
Actually test persistence
Diffstat (limited to '')
| -rw-r--r-- | test/unit/kernel/Merkle.ml | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/test/unit/kernel/Merkle.ml b/test/unit/kernel/Merkle.ml index a08426f..f12182a 100644 --- a/test/unit/kernel/Merkle.ml +++ b/test/unit/kernel/Merkle.ml @@ -15,7 +15,7 @@ module Make (S : Abstract.Storage.STORAGE) (C : Helpers.Storage.CONFIGURATOR) = module T = Rnt.Kernel.Merkle.Interface (S) (StringKey) (StringKey) (* TODO: be a bit more comprehensive (ideally, we want to test splits as well) *) - let storage_and_lookup conn = + let insert_and_lookup conn = let v1, v2, v3, v3', bogus = begin let open Utilities.Result in @@ -41,13 +41,45 @@ module Make (S : Abstract.Storage.STORAGE) (C : Helpers.Storage.CONFIGURATOR) = check (option string) "" (Some "toodles") v3'; check (option string) "" None bogus + let persistence conn = + let addr = + begin + let open Utilities.Result in + let* tx = S.start conn in + let* node = T.empty + |> T.insert tx "k1" "v1" + |> fmap (T.insert tx "k2" "v2") + |> fmap (T.insert tx "k3" "v3") + in + let* () = S.commit tx in + Ok (T.hash_of node) + end + |> Helpers.condition_as_failure + in + let v1, v2, v3 = + begin + let open Utilities.Result in + let* tx = S.start conn in + let* node = T.find tx addr |> Result.map Option.get in + let* v1 = T.lookup tx "k1" node in + let* v2 = T.lookup tx "k2" node in + let* v3 = T.lookup tx "k3" node in + Ok (v1, v2, v3) + end + |> Helpers.condition_as_failure + in + check (option string) "" (Some "v1") v1; + check (option string) "" (Some "v2") v2; + check (option string) "" (Some "v3") v3 + (* TODO: this will need `remove` *) (* let determinism _conn = *) (* () *) let suite prefix = ( "merkle/" ^ prefix, - [test_case "storage-and-lookup" `Quick (H.with_connection storage_and_lookup "merkle-test")]) + [test_case "insert-and-lookup" `Quick (H.with_connection insert_and_lookup "merkle-test"); + test_case "persistence" `Quick (H.with_connection persistence "merkle-test")]) end module LMDB = Make (Rnt.Backend.Storage.LMDB) (Helpers.Storage.LMDB_Configurator) |
