From 574434fede313c8749498389109f49af87302130 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 27 Aug 2024 11:39:13 +0530 Subject: [PATCH] Fix test for batched txs --- src/index.test.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/index.test.ts b/src/index.test.ts index e91ae88..e9268a4 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -48,25 +48,29 @@ const registryTests = () => { let accounts: Account[]; beforeAll(async () => { + // Fund 10 new accounts for the test accounts = await createTestAccounts(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); + for (let i = 0; i < accounts.length; i++) { + await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee); } }); test('All txs get included in a single block.', async () => { + // Send a bond creation tx from each account await Promise.all(accounts.map((account) => registry.createBond({ denom: DENOM, amount: '100000' }, account.getPrivateKey(), fee) )); const laconicClient = await registry.getLaconicClient(accounts[0]); - const bondTx = await laconicClient.searchTx("message.action='/cerc.bond.v1.MsgCreateBond'"); + const bondCreationTxs = await Promise.all(accounts.map(async (account) => { + // Get the bond creation tx for each account + const [tx] = await laconicClient.searchTx(`message.sender='${account.address}' AND message.action='/cerc.bond.v1.MsgCreateBond'`); + return tx; + })); - const expectedBlockHeight = bondTx[0].height; - expect(bondTx.every(tx => tx.height === expectedBlockHeight)).toBe(true); + // Check that all txs are in the same block + const expectedBlockHeight = bondCreationTxs[0].height; + expect(bondCreationTxs.every(tx => tx.height === expectedBlockHeight)).toBe(true); }); }); };