From e29143b1e55848810d456021a3557725aa826499 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 22 Aug 2024 11:40:44 +0530 Subject: [PATCH] Add test to send multiple txs --- src/index.test.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/index.test.ts b/src/index.test.ts index 0d846fc..7a3c1bf 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -43,6 +43,37 @@ const registryTests = () => { expect(type).toBe(DENOM); expect(quantity).toBe('10000'); }); + + test('Get transaction info.', async () => { + const bondAmount = '100000'; + + const accounts = await createAccounts(10); + + for (let i = 0; i < 10; i++) { + const amount = (10 ** (15 - i)).toString(); + const fromAccount = i === 0 ? privateKey : accounts[i - 1].getPrivateKey(); + + await registry.sendCoins({ denom: DENOM, amount, destinationAddress: accounts[i].address }, fromAccount, fee); + } + const bondPromises = accounts.map((account) => + registry.createBond({ denom: DENOM, amount: bondAmount }, account.getPrivateKey(), fee) + ); + + await Promise.all(bondPromises); + }); + + const createAccounts = async (numAccounts: number): Promise => { + const accounts: Account[] = []; + + for (let i = 0; i < numAccounts; i++) { + const mnemonic = Account.generateMnemonic(); + const account = await Account.generateFromMnemonic(mnemonic); + await account.init(); + accounts.push(account); + } + + return accounts; + }; }; describe('Registry', registryTests);