All skills
wshobson avatar

/web3-testing

@be57c0b
by Seth Hobsonwshobson/agents40k stars
4,281

Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.

Use this Skill: https://skilld.dev/gh/wshobson/agents/web3-testing

This session only. Nothing lands on disk.

referencesdetails.md

≈493 tokens on demand. Your agent reads this file only when SKILL.md points to it.

web3-testing — additional patterns and templates

Gas Optimization Testing

const { expect } = require("chai");

describe("Gas Optimization", function () {
  it("Compare gas usage between implementations", async function () {
    const Implementation1 =
      await ethers.getContractFactory("OptimizedContract");
    const Implementation2 = await ethers.getContractFactory(
      "UnoptimizedContract",
    );

    const contract1 = await Implementation1.deploy();
    const contract2 = await Implementation2.deploy();

    const tx1 = await contract1.doSomething();
    const receipt1 = await tx1.wait();

    const tx2 = await contract2.doSomething();
    const receipt2 = await tx2.wait();

    console.log("Optimized gas:", receipt1.gasUsed.toString());
    console.log("Unoptimized gas:", receipt2.gasUsed.toString());

    expect(receipt1.gasUsed).to.be.lessThan(receipt2.gasUsed);
  });
});

Coverage Reporting

# Generate coverage report
npx hardhat coverage

# Output shows:
# File                | % Stmts | % Branch | % Funcs | % Lines |
# -------------------|---------|----------|---------|---------|
# contracts/Token.sol |   100   |   90     |   100   |   95    |

Contract Verification

// Verify on Etherscan
await hre.run("verify:verify", {
  address: contractAddress,
  constructorArguments: [arg1, arg2],
});
# Or via CLI
npx hardhat verify --network mainnet CONTRACT_ADDRESS "Constructor arg1" "arg2"

CI/CD Integration

# .github/workflows/test.yml
name: Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "16"

      - run: npm install
      - run: npx hardhat compile
      - run: npx hardhat test
      - run: npx hardhat coverage

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v2

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides standard documentation, templates, and best practice configurations for testing Web3 smart contracts using Hardhat and Foundry. No security issues or malicious patterns were identified.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at be57c0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
  • hardhat
  • foundry
  • solidity
  • smart-contracts
  • unit-testing
  • integration-testing
  • ethereum
  • gas-optimization
  • fuzzing
  • mainnet-forking

README badge

README badge for wshobson/agents/web3-testing

Provides comprehensive testing patterns for Solidity smart contracts using Hardhat and Foundry, covering unit tests, integration tests, gas optimization, fuzzing, and mainnet forking. Targets developers validating token contracts, DeFi protocols, or setting up automated test suites with coverage reporting and Etherscan verification.

Generated from the current SKILL.md.

Does this skill cover both Hardhat and Foundry?
Yes. The skill includes setup and testing patterns for both Hardhat (JavaScript/TypeScript) and Foundry (Solidity), so you can choose or use both frameworks in the same project.
Can I test against mainnet contracts?
Yes. The skill covers mainnet forking with both Hardhat and Foundry, allowing you to test against real contract addresses and state at specific block heights.
Does this include fuzzing and property-based testing?
Yes. The Foundry section demonstrates fuzzing tests with the `testFuzz` pattern to validate contract behavior across randomized inputs.
How do I test gas consumption?
Hardhat's gas reporter plugin is configured in the skill and will measure gas used per transaction; you can also assert on specific gas thresholds in individual tests.

Generated from the current SKILL.md. These answers refresh after source changes.