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