원클릭으로
foundry-polkadot-testing
Test Solidity contracts with forge test --polkadot against pallet-revive runtime using EVM or PVM backends
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Test Solidity contracts with forge test --polkadot against pallet-revive runtime using EVM or PVM backends
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Unified methodology for deterministic AI interaction via Diátaxis (information architecture), COSTAR (prompt structure), and advanced reasoning techniques (CoT, Decision Matrices, Few-Shot). Transform LLMs from text predictors into cognitive decision engines.
Use when creating, refactoring, or validating OpenCode skills. Provides S.T.A.R. workflow, Bottom-Up Reconstruction, and Quality Gates. Semantic cohesion: Contextual granularity with dynamic context pruning.
| name | foundry-polkadot-testing |
| description | Test Solidity contracts with forge test --polkadot against pallet-revive runtime using EVM or PVM backends |
| license | MIT |
| compatibility | opencode |
| triggers | ["test polkadot","forge test --polkadot","foundry polkadot testing","pallet-revive testing","vm.polkadot","revive integration test"] |
| metadata | {"project_specific":true,"domains":["foundry","polkadot","testing","forge","pallet-revive","integration-testing"]} |
Test Solidity contracts against Polkadot's pallet-revive runtime using forge test with --polkadot flag.
<decision_matrix> What do you need to do?
references/running-tests.md Execute tests with --polkadot flag (EVM/PVM modes), understand test execution flow references/writing-tests.md Use vm.polkadot cheatcode, handle state migration, contract persistence references/integration-tests.md Create Solidity test contracts, Rust test wrappers, register in test module references/troubleshooting.md Common issues: numeric limits, state sync, bytecode selection, PVM compatibility references/state-migration.md Bidirectional sync (REVM ↔ pallet-revive), migration workflow, persistenceCRITICAL: ALWAYS use --polkadot flag to test against pallet-revive runtime.
# Run tests in standard REVM (no Polkadot integration)
forge test
# Run tests against Polkadot EVM runtime (PRODUCTION READY) - MUST use this for production
forge test --polkadot
# Run tests against Polkadot PVM runtime (EXPERIMENTAL) - NEVER use in production
forge test --polkadot=pvm
# Run specific test with verbose output - MUST use -vvv for debugging
forge test --polkadot --match-test testMyFunction -vvv
# Run with integer fuzzing limited (set max_fuzz_int in foundry.toml if needed)
forge test --polkadot
SAFETY RULES:
--polkadot before deploying to Polkadotvm.makePersistent before switching VMs with vm.polkadot(false)--polkadot=pvm for production testing--resolc when using PVM modeCRITICAL CONSTRAINTS:
vm.makePersistent(address) before using vm.polkadot(false)--resolc before testing PVM mode| Mode | Flag | Backend | Status | Use Case |
|---|---|---|---|---|
| REVM | (none) | Foundry's standard EVM | Stable | Local development, standard Ethereum |
| Polkadot EVM | --polkadot or --polkadot=evm | pallet-revive EVM | Production | Ethereum-compatible Polkadot testing |
| Polkadot PVM | --polkadot=pvm | PolkaVM (RISC-V) | Experimental | Advanced RISC-V features |
┌─────────────────────────────────────────────────────────────┐
│ Test Contract (runs in REVM) │
│ ├─ setUp() │
│ ├─ test functions │
│ └─ vm.polkadot(true) ← switches to pallet-revive │
└─────────────────────────────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────────┐
│ CREATE/CALL Interception │
│ ├─ CREATE/CREATE2 → deployed in pallet-revive │
│ ├─ CALL/STATICCALL → executed in pallet-revive │
│ └─ State syncs back to REVM after each operation │
└─────────────────────────────────────────────────────────────┘
MANDATORY EXECUTION RULES:
new MUST go to pallet-revive when --polkadot is activeCRITICAL THREE-PHASE SYNC (MUST happen in this order):
Initial Migration (REVM → pallet-revive): MUST trigger when --polkadot flag is used
After Each Call (pallet-revive → REVM): MUST happen after EVERY contract interaction
Switching Back (pallet-revive → REVM): MUST trigger when vm.polkadot(false) is called
# All tests against Polkadot EVM
forge test --polkadot
# Specific test pattern
forge test --polkadot --match-test test_revive
# With debug output
env RUST_LOG=warn,revive_strategy=info \
cargo test --package forge --test it test_revive_basic_migration -- --nocapture
// testdata/default/revive/MyTest.t.sol
pragma solidity ^0.8.18;
import "ds-test/test.sol";
import "cheats/Vm.sol";
contract MyTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);
function setUp() public {
// Setup runs in REVM
}
function testWithPolkadot() public {
// Deploys in pallet-revive (when --polkadot flag active)
Counter counter = new Counter();
// Mark for migration if switching VMs
vm.makePersistent(address(counter));
counter.increment();
assertEq(counter.number(), 1);
}
}
testdata/default/revive/MyTest.t.solcrates/forge/tests/it/revive/my_test.rscrates/forge/tests/it/revive/mod.rsSTOP: Read these constraints before writing tests.
CRITICAL: Polkadot uses smaller integer types than Ethereum.
| Type | Ethereum | Polkadot | Behavior |
|---|---|---|---|
| Block number | uint256 | u64 | Values > u64::MAX clamped with warning |
| Timestamp | uint256 | u64 | Values > u64::MAX clamped with warning |
| Balance | uint256 | u128 | Values > u128::MAX clamped with warning |
MANDATORY RULES:
uint64 for timestamps/block numbers in fuzz testsuint128 for balances in fuzz tests-vv flagFuzzing: Set max_fuzz_int in foundry.toml to limit fuzz values for Polkadot compatibility
--resolc compilation for PVM bytecodeforge clone requires an Etherscan API keyforge coverage --resolc fails with compiler error (standard and --polkadot work)State Synchronization:
select_revive() (line 649): REVM → pallet-revive migrationselect_evm() (line 903): pallet-revive → REVM migrationapply_revm_storage_diff() (line 1560): Post-call syncrevive_try_create() (line 985): CREATE interceptionrevive_try_call() (line 1212): CALL interceptionTest Infrastructure:
# Run full test suite
cargo test --workspace
# Run Polkadot integration tests
cargo test --package forge --test it test_revive_
# Run specific integration test
cargo test --package forge --test it test_revive_basic_migration
# Format and lint
cargo fmt --all
cargo clippy --workspace
test_revive_*.rs*.t.soltestCamelCase() or test_snake_case()See existing tests: