Skip to content

[KLC-2316] Add tests/scenarios to knowledge base#40

Merged
fbsobreira merged 4 commits into
developfrom
KLC-2316-Add-tests-to-knowledge-base
May 19, 2026
Merged

[KLC-2316] Add tests/scenarios to knowledge base#40
fbsobreira merged 4 commits into
developfrom
KLC-2316-Add-tests-to-knowledge-base

Conversation

@phcarneirobc

@phcarneirobc phcarneirobc commented May 5, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added a new testing knowledge category, including detailed guides and code examples for:
    • Unit tests using SingleTxApi (unit-tests.ts)
    • Whitebox tests with BlockchainStateWrapper and related patterns (whitebox-tests.ts)
    • Blackbox tests (referenced, but file not shown in this diff)
    • Scenario JSON files for portable, VM-independent contract testing (scenario-json.ts)
  • Aggregated all testing knowledge in src/knowledge/testing/index.ts for unified export

Knowledge Base Integration:

  • Registered the new testingKnowledge in the main knowledge base (kleverKnowledge) and exported it for targeted access in src/knowledge/index.ts [1] [2] [3]

MCP Resource Category Updates:

  • Added "testing" to the list of knowledge categories and mapped relevant tags for improved search and categorization in src/mcp/resources.ts [1] [2]
  • Updated the category description to clarify the scope of testing resources

Copilot AI review requested due to automatic review settings May 5, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 testing as 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.json scenario 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.

Comment thread src/mcp/resources.ts
Comment thread src/knowledge/testing/blackbox-tests.ts
@phcarneirobc phcarneirobc changed the title [KLC-23166] Add tests/scenarios to knowledge base [KLC-2316] Add tests/scenarios to knowledge base May 5, 2026

@fbsobreira fbsobreira left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/knowledge/testing/whitebox-tests.ts
Comment thread src/knowledge/testing/unit-tests.ts Outdated
Comment thread src/knowledge/testing/blackbox-tests.ts
Comment thread src/knowledge/testing/blackbox-tests.ts Outdated
Comment thread src/knowledge/testing/whitebox-tests.ts
Comment thread src/knowledge/testing/blackbox-tests.ts Outdated
Comment thread src/knowledge/testing/scenario-json.ts Outdated
Comment thread src/mcp/resources.test.ts
Comment thread src/knowledge/testing/whitebox-tests.ts
Comment thread src/mcp/resources.ts Outdated
phcarneirobc and others added 2 commits May 8, 2026 10:18
- 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'
@fbsobreira
fbsobreira merged commit df0f02c into develop May 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants