From genlayer-dev
Write and run integration tests against a GenLayer environment.
How this skill is triggered — by the user, by Claude, or both
Slash command
/genlayer-dev:integration-testsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Run contracts against a real GenLayer environment (GLSim, Studio, or testnet) with full consensus validation.
Run contracts against a real GenLayer environment (GLSim, Studio, or testnet) with full consensus validation.
# Against default network (from gltest.config.yaml)
gltest tests/integration/ -v -s
# Against specific network
gltest tests/integration/ -v -s --network localnet
gltest tests/integration/ -v -s --network studionet
gltest tests/integration/ -v -s --network testnet_bradbury
Always use -v -s for visible output during development.
from gltest import get_contract_factory
from gltest.assertions import tx_execution_succeeded
def test_full_flow():
factory = get_contract_factory("MyContract")
contract = factory.deploy(args=[])
# Write methods return transaction receipts
tx_receipt = contract.set_data(args=["hello"]).transact()
assert tx_execution_succeeded(tx_receipt)
# Read methods return values directly
result = contract.get_data(args=[contract.address]).call()
assert result == "hello"
| Direct Mode | Integration Tests | |
|---|---|---|
| Speed | ~30ms | ~seconds to minutes |
| Server required | No | Yes (GLSim, Studio, or testnet) |
| Consensus | Leader only | Full leader + validators |
| Write methods | Return values directly | Return transaction receipts |
| Read methods | Return values directly | Use .call() |
| Mocking | mock_web() / mock_llm() | Real web/LLM calls |
Write methods (state-changing):
# .transact() submits and waits for consensus
tx_receipt = contract.method_name(args=[arg1, arg2]).transact()
assert tx_execution_succeeded(tx_receipt)
Read methods (view-only):
# .call() reads without transaction
result = contract.view_method(args=[arg1]).call()
contract_path: contracts/
networks:
localnet:
# GenLayer Studio running locally
studionet:
# studio.genlayer.com
testnet_bradbury:
accounts:
- "${ACCOUNT_PRIVATE_KEY_1}"
- "${ACCOUNT_PRIVATE_KEY_2}"
import pytest
@pytest.mark.slow
def test_expensive_operation():
"""Excluded by default. Run with: gltest -m slow"""
pass
pip install genlayer-test[sim], glsim --port 4000 --validators 5) — lightweight, no Docker, ~1s startup. Runs Python natively, not in GenVM. Good for fast iteration.genlayer up) — full GenVM, real consensus, Docker required. Validates runtime compatibility.Direct mode should cover most logic testing. Use integration tests for final validation before deploying.
Clear cache: rm -rf .gltest_cache
Run single tests during development:
gltest tests/integration/test_file.py::test_specific -v -s
When working with mock validators, convert to dicts:
transaction_context = {"validators": [v.to_dict() for v in mock_validators]}
npx claudepluginhub genlayerlabs/skills --plugin genlayer-devCovers smart contract testing strategies using Hardhat and Foundry, including unit tests, integration, gas optimization, fuzzing, and mainnet forking.
Tests API endpoints, validates consumer-driven contracts between microservices, and verifies database interactions against real infrastructure.
Guides writing and running Cairo smart-contract tests with snforge: unit, integration, fuzz, fork, and regression tests. Covers cheatcode usage, coverage, and test strategy.