-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create TestCoin feat: add TestCoin helper class (#3445) #3460
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for the contribution! Before we can merge this, we need @crStiv to sign the Fuel Labs Contributor License Agreement. |
@crStiv is attempting to deploy a commit to the Fuel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Hey @crStiv i think the file is missing an extension ( |
hey, I redid this, is it good? |
@Dhaiwat10 so what do you say |
TestCoin
Outdated
@@ -0,0 +1,24 @@ | |||
import { Coin } from '../types'; | |||
import { randomBytes } from 'crypto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { randomBytes } from 'crypto'; | |
import { randomBytes } from '@fuel-ts/crypto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This is at the root of the project. Move to a more appropriate location like
packages/account/src/test-utils
. - Add tests so we can validate the functionality.
- The
Coin
should reference the followingCoin
type.
id: params.id || `0x${randomBytes(32).toString('hex')}`, | ||
owner: params.owner || `0x${randomBytes(32).toString('hex')}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id: params.id || `0x${randomBytes(32).toString('hex')}`, | |
owner: params.owner || `0x${randomBytes(32).toString('hex')}`, | |
id: params.id || getRandomB256(), | |
owner: params.owner || getRandomB256(), |
Favour helper functions
return { | ||
id: params.id || `0x${randomBytes(32).toString('hex')}`, | ||
owner: params.owner || `0x${randomBytes(32).toString('hex')}`, | ||
amount: params.amount || BigInt(1000000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount: params.amount || BigInt(1000000), | |
amount: params.amount || bn(1000000), |
Amount is a BN
Release Notes
In this release, we:
TestCoin
helper class to simplify the creation of testCoin
objects for testing purposes.TestCoin.create
: Generates a single test coin with customizable parameters.TestCoin.many
: Generates an array of test coins based on shared parameters.Summary
This pull request introduces the
TestCoin
helper class, designed to streamline the creation of testCoin
objects. Thecreate
method allows for the generation of a single coin with default or customized properties, while themany
method supports bulk creation of coins. These utilities will improve the efficiency and readability of tests that rely onCoin
objects.Related Issues
TestCoin
helper class #3445Breaking Changes
None.
Checklist
Allow edits by maintainers.