diff --git a/src/lib/ai/knowledge.test.ts b/src/lib/ai/knowledge.test.ts index 116a908..4a47814 100644 --- a/src/lib/ai/knowledge.test.ts +++ b/src/lib/ai/knowledge.test.ts @@ -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(""); + 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(""); + 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(""); + 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(); diff --git a/src/lib/mip-markdown.test.ts b/src/lib/mip-markdown.test.ts index 103cb23..dbe08a1 100644 --- a/src/lib/mip-markdown.test.ts +++ b/src/lib/mip-markdown.test.ts @@ -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"; @@ -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 () => {