Add `TestCoin` helper class
Similar to the TestMessage helper class, it might be worth having one for coins as well.
We could have a static many function which could generate multiple coins.
const coins: Coin[] = TestCoin.many({
owner: '0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db'
}, 4);
May I try to solve this Issue?
Hey @crStiv 👋🏼
Go ahead - let us know if you need anything :)
import { Coin } from '../types'; import { randomBytes } from 'crypto';
export class TestCoin { /**
- Creates a single test coin with given parameters */ static create(params: Partial<Coin> = {}): Coin { return { id: randomBytes(32).toString('hex'), owner: randomBytes(32).toString('hex'), amount: '1000000000000000000', // 1 ETH by default ...params }; }
/**
- Generates an array of test coins
- @param params - Parameters for all generated coins
- @param count - Number of coins to generate */ static many(params: Partial<Coin> = {}, count: number): Coin[] { return Array.from({ length: count }, () => TestCoin.create(params)); } }
does this one helps in any shape or form, or did I go into the wrong direction?
@crStiv feel free to open a draft PR with this implementation. It is easier for the team to review and collaborate