Skip to content

docs(intelligent-contracts): add Testing guide for Direct Mode and Studio Mode#353

Open
Ridwannurudeen wants to merge 3 commits intogenlayerlabs:mainfrom
Ridwannurudeen:docs/testing-guide
Open

docs(intelligent-contracts): add Testing guide for Direct Mode and Studio Mode#353
Ridwannurudeen wants to merge 3 commits intogenlayerlabs:mainfrom
Ridwannurudeen:docs/testing-guide

Conversation

@Ridwannurudeen
Copy link

@Ridwannurudeen Ridwannurudeen commented Mar 2, 2026

Summary

  • Adds a new Testing Intelligent Contracts guide page under pages/developers/intelligent-contracts/testing.mdx
  • Adds \"testing\": \"Testing\" to the section _meta.json (placed after Debugging, before Deploying)

Motivation

The api-references/genlayer-test page covers the Studio Mode API in detail, but there is no developer-guide page walking developers through how to actually test their contracts. The genlayer-testing-suite README now leads with Direct Mode — a faster, in-process runner that requires no Docker and produces millisecond test results — but this mode has no documentation in the main docs.

New developers looking for "how do I test my contract?" find only the API reference and a brief mention in tooling-setup. This PR fills that gap.

What the page covers

  • Two-mode overview table (Direct vs Studio) so developers can choose the right tool
  • Direct Mode quick start — deploy in-memory, call view/write methods, run with pytest
  • Fixtures referencedirect_vm, direct_deploy, direct_alice/bob/charlie, etc.
  • Cheatcodes — sender control, prank, snapshot/revert, expect_revert
  • Mockingmock_web and mock_llm with regex patterns; strict_mocks
  • Consensus testingrun_validator() to verify equivalence principle behavior
  • Studio Mode quick start + link to full API reference
  • Testing strategy — layered approach (storage → mocks → consensus → Studio)

Related

  • Complements the existing api-references/genlayer-test reference (no duplication — this is a guide, not a reference)
  • Addresses the developer experience gap noted in the ecosystem report (#346)

Summary by CodeRabbit

  • Documentation

    • Added comprehensive "Testing" documentation for Intelligent Contracts: installation, quick-start, execution modes, fixtures, cheatcodes, mocking guidance, examples, and testing workflow
    • Included tips, callouts, and best practices for snapshot/revert, expect_revert, and Studio usage
  • Chores

    • Added a new "Testing" section label to the Intelligent Contracts documentation navigation

@vercel
Copy link
Contributor

vercel bot commented Mar 2, 2026

@Ridwannurudeen is attempting to deploy a commit to the YeagerAI Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link

netlify bot commented Mar 2, 2026

Deploy Preview for genlayer-docs ready!

Name Link
🔨 Latest commit 7343412
🔍 Latest deploy log https://app.netlify.com/projects/genlayer-docs/deploys/69a548cc4fc2e30008458145
😎 Deploy Preview https://deploy-preview-353--genlayer-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 757cccf and 7343412.

📒 Files selected for processing (1)
  • pages/developers/intelligent-contracts/testing.mdx

📝 Walkthrough

Walkthrough

Adds a new "Testing" navigation entry and a comprehensive testing guide (GenLayer Testing Suite) under developers/intelligent-contracts, introducing Direct and Studio execution modes, setup, examples, fixtures, cheatcodes, mocking strategies, and testing workflows.

Changes

Cohort / File(s) Summary
Navigation
pages/developers/intelligent-contracts/_meta.json
Adds a new "testing": "Testing" entry to the intelligent-contracts navigation metadata.
Documentation (new)
pages/developers/intelligent-contracts/testing.mdx
Adds a new testing guide describing GenLayer Testing Suite: execution modes (Direct/Studio), installation, quick-start examples, fixtures & cheatcodes, mock patterns for non-deterministic calls (web/LLM), testing strategies (snapshot/revert, expect_revert), and workflow recommendations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • cristiam86

Poem

🐰🔎 I hopped through docs with testing in sight,
Modes and mocks made the workflow light.
Fixtures snug, snapshots near,
Contracts tested without a fear—
A rabbit's cheer for tests done right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Testing guide documentation for intelligent contracts covering Direct Mode and Studio Mode.
Description check ✅ Passed The description provides comprehensive context including summary of changes, motivation, detailed coverage of page content, and related issues, exceeding the template requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pages/developers/intelligent-contracts/testing.mdx (2)

139-141: Minor: Consider using type="warning" for strict mode callout.

The strict_mocks tip describes behavior that catches bugs. Using type="warning" instead of type="tip" would visually emphasize this is about preventing issues rather than just a helpful suggestion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/developers/intelligent-contracts/testing.mdx` around lines 139 - 141,
The Callout currently uses type="tip" but the content warns about catching bugs
via direct_vm.strict_mocks; update the Callout to use type="warning" so the UI
emphasizes prevention of issues—locate the Callout component wrapping the text
about setting direct_vm.strict_mocks = True and change its type prop from "tip"
to "warning".

177-189: Studio Mode example may have inconsistent import and fixture patterns.

The Studio Mode example imports get_default_account but uses default_account as a fixture parameter without showing how they connect. Additionally, factory.deploy(args=["initial"]) syntax differs from Direct Mode's positional args in direct_deploy("contracts/Storage.py", "initial value").

Consider either:

  1. Showing the fixture setup that provides default_account
  2. Clarifying in text that Studio Mode uses different fixtures/patterns than Direct Mode
Suggested clarification
 ```python
 from gltest import get_contract_factory, get_default_account
 from gltest.assertions import tx_execution_succeeded

+# The `default_account` fixture is provided by genlayer-test for Studio Mode
 def test_contract_integration(default_account):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/developers/intelligent-contracts/testing.mdx` around lines 177 - 189,
The Studio Mode example shows get_default_account imported but uses the fixture
default_account without connecting them; update the example or surrounding text
to either (A) show the fixture provider (e.g., note that the default_account
fixture is supplied by genlayer-test/Studio Mode) or (B) remove the unused
import and use get_default_account explicitly—specifically adjust the
test_contract_integration example and imports (get_contract_factory,
get_default_account, default_account) or add a one-line comment above
test_contract_integration clarifying that default_account is a pre-provided
Studio Mode fixture so readers know why the fixture and import appear different
from the Direct Mode direct_deploy pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pages/developers/intelligent-contracts/testing.mdx`:
- Around line 33-46: The test_storage example currently defines an unused
parameter direct_vm; remove it from the function signature so the test reads def
test_storage(direct_deploy): to avoid confusion and show the minimal fixture
required — update the test function name signature (test_storage) and ensure
only the direct_deploy fixture is referenced in the body.

---

Nitpick comments:
In `@pages/developers/intelligent-contracts/testing.mdx`:
- Around line 139-141: The Callout currently uses type="tip" but the content
warns about catching bugs via direct_vm.strict_mocks; update the Callout to use
type="warning" so the UI emphasizes prevention of issues—locate the Callout
component wrapping the text about setting direct_vm.strict_mocks = True and
change its type prop from "tip" to "warning".
- Around line 177-189: The Studio Mode example shows get_default_account
imported but uses the fixture default_account without connecting them; update
the example or surrounding text to either (A) show the fixture provider (e.g.,
note that the default_account fixture is supplied by genlayer-test/Studio Mode)
or (B) remove the unused import and use get_default_account
explicitly—specifically adjust the test_contract_integration example and imports
(get_contract_factory, get_default_account, default_account) or add a one-line
comment above test_contract_integration clarifying that default_account is a
pre-provided Studio Mode fixture so readers know why the fixture and import
appear different from the Direct Mode direct_deploy pattern.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e7426e and 757cccf.

📒 Files selected for processing (2)
  • pages/developers/intelligent-contracts/_meta.json
  • pages/developers/intelligent-contracts/testing.mdx

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.

1 participant