Check all txs are within two blocks in batched txs test
This commit is contained in:
parent
14dd316976
commit
6ed0be38ed
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user