Skip to content

Commit

Permalink
fix queries tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 17, 2024
1 parent d331926 commit 31bcca6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 23 deletions.
20 changes: 20 additions & 0 deletions contracts/checksums.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/helpers/interchainqueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down
37 changes: 20 additions & 17 deletions src/testcases/run_in_band/interchain_kv_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,15 @@ describe('Neutron / Interchain KV Query', () => {
});

test('register icq #7: balance', async () => {
await registerBalancesQuery(
const queryId = await registerBalancesQuery(
neutronClient,
contractAddress,
connectionId,
1_000_000,
[COSMOS_DENOM],
testState.wallets.cosmos.val1.address,
);
console.log('queryId: ' + queryId)

Check failure on line 364 in src/testcases/run_in_band/interchain_kv_query.test.ts

View workflow job for this annotation

GitHub Actions / Actions - lint

Insert `;`
});
});
});
Expand All @@ -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');
Expand All @@ -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(),
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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');
Expand All @@ -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;
Expand All @@ -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++) {
Expand All @@ -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,
);
});

Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
5 changes: 2 additions & 3 deletions src/testcases/run_in_band/interchain_tx_query_plain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/interchaintx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 31bcca6

Please sign in to comment.