Skip to content

feat: add TestCoin helper class#3963

Open
airope wants to merge 1 commit intoFuelLabs:masterfrom
airope:feat/test-coin-helper
Open

feat: add TestCoin helper class#3963
airope wants to merge 1 commit intoFuelLabs:masterfrom
airope:feat/test-coin-helper

Conversation

@airope
Copy link

@airope airope commented Mar 4, 2026

Summary

Adds a TestCoin helper class, similar to the existing TestMessage class, for creating coins in tests.

Closes #3445

Changes

  • packages/account/src/test-utils/test-coin.ts — New TestCoin class with:
    • Constructor with sensible defaults (random owner, 1M amount, base asset ID)
    • toChainCoin() method to convert to chain snapshot format
    • Static many() method to generate multiple test coins at once
  • packages/account/src/test-utils/test-coin.test.ts — Unit tests covering defaults, custom values, owner override, and many()
  • packages/account/src/test-utils.ts — Re-export TestCoin

Usage

import { TestCoin } from @fuel-ts/account/test-utils;

// Single coin with defaults
const coin = new TestCoin();

// Multiple coins for a specific owner
const coins = TestCoin.many({ owner: myAddress }, 4);

// Convert to chain format for snapshot configs
const chainCoin = coin.toChainCoin();

@cursor
Copy link

cursor bot commented Mar 4, 2026

PR Summary

Low Risk
Low risk: adds a new test-only helper and unit tests, with minimal surface-area change beyond a new export.

Overview
Adds a new TestCoin test utility for building coin entries used in genesis/snapshot configs, including defaults, custom overrides, and a many() factory plus toChainCoin() conversion.

Exports TestCoin from packages/account/src/test-utils.ts and adds a dedicated test suite validating default fields, overrides (including owner override), and multi-coin generation behavior.

Written by Cursor Bugbot for commit 8ce82c6. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added the feat Issue is a feature label Mar 4, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@airope airope force-pushed the feat/test-coin-helper branch from 4389cf3 to 8ce82c6 Compare March 4, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:signed feat Issue is a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TestCoin helper class

1 participant