Update config tests to use a single account
All checks were successful
Lint & Build / lint_and_build (20.x) (pull_request) Successful in 1m52s
Tests / sdk_tests (pull_request) Successful in 22m3s

This commit is contained in:
Prathamesh Musale 2024-09-05 11:20:50 +05:30
parent f802e1d31c
commit 8828b5388d
2 changed files with 9 additions and 17 deletions

View File

@ -11,20 +11,17 @@ jest.setTimeout(90 * 1000);
const configTests = () => {
let registry: Registry;
let accounts: Account[];
let testAccount: Account;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
// Fund 4 new accounts for the test
accounts = await createTestAccounts(4);
for (let i = 0; i < accounts.length; i++) {
await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee);
}
// Fund a new account for the test
[testAccount] = await createTestAccounts(1);
await registry.sendCoins({ denom: DENOM, amount: '10000000', destinationAddress: testAccount.address }, privateKey, fee);
});
test('StdFee fees with gas price not set', async () => {
const testAccount = accounts[0];
const testFees = {
amount: [{ denom: 'alnt', amount: '400000' }],
gas: '400000'
@ -39,7 +36,6 @@ const configTests = () => {
});
test('StdFee fees with gas price set', async () => {
const testAccount = accounts[0];
const testFees = {
amount: [{ denom: 'alnt', amount: '400000' }],
gas: '400000'
@ -58,8 +54,6 @@ const configTests = () => {
});
test('Gas price with fees not set (default gas estimation multiplier)', async () => {
const testAccount = accounts[1];
// Set gas price
const testGasPrice = GasPrice.fromString('1alnt');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
@ -69,11 +63,10 @@ const configTests = () => {
// Check that bond gets created (gas price ignored)
const [result] = await registry.queryBondsByOwner([testAccount.address]);
expect(result.bonds).toHaveLength(1);
expect(result.bonds).toHaveLength(3);
});
test('Gas price with fees set (fees as the gas estimation multiplier)', async () => {
const testAccount = accounts[2];
const testFees = 2.1;
// Set gas price
@ -85,11 +78,10 @@ const configTests = () => {
// Check that bond gets created (gas price ignored)
const [result] = await registry.queryBondsByOwner([testAccount.address]);
expect(result.bonds).toHaveLength(1);
expect(result.bonds).toHaveLength(4);
});
test('Error on fees and gas price both not set', async () => {
const testAccount = accounts[3];
const errorMsg = 'Gas price must be set in the client options when auto gas is used';
// Create registry without gasPrice
@ -104,7 +96,7 @@ const configTests = () => {
// Check that bond doesn't get created
const [result] = await registry.queryBondsByOwner([testAccount.address]);
expect(result.bonds).toHaveLength(0);
expect(result.bonds).toHaveLength(4);
});
};

View File

@ -48,7 +48,7 @@ const registryTests = () => {
let accounts: Account[];
beforeAll(async () => {
// Fund 10 new accounts for the test
// Fund 5 new accounts for the test
accounts = await createTestAccounts(5);
for (let i = 0; i < accounts.length; i++) {
await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee);
@ -56,7 +56,7 @@ const registryTests = () => {
});
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 (send from different accounts to avoid sequence errors)
await Promise.all(accounts.map((account) =>
registry.createBond({ denom: DENOM, amount: '100000' }, account.getPrivateKey(), fee)
));