[KLC-2316] Add tests/scenarios to knowledge base#40
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new testing knowledge category to the Klever VM knowledge base and populates it with unit/whitebox/blackbox/scenario JSON guidance so MCP users can search and browse testing patterns alongside existing docs, examples, and best practices.
Changes:
- Added
testingas a first-class knowledge category in MCP resources (category list, tag mapping, and index descriptions). - Introduced a new
src/knowledge/testing/module with curated entries for unit tests, whitebox tests, blackbox tests, and.scen.jsonscenario files. - Wired the testing category into the aggregated knowledge export (
src/knowledge/index.ts).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mcp/resources.ts | Adds the new testing category, its tag mapping, and index description so it is browseable via MCP resources. |
| src/knowledge/index.ts | Includes the new testing knowledge module in the full knowledge export and named exports. |
| src/knowledge/testing/index.ts | Aggregates the testing knowledge entries (unit/whitebox/blackbox/scenario JSON). |
| src/knowledge/testing/unit-tests.ts | Adds a unit-testing entry using SingleTxApi (contains an invalid Cargo version string). |
| src/knowledge/testing/whitebox-tests.ts | Adds a whitebox testing entry using BlockchainStateWrapper plus a WhiteboxContract example. |
| src/knowledge/testing/blackbox-tests.ts | Adds blackbox testing guidance for ScenarioWorld fluent API + step-based API (includes a snippet that won’t compile as written). |
| src/knowledge/testing/scenario-json.ts | Adds a scenario JSON (.scen.json) structure/running/generation entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fbsobreira
left a comment
There was a problem hiding this comment.
Multi-agent code review
Reviewed by 4 agents (pr-review-toolkit, CodeRabbit, Codex, security-auditor) and cross-correlated. Security: clean — no new dependencies, no attack-surface change. TypeScript wiring: correct (pnpm test 131/131, typecheck/lint clean).
All 12 inline comments are warning-severity issues in the embedded Rust/JSON code examples that ship as authoritative documentation to LLM clients. Most are undeclared identifiers or contradictions that would prevent a copy-paste from compiling. Suggestions (#13-20 in the orchestrator's table) are intentionally not posted to keep the review actionable.
The documentation pattern I'd suggest before re-pushing: each fenced rust block in a knowledge entry should be self-contained — imports, address constants, and helper definitions present in every snippet, or grouped under a single "Setup" snippet that all examples in that entry assume.
- scenario-json: switch language from 'markdown' to 'rust' for consistent fenced-block rendering - whitebox-tests: drop "(Legacy)" label and clarify relationship to WhiteboxContract API - blackbox-tests: note RustBigUint re-export in querying example - resources.test: assert real testingKnowledge module exports and tag every entry with 'testing'
This pull request introduces a comprehensive "testing" knowledge category to the Klever knowledge base, providing detailed resources and examples for unit, whitebox, blackbox, and scenario-based testing of smart contracts. The changes add new knowledge entries, update exports and category mappings, and enhance the categorization and discoverability of testing-related documentation.
Testing Knowledge Base Expansion:
testingknowledge category, including detailed guides and code examples for:SingleTxApi(unit-tests.ts)BlockchainStateWrapperand related patterns (whitebox-tests.ts)scenario-json.ts)src/knowledge/testing/index.tsfor unified exportKnowledge Base Integration:
testingKnowledgein the main knowledge base (kleverKnowledge) and exported it for targeted access insrc/knowledge/index.ts[1] [2] [3]MCP Resource Category Updates:
src/mcp/resources.ts[1] [2]