Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions src/lib/ai/knowledge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,95 @@ import { describe, expect, it } from "vitest";

import { getKnowledgeBundle } from "@/lib/ai/knowledge";

describe("MIP-3 knowledge bundle", () => {
it("loads reviewed facts and excludes placeholders", async () => {
const bundle = await getKnowledgeBundle();

expect(bundle).toContain("<!-- file: mip-3.md -->");
expect(bundle).toContain("# MIP-3: Linear Memory");
expect(bundle).toContain("**Proposal status:** Final");
expect(bundle).toContain(
"Activated with the MONAD_NINE upgrade on Monad mainnet on March 19, 2026",
);
expect(bundle).toContain("memory_cost = memory_size_words // 2");
expect(bundle).toContain("8 * 1024 * 1024 - j - k");
expect(bundle).toContain("8 MB per transaction, shared across call frames");
expect(bundle.replace(/\s+/g, " ")).toContain(
"halts exceptionally and consumes all gas left in that call frame",
);
expect(bundle).toContain(
"https://forum.monad.xyz/t/mip-3-linear-evm-memory-cost/362",
);
expect(bundle).toContain(
"https://github.com/monad-crypto/MIPs/blob/282d18125d6590447d9229550887581385649e48/MIPs/MIP-3.md",
);
expect(bundle).not.toContain("TODO(author)");
});
});

describe("MIP-4 knowledge bundle", () => {
it("loads reviewed facts and excludes placeholders", async () => {
const bundle = await getKnowledgeBundle();

expect(bundle).toContain("<!-- file: mip-4.md -->");
expect(bundle).toContain("# MIP-4: Reserve Balance Introspection");
expect(bundle).toContain("**Proposal status:** Final");
expect(bundle).toContain(
"Activated with the MONAD_NINE upgrade on Monad mainnet on March 19, 2026",
);
expect(bundle).toContain("`0x1001`");
expect(bundle).toContain("It must be called with `CALL`");
expect(bundle).toContain("STATICCALL");
expect(bundle).toContain("DELEGATECALL");
expect(bundle).toContain("CALLCODE");
expect(bundle).toContain("0x3a61584e");
expect(bundle).toContain("100 gas, the same as one `TLOAD`");
expect(bundle).toContain("method not supported");
expect(bundle).toContain("input is invalid");
expect(bundle).toContain("value is nonzero");
expect(bundle).toContain(
"Every revert consumes all gas given to the call frame",
);
expect(bundle).toContain(
"https://forum.monad.xyz/t/mip-4-reserve-balance-introspection/363",
);
expect(bundle).toContain(
"https://github.com/monad-crypto/MIPs/blob/282d18125d6590447d9229550887581385649e48/MIPs/MIP-4.md",
);
expect(bundle).not.toContain("TODO(author)");
});
});

describe("MIP-7 knowledge bundle", () => {
it("loads reviewed facts and excludes placeholders", async () => {
const bundle = await getKnowledgeBundle();

expect(bundle).toContain("<!-- file: mip-7.md -->");
expect(bundle).toContain("# MIP-7: Extension Opcodes");
expect(bundle).toContain("**Proposal status:** Review");
expect(bundle).toContain(
"**Network status:** No activation evidence in this bundle",
);
expect(bundle).toContain("`EXTENSION` (`0xAE`)");
expect(bundle).toContain("0xAE XX");
expect(bundle).toContain("0x5B");
expect(bundle).toContain("0x60`-`0x7F");
expect(bundle).toContain("at the very end of the code has no selector");
expect(bundle).toContain("INVALID");
expect(bundle).toContain("0xFE");
expect(bundle).toContain("Restricted-range immediates");
expect(bundle).toContain("PUSH-prefix immediates");
expect(bundle).toContain("JUMPDEST");
expect(bundle).toContain(
"https://forum.monad.xyz/t/mip-7-extension-opcodes/387",
);
expect(bundle).toContain(
"https://github.com/monad-crypto/MIPs/blob/282d18125d6590447d9229550887581385649e48/MIPs/MIP-7.md",
);
expect(bundle).not.toContain("TODO(author)");
});
});

describe("MIP-12 knowledge bundle", () => {
it("loads current MIP-12 status and sourced activation facts", async () => {
const bundle = await getKnowledgeBundle();
Expand Down
37 changes: 35 additions & 2 deletions src/lib/mip-markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vi.mock("@/lib/mip-index", () => ({
import { GET as indexMarkdownRoute } from "@/app/index.md/route";
import { GET as llmsTxtRoute } from "@/app/llms.txt/route";
import { GET as mip3MarkdownRoute } from "@/app/mip-3.md/route";
import { GET as mip4MarkdownRoute } from "@/app/mip-4.md/route";
import { GET as mip7MarkdownRoute } from "@/app/mip-7.md/route";
import { GET as mip10MarkdownRoute } from "@/app/mip-10.md/route";
import { GET as mip12MarkdownRoute } from "@/app/mip-12.md/route";
Expand Down Expand Up @@ -51,12 +52,44 @@ describe("route mapping", () => {
});

describe(".md route handlers", () => {
it("mip-3.md returns its source as text/markdown", async () => {
it("mip-3.md serves the reviewed status, linear cost facts, and source links", async () => {
const res = await mip3MarkdownRoute();
const body = await res.text();

expect(res.headers.get("content-type")).toBe(
"text/markdown; charset=utf-8",
);
expect(await res.text()).toBe(await readMipSource("mip-3"));
expect(body).toBe(await readMipSource("mip-3"));
expect(body).toContain("**Proposal status:** Final");
expect(body).toContain("8 MB per transaction, shared across call frames");
expect(body).toContain("memory_cost = memory_size_words // 2");
expect(body.replace(/\s+/g, " ")).toContain(
"halts exceptionally and consumes all gas left in that call frame",
);
expect(body).toContain("282d18125d6590447d9229550887581385649e48");
expect(body).not.toContain("TODO(author)");
});

it("mip-4.md serves the reviewed status, CALL-only precompile facts, and source links", async () => {
const res = await mip4MarkdownRoute();
const body = await res.text();

expect(res.headers.get("content-type")).toBe(
"text/markdown; charset=utf-8",
);
expect(body).toBe(await readMipSource("mip-4"));
expect(body).toContain("**Proposal status:** Final");
expect(body).toContain("`0x1001`");
expect(body).toContain("It must be called with `CALL`");
expect(body).toContain("0x3a61584e");
expect(body).toContain("method not supported");
expect(body).toContain("input is invalid");
expect(body).toContain("value is nonzero");
expect(body).toContain(
"Every revert consumes all gas given to the call frame",
);
expect(body).toContain("282d18125d6590447d9229550887581385649e48");
expect(body).not.toContain("TODO(author)");
});

it("mip-12.md serves the corrected status, parameter facts, and source links", async () => {
Expand Down
Loading