summaryrefslogtreecommitdiff
path: root/ocaml/test/old/test_solid_boot.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/test/old/test_solid_boot.ml')
-rw-r--r--ocaml/test/old/test_solid_boot.ml116
1 files changed, 116 insertions, 0 deletions
diff --git a/ocaml/test/old/test_solid_boot.ml b/ocaml/test/old/test_solid_boot.ml
new file mode 100644
index 0000000..08382da
--- /dev/null
+++ b/ocaml/test/old/test_solid_boot.ml
@@ -0,0 +1,116 @@
+(* Test Solid Pill Boot
+ *
+ * Try loading solid pill which contains full Arvo kernel
+ *)
+
+open Nock_lib
+
+let test_solid_boot env =
+ Printf.printf "🎯 Testing Solid Pill Boot\n\n";
+
+ Eio.Switch.run @@ fun _sw ->
+ let fs = Eio.Stdenv.fs env in
+
+ (* Load solid pill *)
+ Printf.printf "Loading solid pill (this may take a while)...\n";
+ let file_path = Eio.Path.(fs / "solid.pill") in
+ let pill_bytes = Eio.Path.load file_path |> Bytes.of_string in
+
+ Printf.printf "Pill size: %.1f MB\n"
+ (float_of_int (Bytes.length pill_bytes) /. 1024.0 /. 1024.0);
+
+ let start = Unix.gettimeofday () in
+ let pill = Serial.cue pill_bytes in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf "Cued in %.2fs\n\n" elapsed;
+
+ (* Examine structure *)
+ Printf.printf "Examining solid pill structure:\n";
+ if Noun.is_cell pill then begin
+ Printf.printf " ✓ Is cell\n";
+
+ (* Check for tag *)
+ let head = Noun.head pill in
+ let tail = Noun.tail pill in
+
+ Printf.printf " Head: %s\n" (if Noun.is_cell head then "Cell" else "Atom");
+ (match head with
+ | Noun.Atom z ->
+ Printf.printf " Value: %s\n" (Z.to_string z);
+ Printf.printf " Hex: 0x%s\n" (Z.format "x" z)
+ | _ -> ());
+
+ Printf.printf " Tail: %s\n\n" (if Noun.is_cell tail then "Cell" else "Atom");
+
+ (* Try to navigate to Arvo core at known path *)
+ Printf.printf "Navigating to Arvo core at [3 3 2 3 2 3 3 2]...\n";
+ let path = [3; 3; 2; 3; 2; 3; 3; 2] in
+ let rec navigate noun = function
+ | [] -> noun
+ | slot :: rest ->
+ navigate (Noun.slot (Z.of_int slot) noun) rest
+ in
+
+ try
+ let arvo = navigate tail path in
+ Printf.printf " ✓ Found Arvo core\n\n";
+
+ (* Test for slot 23 *)
+ Printf.printf "Testing for slot 23 (poke interface)...\n";
+ (try
+ let slot_23 = Noun.slot (Z.of_int 23) arvo in
+ Printf.printf " ✓ Slot 23 exists!\n";
+ Printf.printf " Type: %s\n\n"
+ (if Noun.is_cell slot_23 then "Cell (formula)" else "Atom");
+
+ (* Try C Vere poke sequence *)
+ Printf.printf "Attempting poke sequence:\n";
+ Printf.printf " 1. Run slot 23 formula on Arvo core\n";
+
+ let start = Unix.gettimeofday () in
+ let poke_gate = Nock.nock_on arvo slot_23 in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf " ✓ Got poke gate (%.4fs)\n" elapsed;
+
+ Printf.printf " 2. Slam poke gate with test event\n";
+ let event = Noun.cell (Noun.atom 0) (Noun.atom 42) in
+
+ (* Slam: [battery [event context]] *)
+ let battery = Noun.head poke_gate in
+ let context = Noun.tail (Noun.tail poke_gate) in
+ let new_core = Noun.cell battery (Noun.cell event context) in
+ let kick_formula = Noun.cell (Noun.atom 9)
+ (Noun.cell (Noun.atom 2)
+ (Noun.cell (Noun.atom 0) (Noun.atom 1))) in
+
+ Printf.printf " 3. Call arm 2\n";
+ let start = Unix.gettimeofday () in
+ let result = Nock.nock_on new_core kick_formula in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf " ✓ Poke succeeded in %.4fs!\n" elapsed;
+ Printf.printf " Result: %s\n\n"
+ (if Noun.is_cell result then "Cell (effects + new state)" else "Atom");
+
+ Printf.printf "🎉 SOLID PILL WORKS!\n";
+ Printf.printf "We have successfully poked Arvo!\n"
+
+ with e ->
+ Printf.printf " ✗ Slot 23 test failed: %s\n" (Printexc.to_string e))
+
+ with e ->
+ Printf.printf " ✗ Navigation failed: %s\n" (Printexc.to_string e)
+
+ end else
+ Printf.printf " ✗ Not a cell\n"
+
+let () =
+ Printf.printf "\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf " Testing Solid Pill Boot\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf "\n";
+
+ Eio_main.run test_solid_boot