From 6ed0be38ed15f7f6b6de324129c7ddaa3ebfe23c Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 27 Aug 2024 19:27:30 +0530 Subject: [PATCH] Check all txs are within two blocks in batched txs test --- .gitea/workflows/test.yml | 1 - src/index.test.ts | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index b2a481c..032359e 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -21,7 +21,6 @@ jobs: with: path: "./laconicd/" repository: cerc-io/laconicd - github-server-url: 'https://git.vdb.to' fetch-depth: 0 ref: main - name: Environment diff --git a/src/index.test.ts b/src/index.test.ts index 85902d2..9625147 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -53,30 +53,28 @@ const registryTests = () => { for (let i = 0; i < accounts.length; i++) { await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee); } - - console.log('accounts', accounts); }); - test('All txs get included in a single block.', async () => { + test('Multiple txs get included in a 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 bondCreationTxs = await Promise.all(accounts.map(async (account) => { + const bondCreationTxHeights = 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; + return tx.height; })); - bondCreationTxs.forEach((tx, i) => { - console.log('tx', accounts[i].address, tx.height); + bondCreationTxHeights.forEach((txHeight, i) => { + console.log('tx', accounts[i].address, txHeight); }); - // Check that all txs are in the same block - const expectedBlockHeight = bondCreationTxs[0].height; - expect(bondCreationTxs.every(tx => tx.height === expectedBlockHeight)).toBe(true); + // Check that all txs are within two blocks + const expectedBlockHeight = bondCreationTxHeights.sort()[0]; + expect(bondCreationTxHeights.every(txHeight => txHeight === expectedBlockHeight || txHeight === expectedBlockHeight + 1)).toBe(true); }); }); };