diff --git a/src/testcases/parallel/icq_howto_register_custom_kv_icq.test.ts b/src/testcases/parallel/icq_howto_register_custom_kv_icq.test.ts index b5e60901..c3acb14e 100644 --- a/src/testcases/parallel/icq_howto_register_custom_kv_icq.test.ts +++ b/src/testcases/parallel/icq_howto_register_custom_kv_icq.test.ts @@ -11,7 +11,8 @@ import { } from '../../helpers/constants'; import { GasPrice } from '@cosmjs/stargate/build/fee'; import { SigningNeutronClient } from '../../helpers/signing_neutron_client'; -import { waitBlocks } from '@neutron-org/neutronjsplus/dist/wait'; +import { getWithAttempts } from '@neutron-org/neutronjsplus/dist/wait'; +import { BaseAccount } from '@neutron-org/neutronjs/src/cosmos/auth/v1beta1/auth'; // just a fresh test-specific address. don't use it in other parallel test cases to avoid races const WATCHED_GAIA_ADDR = 'cosmos1yfhvt7uje9ztwr9mk6xnkg0thf83r2d53w38ja'; @@ -20,7 +21,7 @@ const CONNECTION_ID = 'connection-0'; const ICQ_UPDATE_PERIOD = 5; describe( - 'Neutron / docs / interchainqueries / howto / register KV ICQ', + 'Neutron / docs / interchainqueries / howto / register KV ICQ with custom keys', {}, () => { let testState: LocalState; @@ -114,15 +115,17 @@ describe( }); test('check ICQ submitted value result', async () => { - await waitBlocks(ICQ_UPDATE_PERIOD, neutronClient); - - const queryResult = await neutronClient.queryContractSmart( - contractAddress, - { account: { address: WATCHED_GAIA_ADDR } }, + await getWithAttempts( + neutronClient, + async (): Promise => + await neutronClient.queryContractSmart(contractAddress, { + account: { address: WATCHED_GAIA_ADDR }, + }), + async (response) => + response.address == WATCHED_GAIA_ADDR && + response.sequence == BigInt(0) && + response.accountNumber != BigInt(0), ); - expect(queryResult.address).toEqual(WATCHED_GAIA_ADDR); - expect(+queryResult.sequence).toEqual(0); - expect(+queryResult.account_number).not.toEqual(0); }); }); }, diff --git a/src/testcases/parallel/icq_howto_register_kv_icq.test.ts b/src/testcases/parallel/icq_howto_register_kv_icq.test.ts index 9f5e2247..af36bbbf 100644 --- a/src/testcases/parallel/icq_howto_register_kv_icq.test.ts +++ b/src/testcases/parallel/icq_howto_register_kv_icq.test.ts @@ -1,7 +1,7 @@ import config from '../../config.json'; import { inject, RunnerTestSuite } from 'vitest'; import { LocalState } from '../../helpers/local_state'; -import { Registry } from '@cosmjs/proto-signing'; +import { Registry, Coin } from '@cosmjs/proto-signing'; import { Wallet } from '../../helpers/wallet'; import { defaultRegistryTypes, SigningStargateClient } from '@cosmjs/stargate'; import { @@ -11,7 +11,7 @@ import { } from '../../helpers/constants'; import { GasPrice } from '@cosmjs/stargate/build/fee'; import { SigningNeutronClient } from '../../helpers/signing_neutron_client'; -import { waitBlocks } from '@neutron-org/neutronjsplus/dist/wait'; +import { getWithAttempts } from '@neutron-org/neutronjsplus/dist/wait'; // just a fresh test-specific address. don't use it in other parallel test cases to avoid races const WATCHED_GAIA_ADDR = 'cosmos1gdzru2fzdn7czxn89phu9ergn7v8c7zpladz6f'; @@ -114,20 +114,18 @@ describe( }); test('check ICQ submitted value result', async () => { - await waitBlocks(ICQ_UPDATE_PERIOD, neutronClient); - - const queryResult = await neutronClient.queryContractSmart( - contractAddress, - { balances: { address: WATCHED_GAIA_ADDR } }, + await getWithAttempts( + neutronClient, + async (): Promise<{ coins: Coin[] }> => + await neutronClient.queryContractSmart(contractAddress, { + balances: { address: WATCHED_GAIA_ADDR }, + }), + async (response) => + response.coins.length == 1 && + response.coins[0].amount == + WATCHED_GAIA_ADDR_BALANCE_UATOM.toString() && + response.coins[0].denom == COSMOS_DENOM, ); - expect(queryResult).toEqual({ - coins: [ - { - denom: COSMOS_DENOM, - amount: WATCHED_GAIA_ADDR_BALANCE_UATOM.toString(), - }, - ], - }); }); }); },