Check all txs are within two blocks in batched txs test
All checks were successful
Lint & Build / lint_and_build (20.x) (pull_request) Successful in 2m0s
Tests / sdk_tests (pull_request) Successful in 22m20s

This commit is contained in:
Prathamesh Musale 2024-08-27 19:27:30 +05:30
parent 6add6d2844
commit f802e1d31c
2 changed files with 8 additions and 11 deletions

View File

@ -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

View File

@ -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);
});
});
};