summaryrefslogtreecommitdiff
path: root/ocaml/test/old/test_arvo_slots.ml
blob: 5ec9f766202bf322faa7c595c88d6b4a3f7b135e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(* Test Available Slots on Arvo Core
 *
 * Check what slots are available on the Arvo core we found
 *)

open Nock_lib

let test_slot slot arvo =
  try
    let value = Noun.slot (Z.of_int slot) arvo in
    Printf.printf "  Slot %2d: exists (%s)\n" slot
      (if Noun.is_cell value then "cell" else "atom");
    Some value
  with _ ->
    Printf.printf "  Slot %2d: does not exist\n" slot;
    None

let test_arvo_slots env =
  Printf.printf "🔍 Testing Available Slots on Arvo Core\n\n";

  Eio.Switch.run @@ fun _sw ->
  let fs = Eio.Stdenv.fs env in

  (* Load solid pill *)
  let state = State.create () in
  match Boot.boot_from_file ~fs state "solid.pill" with
  | Error msg ->
      Printf.printf "✗ Failed to load pill: %s\n%!" msg
  | Ok () ->
      let pill_root = State.get_arvo state in

      Printf.printf "=== Testing PILL ROOT ===\n\n";
      Printf.printf "Testing slots 2-30 on pill root:\n\n";
      List.iter (fun slot -> ignore (test_slot slot pill_root))
        (List.init 29 (fun i -> i + 2));

      Printf.printf "\n\n=== Testing ARVO CORE (at depth 8) ===\n\n";

      (* Navigate to real Arvo *)
      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
      let arvo = navigate pill_root path in

      Printf.printf "Testing slots 2-30 on Arvo core:\n\n";
      List.iter (fun slot -> ignore (test_slot slot arvo))
        (List.init 29 (fun i -> i + 2));

      Printf.printf "\nLooking for formula slots that might be poke...\n\n";

      (* Check if any slot contains a formula (cell starting with opcode) *)
      for slot = 2 to 30 do
        match test_slot slot arvo with
        | Some value when Noun.is_cell value ->
            (match Noun.head value with
             | Noun.Atom z when Z.numbits z < 8 ->
                 let opcode = Z.to_int z in
                 if opcode >= 0 && opcode <= 11 then
                   Printf.printf "  Slot %d contains formula with opcode %d\n" slot opcode
             | _ -> ())
        | _ -> ()
      done

let () =
  Printf.printf "\n";
  Printf.printf "═══════════════════════════════════════════════════════════\n";
  Printf.printf " Testing Arvo Core Slots\n";
  Printf.printf "═══════════════════════════════════════════════════════════\n";
  Printf.printf "\n";

  Eio_main.run test_arvo_slots