web3-testing
Prueba smart contracts con Hardhat y Foundry
También disponible en: wshobson
Los desarrolladores de smart contracts necesitan frameworks de prueba confiables para garantizar la seguridad y corrección del código. Esta skill proporciona patrones de prueba integrales utilizando Hardhat y Foundry para pruebas unitarias, pruebas de integración y forking de mainnet.
Descargar el ZIP de la skill
Subir en Claude
Ve a Configuración → Capacidades → Skills → Subir skill
Activa y empieza a usar
Pruébalo
Usando "web3-testing". Generate a Foundry test for a vault contract that handles deposits and withdrawals
Resultado esperado:
- Created VaultTest.sol with 8 test functions
- Tests include: testInitialBalance, testDeposit, testWithdraw, testFailWithdrawMoreThanDeposit, testFuzzDepositAmount, testMultipleUsers, testVaultBalanceTracking, testEmergencyWithdraw
- Coverage: 95% statement coverage across vault functions
- Gas report: Average deposit costs 45000 gas, withdrawal costs 38000 gas
Usando "web3-testing". Set up mainnet forking to test my lending protocol against Aave
Resultado esperado:
- Configured hardhat.config.js with mainnet forking settings
- Created integration test connecting to Aave V2 lending pool at 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9
- Test validates borrowing against collateral at current mainnet rates
- Fork block: 19500000, ETH balance mocked: 100 ETH for test address
Auditoría de seguridad
SeguroStatic analysis flagged 63 patterns across 430 lines, but all findings are false positives. The SKILL.md file is documentation containing code examples in markdown blocks, not executable code. Flagged patterns include standard Hardhat configuration (process.env usage), Solidity import syntax, and blockchain RPC endpoints - all legitimate web3 development practices. No malicious intent detected.
Problemas de riesgo bajo (1)
Factores de riesgo
⚙️ Comandos externos (22)
🌐 Acceso a red (3)
📁 Acceso al sistema de archivos (1)
🔑 Variables de entorno (6)
Puntuación de calidad
Lo que puedes crear
Pruebas de Protocolos DeFi
Prueba contratos de exchange descentralizados con mainnet forking para verificar que los swaps funcionen correctamente con contratos de token reales antes del despliegue.
Validación de Colecciones NFT
Valida la lógica de minting, transferencia y distribución de royalties de NFT con pruebas unitarias integrales y fuzzing para edge cases.
Preparación para Auditoría de Smart Contracts
Genera suites de prueba integrales con alta cobertura antes de enviar contratos para auditoría de seguridad profesional.
Prueba estos prompts
Create a Hardhat test file for my ERC20 token contract. Include tests for deployment, transfer functionality, and balance checking. Use the Token.sol contract at src/Token.sol.
Write a Foundry fuzzing test for my staking contract that validates rewards calculation across different stake amounts and time periods. Use vm.assume to set valid input ranges.
Set up a mainnet fork test that interacts with the real Uniswap V2 router and DAI token. Test swapping 1 ETH for DAI and validate the received amount is within expected slippage.
Create a test that compares gas usage between two implementations of the same contract function. Deploy both versions, execute identical operations, and report the gas difference with recommendations.
Mejores prácticas
- Use fixtures to set up test state and avoid code duplication between tests
- Test both success paths and failure cases including revert conditions
- Run tests with coverage enabled and aim for over 90 percent line coverage
Evitar
- Testing only happy paths without checking edge cases and failure modes
- Hardcoding private keys or RPC URLs directly in test files instead of using environment variables
- Skipping mainnet fork tests for contracts that interact with external DeFi protocols