summaryrefslogtreecommitdiff
path: root/ocaml/test/old/test_poke_solid_arvo.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/test/old/test_poke_solid_arvo.ml')
-rw-r--r--ocaml/test/old/test_poke_solid_arvo.ml120
1 files changed, 120 insertions, 0 deletions
diff --git a/ocaml/test/old/test_poke_solid_arvo.ml b/ocaml/test/old/test_poke_solid_arvo.ml
new file mode 100644
index 0000000..e81c41f
--- /dev/null
+++ b/ocaml/test/old/test_poke_solid_arvo.ml
@@ -0,0 +1,120 @@
+(* Test poking the Arvo kernel from solid pill *)
+
+open Nock_lib
+
+let extract_arvo_from_solid () =
+ Printf.printf "Extracting Arvo from solid pill...\n";
+
+ let in_channel = open_in_bin "solid.noun" in
+ let pill = (Marshal.from_channel in_channel : Noun.noun) in
+ close_in in_channel;
+
+ match pill with
+ | Noun.Cell (_tag, events) ->
+ (* Get event 1 which should be the initial kernel *)
+ let rec nth n noun =
+ match noun with
+ | Noun.Atom _ -> None
+ | Noun.Cell (item, rest) ->
+ if n = 0 then Some item
+ else nth (n - 1) rest
+ in
+
+ begin match nth 1 events with
+ | Some (Noun.Cell (_wire, card)) ->
+ Printf.printf "✓ Extracted Arvo from event 1\n\n";
+ Some card
+ | _ ->
+ Printf.printf "✗ Could not extract event 1\n";
+ None
+ end
+
+ | _ -> None
+
+let test_poke _env =
+ Printf.printf "🎯 Testing Arvo Poke from Solid Pill\n\n";
+
+ match extract_arvo_from_solid () with
+ | None ->
+ Printf.printf "✗ Failed to extract Arvo\n"
+
+ | Some arvo ->
+ Printf.printf "Creating test event...\n";
+
+ (* Simple test event: [wire card] *)
+ let test_event = Noun.cell
+ (Noun.atom 0) (* wire *)
+ (Noun.cell (Noun.atom 1) (Noun.atom 42)) (* card [1 42] *)
+ in
+
+ Printf.printf "Test event: [0 [1 42]]\n\n";
+
+ try
+ (* Get poke gate *)
+ let gate = Noun.slot (Z.of_int 23) arvo in
+ Printf.printf "✓ Found poke gate at slot 23\n\n";
+
+ (* Build subject: [event gate] *)
+ let subject = Noun.cell test_event gate in
+
+ (* Call gate: [9 2 [0 2] [0 3]] *)
+ let formula = Noun.cell
+ (Noun.atom 9)
+ (Noun.cell
+ (Noun.atom 2)
+ (Noun.cell
+ (Noun.cell (Noun.atom 0) (Noun.atom 2))
+ (Noun.cell (Noun.atom 0) (Noun.atom 3))))
+ in
+
+ Printf.printf "Calling Arvo poke gate...\n%!";
+ let start = Unix.gettimeofday () in
+ let result = Nock.nock_on subject formula in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf "✓ Poke succeeded in %.4fs!\n\n" elapsed;
+
+ (* Examine result *)
+ begin match result with
+ | Noun.Cell (effects, new_kernel) ->
+ Printf.printf "Result structure: [effects new_kernel]\n";
+ Printf.printf " Effects: %s\n"
+ (match effects with Noun.Atom _ -> "atom" | Noun.Cell _ -> "cell");
+ Printf.printf " New kernel: %s\n\n"
+ (match new_kernel with Noun.Atom _ -> "atom" | Noun.Cell _ -> "cell");
+
+ (* Check if new kernel still has poke gate *)
+ begin try
+ let _new_gate = Noun.slot (Z.of_int 23) new_kernel in
+ Printf.printf "✓ New kernel has poke gate\n\n";
+ Printf.printf "🎉 ARVO IS FULLY FUNCTIONAL!\n";
+ Printf.printf "\nWe can now:\n";
+ Printf.printf " - Send events to Arvo\n";
+ Printf.printf " - Process effects\n";
+ Printf.printf " - Build a full Urbit runtime!\n"
+ with _ ->
+ Printf.printf "✗ New kernel missing poke gate\n"
+ end
+
+ | Noun.Atom _ ->
+ Printf.printf "Result is an atom (unexpected)\n"
+ end
+
+ with
+ | Noun.Exit ->
+ Printf.printf "✗ Nock failed (Exit)\n";
+ Printf.printf "\nThis might mean:\n";
+ Printf.printf " - Wrong gate location (not slot 23)\n";
+ Printf.printf " - Wrong formula\n";
+ Printf.printf " - Event format is incorrect\n"
+ | Not_found ->
+ Printf.printf "✗ No gate at slot 23\n"
+
+let () =
+ Printf.printf "\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf " Test Poking Solid Pill Arvo\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf "\n";
+
+ Eio_main.run test_poke