| 1 | package builtin |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/tool" |
| 8 | ) |
| 9 | |
| 10 | func TestBuiltinContractSchemasDeclareRequiredArray(t *testing.T) { |
| 11 | seen := false |
| 12 | for _, entry := range tool.BuiltinContractEntries() { |
| 13 | var root map[string]json.RawMessage |
| 14 | if err := json.Unmarshal(entry.Schema, &root); err != nil { |
| 15 | t.Fatalf("%s: schema is not an object: %v", entry.Name, err) |
| 16 | } |
| 17 | var required []string |
| 18 | if raw, ok := root["required"]; !ok || string(raw) == "null" || json.Unmarshal(raw, &required) != nil { |
| 19 | t.Errorf("%s: root schema lacks a required array: %s", entry.Name, entry.Schema) |
| 20 | } |
| 21 | if entry.Name == "get_goal" { |
| 22 | seen = true |
| 23 | } |
| 24 | } |
| 25 | if !seen { |
| 26 | t.Fatal("get_goal is not a registered builtin") |
| 27 | } |
| 28 | } |
| 29 |