docs(intelligent-contracts): add Testing guide for Direct Mode and Studio Mode#353
docs(intelligent-contracts): add Testing guide for Direct Mode and Studio Mode#353Ridwannurudeen wants to merge 3 commits intogenlayerlabs:mainfrom
Conversation
|
@Ridwannurudeen is attempting to deploy a commit to the YeagerAI Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for genlayer-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pages/developers/intelligent-contracts/testing.mdx (2)
139-141: Minor: Consider usingtype="warning"for strict mode callout.The
strict_mockstip describes behavior that catches bugs. Usingtype="warning"instead oftype="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_accountbut usesdefault_accountas a fixture parameter without showing how they connect. Additionally,factory.deploy(args=["initial"])syntax differs from Direct Mode's positional args indirect_deploy("contracts/Storage.py", "initial value").Consider either:
- Showing the fixture setup that provides
default_account- 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
📒 Files selected for processing (2)
pages/developers/intelligent-contracts/_meta.jsonpages/developers/intelligent-contracts/testing.mdx
Summary
pages/developers/intelligent-contracts/testing.mdx\"testing\": \"Testing\"to the section_meta.json(placed after Debugging, before Deploying)Motivation
The
api-references/genlayer-testpage covers the Studio Mode API in detail, but there is no developer-guide page walking developers through how to actually test their contracts. Thegenlayer-testing-suiteREADME 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
direct_vm,direct_deploy,direct_alice/bob/charlie, etc.prank,snapshot/revert,expect_revertmock_webandmock_llmwith regex patterns;strict_mocksrun_validator()to verify equivalence principle behaviorRelated
api-references/genlayer-testreference (no duplication — this is a guide, not a reference)Summary by CodeRabbit
Documentation
Chores