Skip to content

Commit

Permalink
Update test-coin.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
crStiv authored Jan 30, 2025
1 parent f7f0f0a commit 34bee1a
Showing 1 changed file with 25 additions and 0 deletions.
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';

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));
}
}

0 comments on commit 34bee1a

Please sign in to comment.