Check all txs are within two blocks in batched txs test

This commit is contained in:
Prathamesh Musale 2024-08-27 19:27:30 +05:30 committed by ashwin
parent e439af3720
commit 36772aca8d
2 changed files with 8 additions and 11 deletions

View File

@ -21,7 +21,6 @@ jobs:
with: with:
path: "./laconicd/" path: "./laconicd/"
repository: cerc-io/laconicd repository: cerc-io/laconicd
github-server-url: 'https://git.vdb.to'
fetch-depth: 0 fetch-depth: 0
ref: main ref: main
- name: Environment - name: Environment

View File

@ -53,30 +53,28 @@ const registryTests = () => {
for (let i = 0; i < accounts.length; i++) { for (let i = 0; i < accounts.length; i++) {
await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee); 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 // Send a bond creation tx from each account
await Promise.all(accounts.map((account) => await Promise.all(accounts.map((account) =>
registry.createBond({ denom: DENOM, amount: '100000' }, account.getPrivateKey(), fee) registry.createBond({ denom: DENOM, amount: '100000' }, account.getPrivateKey(), fee)
)); ));
const laconicClient = await registry.getLaconicClient(accounts[0]); 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 // Get the bond creation tx for each account
const [tx] = await laconicClient.searchTx(`message.sender='${account.address}' AND message.action='/cerc.bond.v1.MsgCreateBond'`); 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) => { bondCreationTxHeights.forEach((txHeight, i) => {
console.log('tx', accounts[i].address, tx.height); console.log('tx', accounts[i].address, txHeight);
}); });
// Check that all txs are in the same block // Check that all txs are within two blocks
const expectedBlockHeight = bondCreationTxs[0].height; const expectedBlockHeight = bondCreationTxHeights.sort()[0];
expect(bondCreationTxs.every(tx => tx.height === expectedBlockHeight)).toBe(true); expect(bondCreationTxHeights.every(txHeight => txHeight === expectedBlockHeight || txHeight === expectedBlockHeight + 1)).toBe(true);
}); });
}); });
}; };