From 31bcca6f7f23cf260f81eaf82b387ebd6f987006 Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 17 Oct 2024 18:47:43 +0400 Subject: [PATCH] fix queries tests --- contracts/checksums.txt | 20 ++++++++++ src/helpers/interchainqueries.ts | 4 +- .../run_in_band/interchain_kv_query.test.ts | 37 ++++++++++--------- .../interchain_tx_query_plain.test.ts | 5 +-- .../run_in_band/interchaintx.test.ts | 2 +- 5 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 contracts/checksums.txt diff --git a/contracts/checksums.txt b/contracts/checksums.txt new file mode 100644 index 00000000..8f256649 --- /dev/null +++ b/contracts/checksums.txt @@ -0,0 +1,20 @@ +e8fadf731d66a9295f8e4384588ee45af3aaea4707ea189a95abcf826566e548 balance_tracker.wasm +7bdd09183de66e9a6b8bd2c3f77b79f82570349218011673ba2168c3482f8335 before_send_hook_test.wasm +c34cc1f7f0194cdadb8d84f798f6fce79704cb04ffcc00f73fc86f5b16dbea70 client_updater.wasm +c7ee546ea9f92051ff1268060ff2e8e8b6757e1b16d0d9c436f2bcc20d5868e2 cron.wasm +3f0f7d45beaaa279ee0298a3d2bcb79c8643ef2cd4476c8d627ed85451ae9a49 dex.wasm +e82b50516b84e0b1079beffdde442aabe91992e632a4abfa28187328cfb6cb73 dex_grpc.wasm +c1d20c14173393e4d9af066e53ec3b967c8a206f5898adb44fdec413c7696443 dex_stargate.wasm +938556c5fbe9a2b4665d1adf6a96321f9a6ba27892b4f3da9778d0f279bac049 echo.wasm +7281dc6277e509b26ecfaed701d023b83d8252dd7d6042f4e6e1f02402fe0763 grpc_querier.wasm +18cdb6abaaf7d3375bfb8f184170e48630cd88073dc31c7439bfe28ace565e6c ibc_transfer.wasm +32c836cd83189f2563af52a9b2a8b7c6edfba2f148f14476a26623f2cc79c516 marketmap.wasm +fac2caf5e686ce41276a0284f3b40d4a4e5d083129302e9ad739cb1a7149502b msg_receiver.wasm +f979a5551544e866e8c4bbd447bbd73c017f1378bf7b79d39a5560e4a1e5ad41 neutron_interchain_queries.wasm +344a19f427a91b6a8892fd4abe355286f0c823c6e24925d0ab3c2d4318d2db34 neutron_interchain_txs.wasm +6177cc38d0e39be00876e1bb2fc84a4306901cd8840745488d54536fdf8ff918 neutron_price_feed_mock.wasm +fcab32643775a7e71596e23f6fc802406c3d12ebae8f24ebe2a49337de4e51c8 neutron_validators_test.wasm +0edf7ee326f63e9cfcbad9dca0bfead821010c0fbe4e5efe624cd8efe27dab67 oracle.wasm +210ce0b80133f326c0518376e6c660b4f935c258a9116e77370d1a71cd46a594 reflect.wasm +918aec79baa39d99bbe174f96cf4d15357ebdb1ceba9592ded25612bce557386 stargate_querier.wasm +aa23a731631b03355ea5642cd48df7ba0428a20061f8c5c12feb7eef9acb566c tokenfactory.wasm diff --git a/src/helpers/interchainqueries.ts b/src/helpers/interchainqueries.ts index 1fdddff5..51bc596f 100644 --- a/src/helpers/interchainqueries.ts +++ b/src/helpers/interchainqueries.ts @@ -547,8 +547,8 @@ export const waitForICQResultWithRemoteHeight = ( client, () => getRegisteredQuery(client, contractAddress, queryId), async (query) => - query.last_submitted_result_remote_height - .revision_height >= targetHeight, + +query.last_submitted_result_remote_height.revision_height >= + targetHeight, numAttempts, ); diff --git a/src/testcases/run_in_band/interchain_kv_query.test.ts b/src/testcases/run_in_band/interchain_kv_query.test.ts index a7b62b15..d54abf6b 100644 --- a/src/testcases/run_in_band/interchain_kv_query.test.ts +++ b/src/testcases/run_in_band/interchain_kv_query.test.ts @@ -353,7 +353,7 @@ describe('Neutron / Interchain KV Query', () => { }); test('register icq #7: balance', async () => { - await registerBalancesQuery( + const queryId = await registerBalancesQuery( neutronClient, contractAddress, connectionId, @@ -361,6 +361,7 @@ describe('Neutron / Interchain KV Query', () => { [COSMOS_DENOM], testState.wallets.cosmos.val1.address, ); + console.log('queryId: ' + queryId) }); }); }); @@ -373,7 +374,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); expect(queryResult.keys.length).toEqual(1); expect(queryResult.keys[0].path).toEqual('bank'); @@ -394,7 +395,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.keys.length).toEqual(1); expect(queryResult.update_period).toEqual( updatePeriods[queryId].toString(), @@ -408,7 +409,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); // we expect three keys, 1 always + 2 per validator expect(queryResult.keys.length).toEqual(3); @@ -417,7 +418,8 @@ describe('Neutron / Interchain KV Query', () => { expect(queryResult.connection_id).toEqual(connectionId); expect(queryResult.update_period).toEqual( updatePeriods[queryId].toString(), - ); }); + ); + }); test('get registered icq #5: multiple balances', async () => { const queryId = 5; @@ -426,7 +428,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); expect(queryResult.keys.length).toEqual(2); expect(queryResult.keys[0].path).toEqual('bank'); @@ -438,7 +440,8 @@ describe('Neutron / Interchain KV Query', () => { expect(queryResult.connection_id).toEqual(connectionId); expect(queryResult.update_period).toEqual( updatePeriods[queryId].toString(), - ); }); + ); + }); test('get registered icq #6: 100 keys', async () => { const queryId = 6; @@ -447,7 +450,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); expect(queryResult.keys.length).toEqual(100); for (let i = 0; i < queryResult.keys.length; i++) { @@ -471,9 +474,9 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect(queryResult.last_submitted_result_local_height).greaterThan(0); - expect(queryResult.last_submitted_result_local_height).lessThan( - queryResult.update_period, + expect(+queryResult.last_submitted_result_local_height).greaterThan(0); + expect(+queryResult.last_submitted_result_local_height).lessThan( + +queryResult.update_period, ); }); @@ -840,8 +843,8 @@ describe('Neutron / Interchain KV Query', () => { await neutronClient.getWithAttempts( () => getRegisteredQuery(neutronClient, contractAddress, queryId), async (response) => - response.last_submitted_result_local_height > 0 && - response.last_submitted_result_local_height + 5 < + +response.last_submitted_result_local_height > 0 && + +response.last_submitted_result_local_height + 5 < (await neutronClient.getHeight()), 20, ); @@ -959,7 +962,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans @@ -1040,7 +1043,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans @@ -1146,7 +1149,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); expect(queryResult.keys.length).toEqual(1); expect(queryResult.keys[0].path).toEqual('slashing'); @@ -1230,7 +1233,7 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.id).toEqual(queryId); + expect(queryResult.id).toEqual(queryId.toString()); expect(queryResult.owner).toEqual(contractAddress); expect(queryResult.keys.length).toEqual(1); expect(queryResult.keys[0].path).toEqual('staking'); diff --git a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts index 4e1918b7..923ee031 100644 --- a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts +++ b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts @@ -460,9 +460,6 @@ describe('Neutron / Interchain TX Query', () => { }); let deposits = await depositsPromise; // update time hasn't come yet despite the fact that sent funds are already on the account - console.log( - 'deposits.transfers: \n' + JSON.stringify(deposits.transfers), - ); expect(deposits.transfers).toEqual([ { recipient: watchedAddr3, @@ -927,11 +924,13 @@ describe('Neutron / Interchain TX Query', () => { describe('update recipient and check', () => { const newWatchedAddr5 = 'cosmos1jy7lsk5pk38zjfnn6nt6qlaphy9uejn4hu65xa'; it('should update recipient', async () => { + const query = await getRegisteredQuery(neutronClient, contractAddress, 3); const res = await neutronClient.execute(contractAddress, { update_interchain_query: { query_id: 3, new_update_period: query3UpdatePeriod, new_recipient: newWatchedAddr5, + new_keys: query.keys, }, }); expect(res.code).toEqual(0); diff --git a/src/testcases/run_in_band/interchaintx.test.ts b/src/testcases/run_in_band/interchaintx.test.ts index 59543e3b..120025cd 100644 --- a/src/testcases/run_in_band/interchaintx.test.ts +++ b/src/testcases/run_in_band/interchaintx.test.ts @@ -132,7 +132,7 @@ describe('Neutron / Interchain TXs', () => { register: { connection_id: connectionId, interchain_account_id: unorderedIcaId, - ordering: 'ORDER_UNORDERED', + ordering: 'Unordered', }, }); expect(res.code).toEqual(0);