aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-09-07 23:33:33 +0000
committerGitHub <noreply@github.com>2026-09-07 20:33:33 -0300
commit962981db8038b980d89142b0b89a1474f7448986 (patch)
tree4913f678c38b69b521f75bdcca9681cbf9de5cb3 /test
parent18e0c91873167c416e5c69a816741a52d4693bf4 (diff)
downloadRNT-962981db8038b980d89142b0b89a1474f7448986.tar.gz
RNT-962981db8038b980d89142b0b89a1474f7448986.zip
Allow users to defer persistence when constructing tree nodes
Diffstat (limited to 'test')
-rw-r--r--test/test_rnt.ml1
-rw-r--r--test/unit/kernel/Merkle.ml30
2 files changed, 31 insertions, 0 deletions
diff --git a/test/test_rnt.ml b/test/test_rnt.ml
index 7bad887..b80de90 100644
--- a/test/test_rnt.ml
+++ b/test/test_rnt.ml
@@ -1,5 +1,6 @@
let all_suites =
Unit.Backend.Storage.suites ()
+ @ Unit.Kernel.Merkle.suites ()
@ Unit.Kernel.SubstantialRelation.suites ()
@ Integration.Registration.suites ()
diff --git a/test/unit/kernel/Merkle.ml b/test/unit/kernel/Merkle.ml
index d5a075e..85c756c 100644
--- a/test/unit/kernel/Merkle.ml
+++ b/test/unit/kernel/Merkle.ml
@@ -34,6 +34,35 @@ module Make (S : Abstract.Storage.STORAGE) (C : Helpers.Storage.CONFIGURATOR) =
check (option string) "that in-memory reads from a value replacement work properly" (Some "toodles") v3';
check (option string) "that in-memory reads from a non-existent key returns nothing" None bogus
+ let batching conn =
+ let intermediate, final =
+ begin
+ let open Utilities.Result in
+ let* tx = S.start conn in
+ let intermediate = ref None in
+ let* final = T.with_batch tx (fun () ->
+ let* i = T.empty |> T.insert tx "tree" "maple" in
+ intermediate := Some (T.hash_of i);
+ T.insert tx "tree" "spruce" i) in
+ let* () = S.commit tx in
+ Ok (Option.get !intermediate, T.hash_of final)
+ end
+ |> Helpers.condition_as_failure
+ in
+ let i_node, f_node =
+ begin
+ let open Utilities.Result in
+ let* tx = S.start conn in
+ let* intermediate = T.find tx intermediate in
+ let* final = T.find tx final in
+ Ok (intermediate, final)
+ end
+ |> Helpers.condition_as_failure
+ in
+ check bool "that the intermediate node does not get persisted" true (Option.is_none i_node);
+ check bool "that the final node does get persisted" true (Option.is_some f_node)
+
+
let persistence conn =
let addr =
begin
@@ -92,6 +121,7 @@ module Make (S : Abstract.Storage.STORAGE) (C : Helpers.Storage.CONFIGURATOR) =
let suite prefix =
( "merkle/" ^ prefix,
[test_case "insert-and-lookup" `Quick (H.with_connection insert_and_lookup "merkle-test");
+ test_case "batching" `Quick (H.with_connection batching "merkle-test");
test_case "persistence" `Quick (H.with_connection persistence "merkle-test");
test_case "iteration" `Quick (H.with_connection iteration "merkle-test")])
end