Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(account): Add TestCoin helper class for testing purposes #3647

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/account/src/test-utils/test-coin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Coin } from '@fuel-ts/account';
import { bn } from '@fuel-ts/math';
import { getRandomB256 } from '@fuel-ts/crypto';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { getRandomB256 } from '@fuel-ts/crypto';
import { getRandomB256 } from '@fuel-ts/address';


export class TestCoin {
/**
* Creates a single test coin with given parameters
*/
static create(params: Partial<Coin> = {}): Coin {
return {
id: params.id || getRandomB256(),
owner: params.owner || getRandomB256(),
amount: params.amount || bn(1000000),
type: params.type || 0,
...params
};
}

/**
* Generates an array of test coins with the same base parameters
*/
static many(params: Partial<Coin> = {}, count = 1): Coin[] {
return Array.from({ length: count }, () => TestCoin.create(params));
}
}