aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/kernel/SubstantialRelation.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-09-03 16:55:45 -0300
committerGitHub <noreply@github.com>2026-09-03 16:55:45 -0300
commit441f2f3359d6f59e4f26f1d5751926d26b1c7cf9 (patch)
treebfe2c858da6bd010ea656b6c9045af96ff7e4946 /test/unit/kernel/SubstantialRelation.ml
parent836e1ab528379ac5e0e9151cf369628dcf1034a3 (diff)
downloadRNT-441f2f3359d6f59e4f26f1d5751926d26b1c7cf9.tar.gz
RNT-441f2f3359d6f59e4f26f1d5751926d26b1c7cf9.zip
Substantial relation kernel object
Diffstat (limited to 'test/unit/kernel/SubstantialRelation.ml')
-rw-r--r--test/unit/kernel/SubstantialRelation.ml44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/kernel/SubstantialRelation.ml b/test/unit/kernel/SubstantialRelation.ml
new file mode 100644
index 0000000..9339845
--- /dev/null
+++ b/test/unit/kernel/SubstantialRelation.ml
@@ -0,0 +1,44 @@
+open Rnt
+
+module Make (S : Abstract.Storage.STORAGE) (C : Helpers.Storage.CONFIGURATOR) = struct
+ open Alcotest
+
+ module H = Helpers.Storage.Make (S) (C)
+ module SR = Rnt.Kernel.SubstantialRelation.Make (S)
+
+ let blob s = Concepts.Blob.blob_of_bytes (Bytes.of_string s)
+ let hash s = blob s |> Concepts.Hash.hash_of_blob
+
+ let assert_and_load conn =
+ let tuple = blob "tuple/alaric" in
+ let original_contains, updated_contains, loaded_contains =
+ begin
+ let open Utilities.Result in
+ let* tx = S.start conn in
+ let* original = SR.empty tx ~heading:(hash "heading") () in
+ let* original_contains = SR.contains_tuple tx original tuple in
+ let* updated = SR.assert_tuple tx original tuple in
+ let* updated_contains = SR.contains_tuple tx updated tuple in
+ let* stored = SR.store tx updated in
+ let* () = S.commit tx in
+ let* tx = S.start conn in
+ let* loaded = SR.load_value tx stored in
+ let* loaded_contains = SR.contains_tuple tx loaded tuple in
+ let* () = S.abort tx in
+ Ok (original_contains, updated_contains, loaded_contains)
+ end
+ |> Helpers.condition_as_failure
+ in
+ check bool "original" false original_contains;
+ check bool "updated" true updated_contains;
+ check bool "loaded" true loaded_contains
+
+ let suite prefix =
+ ( "substantial-relation/" ^ prefix,
+ [ test_case "assert-and-load" `Quick
+ (H.with_connection assert_and_load "substantial-relation-test") ] )
+end
+
+module LMDB = Make (Rnt.Backend.Storage.LMDB) (Helpers.Storage.LMDB_Configurator)
+
+let suites () = [LMDB.suite "lmdb"]