forked from cerc-io/registry-sdk
Fix test for batched txs
This commit is contained in:
parent
2222276c73
commit
06adca6e81
@ -48,25 +48,29 @@ const registryTests = () => {
|
|||||||
let accounts: Account[];
|
let accounts: Account[];
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
// Fund 10 new accounts for the test
|
||||||
accounts = await createTestAccounts(10);
|
accounts = await createTestAccounts(10);
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < accounts.length; i++) {
|
||||||
const amount = (10 ** (15 - i)).toString();
|
await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee);
|
||||||
const fromAccount = i === 0 ? privateKey : accounts[i - 1].getPrivateKey();
|
|
||||||
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount, destinationAddress: accounts[i].address }, fromAccount, fee);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('All txs get included in a single block.', async () => {
|
test('All txs get included in a single block.', async () => {
|
||||||
|
// 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 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;
|
// Check that all txs are in the same block
|
||||||
expect(bondTx.every(tx => tx.height === expectedBlockHeight)).toBe(true);
|
const expectedBlockHeight = bondCreationTxs[0].height;
|
||||||
|
expect(bondCreationTxs.every(tx => tx.height === expectedBlockHeight)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user