foundry-test-formatting

Format wei values into readable ether strings in Foundry unit tests.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/phpmac/skills --skill foundry-test-formatting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundry-test-formatting
Source: https://github.com/phpmac/skills/tree/main/plugins/my-agents/skills/foundry-test-formatting
Command: npx skills add https://github.com/phpmac/skills --skill foundry-test-formatting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Foundry unit tests often print raw uint values (wei) which are hard to read. This skill provides formatting helpers to render numbers as human-friendly ether values and to organize logs for easier debugging.

Core Features & Use Cases

  • _formatEther converts wei to readable ether strings.
  • _logStage prints stage separators for test steps.
  • _logLine shows before/after values and deltas in a concise format.
  • _trimTrailingZeros and _toStringPadded improve numeric string representations.
  • Demonstrates use cases like displaying balances, prices, and token amounts in tests.

Quick Start

Import the formatting helpers into your Foundry test and start producing readable ether values and stage logs with _formatEther, _trimTrailingZeros, and _logLine.

Frequently Asked Questions about foundry-test-formatting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format wei values into readable ether strings in Foundry tests?

To format wei values into readable ether strings in Foundry tests, use helpers like _formatEther and _trimTrailingZeros. These convert raw uint values into human-friendly ether representations, making logged balances and token amounts easier to read during debugging.

Why do my Foundry test logs show raw wei numbers instead of ether values?

Foundry test logs display raw wei numbers because native console logging prints uint values directly. Formatting helpers like _formatEther and _toStringPadded convert these raw wei figures into readable ether strings, improving log clarity for balances, prices, and token amounts.

Can I track balance changes and deltas across Foundry test steps?

Yes, you can track balance changes and deltas across Foundry test steps using the _logLine helper. It displays before and after values alongside their calculated deltas, while _logStage prints separators to organize test steps for clearer debugging output.

Does this Foundry test formatting skill work with forge-std Test and vm logging?

Yes, this Foundry test formatting skill works with forge-std Test and vm logging. It relies on these standard components alongside console output to implement helpers like _formatEther, _logLine, and _logStage for rendering readable numeric values in unit tests.

What is the best way to organize Foundry test logs for stage-based debugging?

The best way to organize Foundry test logs for stage-based debugging is using the _logStage helper. It prints stage separators across test steps, while _logLine concisely displays before and after values with deltas, creating structured and readable test output.

How do I remove trailing zeros from numeric strings in Solidity test outputs?

To remove trailing zeros from numeric strings in Solidity test outputs, use the _trimTrailingZeros helper. It improves numeric string representations by cleaning up formatted ether values, ensuring logged balances and token amounts display without unnecessary decimal zeros.