From 5b14abe08928ef63c1fe630b3fabc3113684cef3 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 17:58:38 +0400 Subject: [PATCH 1/9] remove dex_bindings test --- package.json | 3 +- .../run_in_band/dex_bindings.test.ts | 658 ------------------ src/testcases/run_in_band/slinky.test.ts | 22 +- .../run_in_band/tokenfactory.test.ts | 2 +- 4 files changed, 5 insertions(+), 680 deletions(-) delete mode 100644 src/testcases/run_in_band/dex_bindings.test.ts diff --git a/package.json b/package.json index b1d32728..cfcd20fa 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "yarn test:parallel && yarn test:run_in_band", "test:parallel": "vitest --run src/testcases/parallel --bail 1 --reporter=basic", - "test:run_in_band": "yarn test:feemarket && yarn test:globalfee && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory && yarn test:cron && yarn test:dex_grpc && yarn test:dex_bindings", + "test:run_in_band": "yarn test:feemarket && yarn test:globalfee && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory && yarn test:cron && yarn test:dex_grpc", "test:ibc_transfer": "vitest --run src/testcases/parallel/ibc_transfer --bail 1", "test:slinky": "vitest --run src/testcases/run_in_band/slinky --bail 1", "test:cron": "vitest --run src/testcases/run_in_band/cron --bail 1", @@ -28,7 +28,6 @@ "test:voting_registry": "vitest --run src/testcases/parallel/voting_registry --bail 1", "test:float": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/float --bail 1", "test:dex_grpc": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_grpc --bail 1", - "test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_bindings --bail 1", "test:chain_manager": "vitest --run src/testcases/run_in_band/chain_manager --bail 1", "test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/feemarket --bail 1", "test:ibc_rate_limit": "vitest --run src/testcases/run_in_band/ibc_rate_limit --bail 1", diff --git a/src/testcases/run_in_band/dex_bindings.test.ts b/src/testcases/run_in_band/dex_bindings.test.ts deleted file mode 100644 index 55eb055c..00000000 --- a/src/testcases/run_in_band/dex_bindings.test.ts +++ /dev/null @@ -1,658 +0,0 @@ -import { inject } from 'vitest'; -import { NEUTRON_DENOM } from '@neutron-org/neutronjsplus/dist/constants'; -import { LocalState } from '../../helpers/local_state'; -import { - MsgCreateDenom, - MsgMint, -} from '@neutron-org/neutronjs/osmosis/tokenfactory/v1beta1/tx'; -import { SigningNeutronClient } from '../../helpers/signing_neutron_client'; -import { Wallet } from '../../helpers/wallet'; -import { CONTRACTS } from '../../helpers/constants'; -import { - getEventAttribute, - getEventAttributesFromTx, -} from '@neutron-org/neutronjsplus/dist/cosmos'; -import config from '../../config.json'; - -describe('Neutron / dex module bindings', () => { - let testState: LocalState; - let neutronClient: SigningNeutronClient; - let neutronWallet: Wallet; - let contractAddress: string; - let activeTrancheKey: string; - let inactiveTrancheKey: string; - const multiHopSwapDenoms: any[] = []; - - beforeAll(async () => { - testState = await LocalState.create(config, inject('mnemonics')); - neutronWallet = testState.wallets.neutron.demo1; - neutronClient = await SigningNeutronClient.connectWithSigner( - testState.rpcNeutron, - neutronWallet.directwallet, - neutronWallet.address, - ); - }); - - describe('Instantiate dex binding contract', () => { - test('instantiate contract', async () => { - contractAddress = await neutronClient.create(CONTRACTS.DEX_DEV, {}); - }); - test('send funds', async () => { - await neutronClient.sendTokens( - contractAddress, - [{ denom: NEUTRON_DENOM, amount: '100000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - - await neutronClient.sendTokens( - contractAddress, - [{ denom: 'uibcusdc', amount: '100000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - }); - }); - - describe('DEX messages', () => { - describe('Deposit', () => { - test('Invalid pair', async () => { - await expect( - neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'untrn', - amounts_a: ['100'], // uint128 - amounts_b: ['100'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }), - ).rejects.toThrowError( - /failed to execute \*types.MsgDeposit: failed to validate MsgDeposit: tokenA cannot equal tokenB: Invalid token denom/, - ); - }); - test('Valid pair', async () => { - // pool denom - 'neutron/pool/0' - const res = await neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'uibcusdc', - amounts_a: ['1000'], // uint128 - amounts_b: ['1000'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('Withdrawal', () => { - test('valid', async () => { - // pool denom - 'neutron/pool/0' - const res = await neutronClient.execute(contractAddress, { - withdrawal: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'uibcusdc', - shares_to_remove: ['10'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('LimitOrder', () => { - test('GOOD_TIL_CANCELLED', async () => { - // Place order deep in orderbook. Doesn't change existing liquidity - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.221390545', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res.code).toEqual(0); - }); - test('FILL_OR_KILL', async () => { - // Trades through some of LP position at tick 1 - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - limit_sell_price: '0.74', - tick_index_in_to_out: 0, - amount_in: '100', - order_type: 'FILL_OR_KILL', - max_amount_out: '100', - }, - }); - expect(res.code).toEqual(0); - }); - test('IMMEDIATE_OR_CANCEL', async () => { - // Trades through remainder of LP position at tick 1 - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.98', - amount_in: '1000000', - order_type: 'IMMEDIATE_OR_CANCEL', - }, - }); - expect(res.code).toEqual(0); - }); - test('JUST_IN_TIME', async () => { - // Place JIT deep in orderbook - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '7.38', - amount_in: '1000000', - order_type: 'JUST_IN_TIME', - }, - }); - expect(res.code).toEqual(0); - }); - test('GOOD_TIL_TIME', async () => { - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.002', - amount_in: '10000000', - expiration_time: Math.ceil(Date.now() / 1000) + 1000, - order_type: 'GOOD_TIL_TIME', - }, - }); - expect(res.code).toEqual(0); - }); - test('GOOD_TIL_TIME expired', async () => { - await expect( - neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.998', - amount_in: '10000000', - expiration_time: 1, - order_type: 'GOOD_TIL_TIME', - }, - }), - ).rejects.toThrowError( - /Limit order expiration time must be greater than current block time/, - ); - }); - test('unknown order type', async () => { - await expect( - neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.0001', - amount_in: '10', - expiration_time: 1, - order_type: 'unknown', - }, - }), - ).rejects.toThrowError( - /unknown variant `unknown`, expected one of `GOOD_TIL_CANCELLED`, `FILL_OR_KILL`, `IMMEDIATE_OR_CANCEL`, `JUST_IN_TIME`, `GOOD_TIL_TIME`/, - ); - }); - test('limit_sell_price scientific notation', async () => { - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.4564654E-4', - amount_in: '100000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('Withdraw filled LO', () => { - test('Withdraw', async () => { - // place GTC LO at top of orderbook - const res1 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.8188125757', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res1.code).toEqual(0); - activeTrancheKey = getEventAttributesFromTx( - { tx_response: res1 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - // Trade through some of the GTC order - const res2 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'uibcusdc', - token_out: 'untrn', - tick_index_in_to_out: 0, - limit_sell_price: '1.1', - amount_in: '1000', - order_type: 'IMMEDIATE_OR_CANCEL', - }, - }); - expect(res2.code).toEqual(0); - - const res3 = await neutronClient.execute(contractAddress, { - withdraw_filled_limit_order: { - tranche_key: activeTrancheKey, - }, - }); - expect(res3.code).toEqual(0); - }); - }); - describe('cancel LO', () => { - test('success', async () => { - // Cancel the limit order created above - const res = await neutronClient.execute(contractAddress, { - cancel_limit_order: { - tranche_key: activeTrancheKey, - }, - }); - expect(res.code).toEqual(0); - }); - - test('cancel failed', async () => { - // Attempt to cancel again fails - await expect( - neutronClient.execute(contractAddress, { - cancel_limit_order: { - tranche_key: activeTrancheKey, - }, - }), - ).rejects.toThrowError(/Limit order tranche not found:/); - }); - }); - - describe('MultiHopSwap', () => { - test('successful multihops', async () => { - const numberDenoms = 10; - const fee = { - gas: '500000', - amount: [{ denom: NEUTRON_DENOM, amount: '1250' }], - }; - for (let i = 0; i < numberDenoms; i++) { - const data = await neutronClient.signAndBroadcast( - [ - { - typeUrl: MsgCreateDenom.typeUrl, - value: MsgCreateDenom.fromPartial({ - sender: neutronWallet.address, - subdenom: String(i), - }), - }, - ], - fee, - ); - - const newTokenDenom = getEventAttribute( - data.events, - 'create_denom', - 'new_token_denom', - ); - - await neutronClient.signAndBroadcast( - [ - { - typeUrl: MsgMint.typeUrl, - value: MsgMint.fromPartial({ - sender: neutronWallet.address, - amount: { - denom: newTokenDenom, - amount: '1000000', - }, - mintToAddress: neutronWallet.address, - }), - }, - ], - fee, - ); - - await neutronClient.sendTokens( - contractAddress, - [{ denom: newTokenDenom, amount: '1000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - multiHopSwapDenoms.push({ - denom: newTokenDenom, - balance: 1000000, - }); - } - for (let i = 0; i < numberDenoms - 1; i++) { - const res = await neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: multiHopSwapDenoms[i].denom, - token_b: multiHopSwapDenoms[i + 1].denom, - amounts_a: ['1000'], // uint128 - amounts_b: ['1000'], // uint128 - tick_indexes_a_to_b: [5], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }); - expect(res.code).toEqual(0); - } - const res = await neutronClient.execute(contractAddress, { - multi_hop_swap: { - receiver: contractAddress, - routes: [ - { - hops: [ - multiHopSwapDenoms[0].denom, - multiHopSwapDenoms[1].denom, - multiHopSwapDenoms[2].denom, - multiHopSwapDenoms[3].denom, - multiHopSwapDenoms[4].denom, - multiHopSwapDenoms[5].denom, - multiHopSwapDenoms[6].denom, - multiHopSwapDenoms[7].denom, - multiHopSwapDenoms[8].denom, - multiHopSwapDenoms[9].denom, - ], - }, - ], - amount_in: '100', - exit_limit_price: '0.1', - pick_best_route: true, - }, - }); - expect(res.code).toEqual(0); - }); - - test('no route found', async () => { - await expect( - neutronClient.execute(contractAddress, { - multi_hop_swap: { - receiver: contractAddress, - routes: [ - { - hops: [ - multiHopSwapDenoms[0].denom, - multiHopSwapDenoms[9].denom, - ], - }, - ], - amount_in: '100', - exit_limit_price: '0.1', - pick_best_route: true, - }, - }), - ).rejects.toThrowError( - /All multihop routes failed limitPrice check or had insufficient liquidity/, - ); - }); - }); - }); - describe('DEX queries', () => { - beforeAll(async () => { - // create a new active tranche - const res1 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.8188125757', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - activeTrancheKey = getEventAttributesFromTx( - { tx_response: res1 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - - // create an expired tranche - const res2 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '7.3816756536', - amount_in: '1000000', - order_type: 'JUST_IN_TIME', - }, - }); - inactiveTrancheKey = getEventAttributesFromTx( - { tx_response: res2 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - // wait a few blocks to make sure JIT order expires - await neutronClient.waitBlocks(2); - }); - test('ParamsQuery', async () => { - await neutronClient.queryContractSmart(contractAddress, { - params: {}, - }); - }); - test('LimitOrderTrancheUserQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user: { - address: contractAddress, - tranche_key: activeTrancheKey, - }, - }); - expect(res.limit_order_tranche_user).toBeDefined(); - }); - test('LimitOrderTrancheUserAllQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user_all: {}, - }); - expect(res.limit_order_tranche_user.length).toBeGreaterThan(0); - }); - test('LimitOrderTrancheUserAllByAddressQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user_all_by_address: { - address: contractAddress, - }, - }); - expect(res.limit_orders.length).toBeGreaterThan(0); - }); - test('LimitOrderTrancheQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche: { - pair_id: 'uibcusdc<>untrn', - tick_index: -1999, - token_in: 'untrn', - tranche_key: activeTrancheKey, - }, - }); - expect(res.limit_order_tranche).toBeDefined(); - }); - test('invalid LimitOrderTrancheQuery', async () => { - await expect( - neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche: { - pair_id: 'untrn<>notadenom', - tick_index: -1999, - token_in: 'untrn', - tranche_key: activeTrancheKey, - }, - }), - ).rejects.toThrowError(); - }); - test('AllLimitOrderTranche', async () => { - // const res = - await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - // TODO: add tranche for tests - // expect(res.limit_order_tranche.length).toBeGreaterThan(0); - }); - test('AllUserDeposits', async () => { - const resp = await neutronClient.queryContractSmart(contractAddress, { - user_deposit_all: { - address: contractAddress, - include_pool_data: true, - }, - }); - expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0); - expect(Number(resp.deposits[0].pool.id)).toEqual(0); - - const respNoPoolData = await neutronClient.queryContractSmart( - contractAddress, - { - user_deposit_all: { - address: contractAddress, - include_pool_data: false, - }, - }, - ); - expect(respNoPoolData.deposits[0].total_shares).toBeNull(); - expect(respNoPoolData.deposits[0].pool).toBeNull(); - }); - test('AllTickLiquidity', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - tick_liquidity_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - expect(res.tick_liquidity.length).toBeGreaterThan(0); - }); - test('InactiveLimitOrderTranche', async () => { - await neutronClient.queryContractSmart(contractAddress, { - inactive_limit_order_tranche: { - pair_id: 'uibcusdc<>untrn', - tick_index: 19991, - token_in: 'untrn', - tranche_key: inactiveTrancheKey, - }, - }); - }); - test('AllInactiveLimitOrderTranche', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - inactive_limit_order_tranche_all: {}, - }); - expect(res.inactive_limit_order_tranche.length).toBeGreaterThan(0); - }); - test('AllPoolReserves', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - pool_reserves_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - expect(res.pool_reserves.length).toBeGreaterThan(0); - }); - test('PoolReserves', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_reserves: { - pair_id: 'uibcusdc<>untrn', - tick_index: -1, - token_in: 'untrn', - fee: 0, - }, - }); - }); - test.skip('EstimateMultiHopSwap', async () => { - // TODO - // await neutronWallet.queryContract( - // contractAddress, - // { - // params: {}, - // }, - // ); - }); - test('EstimatePlaceLimitOrder', async () => { - await neutronClient.queryContractSmart(contractAddress, { - estimate_place_limit_order: { - creator: contractAddress, - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 1, - amount_in: '100000', - expiration_time: Math.ceil(Date.now() / 1000) + 1000, - order_type: 'GOOD_TIL_TIME', - }, - }); - }); - test('Pool', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool: { pair_id: 'uibcusdc<>untrn', tick_index: -1, fee: 0 }, - }); - }); - test('PoolByID', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_by_id: { pool_id: 0 }, - }); - }); - test('PoolMetadata', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_metadata: { id: 0 }, - }); - }); - test('AllPoolMetadata', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - pool_metadata_all: {}, - }); - expect(res.pool_metadata.length).toBeGreaterThan(0); - }); - }); -}); diff --git a/src/testcases/run_in_band/slinky.test.ts b/src/testcases/run_in_band/slinky.test.ts index 3a499541..4e6c0d0a 100644 --- a/src/testcases/run_in_band/slinky.test.ts +++ b/src/testcases/run_in_band/slinky.test.ts @@ -162,7 +162,7 @@ describe('Neutron / Slinky', () => { }); }); - describe('wasmbindings oracle', () => { + describe('grpc oracle', () => { test('query prices', async () => { const res: GetPricesResponse = await neutronClient.queryContractSmart( oracleContract, @@ -180,7 +180,7 @@ describe('Neutron / Slinky', () => { const res: GetPriceResponse = await neutronClient.queryContractSmart( oracleContract, { - get_price: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, + get_price: { base: 'AAVE', quote: 'USD' }, }, ); expect(+res.price.price).toBeGreaterThan(0); @@ -195,7 +195,7 @@ describe('Neutron / Slinky', () => { expect(res.currency_pairs[0].Quote).toBe('USD'); }); }); - describe('wasmbindings marketmap', () => { + describe('grpc marketmap', () => { test('query last', async () => { const res: LastUpdatedResponse = await neutronClient.queryContractSmart( marketmapContract, @@ -273,10 +273,6 @@ export type GetAllCurrencyPairsResponse = { currency_pairs: CurrencyPair[]; }; -export type ParamsResponse = { - params: Params; -}; - export type CurrencyPair2 = { base: string; quote: string; @@ -286,18 +282,6 @@ export type LastUpdatedResponse = { last_updated: number; }; -export type MarketMapResponse = { - // MarketMap defines the global set of market configurations for all providers - // and markets. - market_map: MarketMap; - // LastUpdated is the last block height that the market map was updated. - // This field can be used as an optimization for clients checking if there - // is a new update to the map. - last_updated: number; - // ChainId is the chain identifier for the market map. - chain_id: string; -}; - export type MarketResponse = { market: Market; }; diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index b160fbe3..10a6a2a6 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -796,7 +796,7 @@ describe('Neutron / Tokenfactory', () => { const res = await neutronClient.queryContractSmart(contractAddress, { full_denom: { creator_addr: contractAddress, subdenom }, }); - expect(res.denom).toEqual(denom); + expect(res.full_denom).toEqual(denom); }); test('denom admin query', async () => { From d331926df9733048e9f2a23dffb800d1207287fc Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 17 Oct 2024 14:42:28 +0400 Subject: [PATCH 2/9] fix parallel tests --- src/helpers/interchainqueries.ts | 40 ++-- .../interchain_tx_query_resubmit.test.ts | 14 +- .../run_in_band/interchain_kv_query.test.ts | 214 ++++++++---------- .../interchain_tx_query_plain.test.ts | 98 ++++---- 4 files changed, 170 insertions(+), 196 deletions(-) diff --git a/src/helpers/interchainqueries.ts b/src/helpers/interchainqueries.ts index 1d0c5f2b..1fdddff5 100644 --- a/src/helpers/interchainqueries.ts +++ b/src/helpers/interchainqueries.ts @@ -511,26 +511,24 @@ export const getRegisteredQuery = async ( contractAddress: string, queryId: number, ): Promise<{ - registered_query: { - id: number; - owner: string; - keys: { - path: string; - key: string; - }[]; - query_type: string; - transactions_filter: string; - connection_id: string; - update_period: number; - last_submitted_result_local_height: number; - last_submitted_result_remote_height: { - revision_number: number; - revision_height: number; - }; - deposit: { denom: string; amount: string }[]; - submit_timeout: number; - registered_at_height: number; + id: number; + owner: string; + keys: { + path: string; + key: string; + }[]; + query_type: string; + transactions_filter: string; + connection_id: string; + update_period: number; + last_submitted_result_local_height: number; + last_submitted_result_remote_height: { + revision_number: number; + revision_height: number; }; + deposit: { denom: string; amount: string }[]; + submit_timeout: number; + registered_at_height: number; }> => client.queryContractSmart(contractAddress, { get_registered_query: { @@ -549,7 +547,7 @@ export const waitForICQResultWithRemoteHeight = ( client, () => getRegisteredQuery(client, contractAddress, queryId), async (query) => - query.registered_query.last_submitted_result_remote_height + query.last_submitted_result_remote_height .revision_height >= targetHeight, numAttempts, ); @@ -581,7 +579,7 @@ export const waitForTransfersAmount = ( client, async () => (await queryTransfersNumber(client, contractAddress)).transfers_number, - async (amount) => amount == expectedTransfersAmount, + async (amount) => amount.toString() == expectedTransfersAmount.toString(), numAttempts, ); diff --git a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts index 528f1b7b..b1ae758d 100644 --- a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts +++ b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts @@ -93,17 +93,17 @@ describe('Neutron / Interchain TX Query Resubmit', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 1); - expect(query.registered_query.id).toEqual(1); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('1'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr1 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query1UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query1UpdatePeriod.toString()); }); test('check failed txs', async () => { 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 dee876a9..a7b62b15 100644 --- a/src/testcases/run_in_band/interchain_kv_query.test.ts +++ b/src/testcases/run_in_band/interchain_kv_query.test.ts @@ -373,18 +373,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('bank'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('bank'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -396,10 +394,10 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.id).toEqual(queryId); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -410,17 +408,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); // we expect three keys, 1 always + 2 per validator - expect(queryResult.registered_query.keys.length).toEqual(3); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], - ); - }); + expect(queryResult.keys.length).toEqual(3); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + 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; @@ -429,24 +426,19 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(2); - expect(queryResult.registered_query.keys[0].path).toEqual('bank'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.keys[1].path).toEqual('bank'); - expect(queryResult.registered_query.keys[1].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], - ); - }); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(2); + expect(queryResult.keys[0].path).toEqual('bank'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.keys[1].path).toEqual('bank'); + expect(queryResult.keys[1].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + 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; @@ -455,21 +447,19 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(100); - for (let i = 0; i < queryResult.registered_query.keys.length; i++) { - expect(queryResult.registered_query.keys[i].path).toEqual('bank'); - expect(queryResult.registered_query.keys[i].key.length).toBeGreaterThan( - 0, - ); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(100); + for (let i = 0; i < queryResult.keys.length; i++) { + expect(queryResult.keys[i].path).toEqual('bank'); + expect(queryResult.keys[i].key.length).toBeGreaterThan(0); } - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -481,12 +471,10 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect( - queryResult.registered_query.last_submitted_result_local_height, - ).greaterThan(0); - expect( - queryResult.registered_query.last_submitted_result_local_height, - ).lessThan(queryResult.registered_query.update_period); + expect(queryResult.last_submitted_result_local_height).greaterThan(0); + expect(queryResult.last_submitted_result_local_height).lessThan( + queryResult.update_period, + ); }); test("registered icq #8 doesn't exist", async () => { @@ -741,10 +729,8 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect(queryResult.registered_query.deposit).toEqual( - params.params.queryDeposit, - ); - expect(queryResult.registered_query.submit_timeout.toString()).toEqual( + expect(queryResult.deposit).toEqual(params.params.queryDeposit); + expect(queryResult.submit_timeout.toString()).toEqual( params.params.querySubmitTimeout.toString(), ); }); @@ -804,10 +790,8 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect(queryResult.registered_query.deposit).toEqual(queryDepositParam); - expect(queryResult.registered_query.submit_timeout.toString()).toEqual( - '1', - ); + expect(queryResult.deposit).toEqual(queryDepositParam); + expect(queryResult.submit_timeout.toString()).toEqual('1'); const interchainQueriesParams = await interchainqQuerier.params(); @@ -825,12 +809,12 @@ describe('Neutron / Interchain KV Query', () => { 2, ); - expect( - registeredQueryBeforeParamChange.registered_query.deposit, - ).toEqual(registeredQueryAfterParamChange.registered_query.deposit); - expect( - registeredQueryBeforeParamChange.registered_query.deposit, - ).toEqual(registeredQueryAfterParamChange.registered_query.deposit); + expect(registeredQueryBeforeParamChange.deposit).toEqual( + registeredQueryAfterParamChange.deposit, + ); + expect(registeredQueryBeforeParamChange.deposit).toEqual( + registeredQueryAfterParamChange.deposit, + ); }); // FIXME: enable after fix change params via proposal @@ -856,8 +840,8 @@ describe('Neutron / Interchain KV Query', () => { await neutronClient.getWithAttempts( () => getRegisteredQuery(neutronClient, contractAddress, queryId), async (response) => - response.registered_query.last_submitted_result_local_height > 0 && - response.registered_query.last_submitted_result_local_height + 5 < + response.last_submitted_result_local_height > 0 && + response.last_submitted_result_local_height + 5 < (await neutronClient.getHeight()), 20, ); @@ -975,18 +959,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans - expect(queryResult.registered_query.keys.length).toEqual(2); - expect(queryResult.registered_query.keys[0].path).toEqual('gov'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.keys.length).toEqual(2); + expect(queryResult.keys[0].path).toEqual('gov'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('proposal votes data', async () => { @@ -1058,18 +1040,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans - expect(queryResult.registered_query.keys.length).toEqual(3); - expect(queryResult.registered_query.keys[0].path).toEqual('gov'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.keys.length).toEqual(3); + expect(queryResult.keys[0].path).toEqual('gov'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('proposals data', async () => { @@ -1166,16 +1146,14 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('slashing'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('slashing'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('signing info data', async () => { @@ -1252,16 +1230,14 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('staking'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.id).toEqual(queryId); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('staking'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('query result', async () => { 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 00979913..4e1918b7 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 @@ -136,17 +136,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 1); - expect(query.registered_query.id).toEqual(1); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('1'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr1 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query1UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query1UpdatePeriod.toString()); }); test('handle callback on a sending', async () => { @@ -299,17 +299,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 2); - expect(query.registered_query.id).toEqual(2); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('2'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr2 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query2UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query2UpdatePeriod.toString()); }); test('handle callback on a past sending', async () => { @@ -368,17 +368,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 3); - expect(query.registered_query.id).toEqual(3); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('3'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr3 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query3UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query3UpdatePeriod.toString()); }); test('check first sending handling', async () => { @@ -701,30 +701,30 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { let query = await getRegisteredQuery(neutronClient, contractAddress, 4); - expect(query.registered_query.id).toEqual(4); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('4'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr4 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query4UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query4UpdatePeriod.toString()); query = await getRegisteredQuery(neutronClient, contractAddress, 5); - expect(query.registered_query.id).toEqual(5); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('5'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr5 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query5UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query5UpdatePeriod.toString()); }); test('make younger sending and check', async () => { @@ -848,17 +848,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 6); - expect(query.registered_query.id).toEqual(6); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(JSON.parse(query.registered_query.transactions_filter)).toEqual( + expect(query.id).toEqual('6'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(JSON.parse(query.transactions_filter)).toEqual( Array(50) .fill(watchedAddr2) .map((v) => ({ field: 'transfer.recipient', op: 'Eq', value: v })), ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query2UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query2UpdatePeriod.toString()); }); }); @@ -938,17 +938,17 @@ describe('Neutron / Interchain TX Query', () => { }); it('seems registered transfers query is updated', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 3); - expect(query.registered_query.id).toEqual(3); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.update_period).toEqual(query3UpdatePeriod); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('3'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.update_period).toEqual(query3UpdatePeriod.toString()); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + newWatchedAddr5 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); + expect(query.connection_id).toEqual(connectionId); }); it('should handle callback on a sending to the new address', async () => { From 31bcca6f7f23cf260f81eaf82b387ebd6f987006 Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 17 Oct 2024 18:47:43 +0400 Subject: [PATCH 3/9] 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); From d8c64ef8693931607059fc2a3ffbda333d2fee7b Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 03:34:45 +0400 Subject: [PATCH 4/9] fix text --- src/testcases/run_in_band/tokenfactory.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index 10a6a2a6..271c302b 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -648,7 +648,7 @@ describe('Neutron / Tokenfactory', () => { }); }); - describe('wasmbindings', () => { + describe('grpc', () => { let contractAddress: string; const subdenom = 'mycoin'; let denom: string; From c73cf3e77bcc313c038989cac37d28d77e45333d Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 12:54:49 +0400 Subject: [PATCH 5/9] fix interface --- contracts/checksums.txt | 5 ++--- src/testcases/run_in_band/dex_grpc.test.ts | 1 + src/testcases/run_in_band/tokenfactory.test.ts | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/contracts/checksums.txt b/contracts/checksums.txt index 8f256649..1686c3ef 100644 --- a/contracts/checksums.txt +++ b/contracts/checksums.txt @@ -2,8 +2,7 @@ e8fadf731d66a9295f8e4384588ee45af3aaea4707ea189a95abcf826566e548 balance_tracke 7bdd09183de66e9a6b8bd2c3f77b79f82570349218011673ba2168c3482f8335 before_send_hook_test.wasm c34cc1f7f0194cdadb8d84f798f6fce79704cb04ffcc00f73fc86f5b16dbea70 client_updater.wasm c7ee546ea9f92051ff1268060ff2e8e8b6757e1b16d0d9c436f2bcc20d5868e2 cron.wasm -3f0f7d45beaaa279ee0298a3d2bcb79c8643ef2cd4476c8d627ed85451ae9a49 dex.wasm -e82b50516b84e0b1079beffdde442aabe91992e632a4abfa28187328cfb6cb73 dex_grpc.wasm +b69a06c6b8398db8a9acea60651ecfa342d28cd30ab04625a17b6e7e8f097e0d dex_grpc.wasm c1d20c14173393e4d9af066e53ec3b967c8a206f5898adb44fdec413c7696443 dex_stargate.wasm 938556c5fbe9a2b4665d1adf6a96321f9a6ba27892b4f3da9778d0f279bac049 echo.wasm 7281dc6277e509b26ecfaed701d023b83d8252dd7d6042f4e6e1f02402fe0763 grpc_querier.wasm @@ -17,4 +16,4 @@ fcab32643775a7e71596e23f6fc802406c3d12ebae8f24ebe2a49337de4e51c8 neutron_valida 0edf7ee326f63e9cfcbad9dca0bfead821010c0fbe4e5efe624cd8efe27dab67 oracle.wasm 210ce0b80133f326c0518376e6c660b4f935c258a9116e77370d1a71cd46a594 reflect.wasm 918aec79baa39d99bbe174f96cf4d15357ebdb1ceba9592ded25612bce557386 stargate_querier.wasm -aa23a731631b03355ea5642cd48df7ba0428a20061f8c5c12feb7eef9acb566c tokenfactory.wasm +9014d531afbc9ff7059abcbb3ab33d4810014523a13791829b8cde83ab915047 tokenfactory.wasm diff --git a/src/testcases/run_in_band/dex_grpc.test.ts b/src/testcases/run_in_band/dex_grpc.test.ts index f14b0b5e..15458d35 100644 --- a/src/testcases/run_in_band/dex_grpc.test.ts +++ b/src/testcases/run_in_band/dex_grpc.test.ts @@ -740,6 +740,7 @@ describe('Neutron / dex module (grpc contract)', () => { amount_in: '10000', order_type: LimitOrderType.FillOrKill.toString(), max_amount_out: '', + min_average_sell_price: '', }, }, }); diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index 271c302b..d78ab500 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -692,7 +692,7 @@ describe('Neutron / Tokenfactory', () => { denom_units: [ { denom, - exponent: 0, + exponent: '0', aliases: [], }, ], @@ -794,7 +794,7 @@ describe('Neutron / Tokenfactory', () => { test('full denom query', async () => { const res = await neutronClient.queryContractSmart(contractAddress, { - full_denom: { creator_addr: contractAddress, subdenom }, + full_denom: { creator: contractAddress, subdenom }, }); expect(res.full_denom).toEqual(denom); }); @@ -802,9 +802,11 @@ describe('Neutron / Tokenfactory', () => { test('denom admin query', async () => { const res = await neutronClient.queryContractSmart(contractAddress, { denom_admin: { + creator: contractAddress, subdenom: denom, }, }); + console.log('res: ' + JSON.stringify(res)); expect(res.admin).toEqual(contractAddress); }); test('set_before_send_hook', async () => { @@ -824,7 +826,8 @@ describe('Neutron / Tokenfactory', () => { }); const res = await neutronClient.queryContractSmart(contractAddress, { before_send_hook: { - denom, + creator: contractAddress, + subdenom: denom, }, }); expect(res.contract_addr).toEqual(contractAddress); From bb8ed8b506d78bc20796bff5212a18d4410c42d0 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 13:18:29 +0400 Subject: [PATCH 6/9] fix tokenfactory --- contracts/checksums.txt | 19 ------------------- .../run_in_band/tokenfactory.test.ts | 7 ++++--- 2 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 contracts/checksums.txt diff --git a/contracts/checksums.txt b/contracts/checksums.txt deleted file mode 100644 index 1686c3ef..00000000 --- a/contracts/checksums.txt +++ /dev/null @@ -1,19 +0,0 @@ -e8fadf731d66a9295f8e4384588ee45af3aaea4707ea189a95abcf826566e548 balance_tracker.wasm -7bdd09183de66e9a6b8bd2c3f77b79f82570349218011673ba2168c3482f8335 before_send_hook_test.wasm -c34cc1f7f0194cdadb8d84f798f6fce79704cb04ffcc00f73fc86f5b16dbea70 client_updater.wasm -c7ee546ea9f92051ff1268060ff2e8e8b6757e1b16d0d9c436f2bcc20d5868e2 cron.wasm -b69a06c6b8398db8a9acea60651ecfa342d28cd30ab04625a17b6e7e8f097e0d 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 -9014d531afbc9ff7059abcbb3ab33d4810014523a13791829b8cde83ab915047 tokenfactory.wasm diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index d78ab500..3c496d04 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -803,7 +803,7 @@ describe('Neutron / Tokenfactory', () => { const res = await neutronClient.queryContractSmart(contractAddress, { denom_admin: { creator: contractAddress, - subdenom: denom, + subdenom, }, }); console.log('res: ' + JSON.stringify(res)); @@ -827,7 +827,7 @@ describe('Neutron / Tokenfactory', () => { const res = await neutronClient.queryContractSmart(contractAddress, { before_send_hook: { creator: contractAddress, - subdenom: denom, + subdenom, }, }); expect(res.contract_addr).toEqual(contractAddress); @@ -904,7 +904,8 @@ describe('Neutron / Tokenfactory', () => { expect(balance).toEqual(amount); const res = await neutronClient.queryContractSmart(contractAddress, { denom_admin: { - subdenom: denom, + creator: contractAddress, + subdenom, }, }); expect(res.admin).toEqual(neutronWallet.address); From c03748b70d08678161f4befe1ddfdfe808c517ec Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 13:36:48 +0400 Subject: [PATCH 7/9] fix slinky test --- src/testcases/run_in_band/slinky.test.ts | 46 +++++-------------- .../run_in_band/tokenfactory.test.ts | 1 - 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/testcases/run_in_band/slinky.test.ts b/src/testcases/run_in_band/slinky.test.ts index 4e6c0d0a..8ca10f77 100644 --- a/src/testcases/run_in_band/slinky.test.ts +++ b/src/testcases/run_in_band/slinky.test.ts @@ -78,14 +78,14 @@ describe('Neutron / Slinky', () => { }); describe('before create market map', () => { - test('query last should return null', async () => { + test('query last should return 0', async () => { const res: LastUpdatedResponse = await neutronClient.queryContractSmart( marketmapContract, { last_updated: {}, }, ); - expect(res.last_updated).toBe(null); + expect(res.last_updated).toBe('0'); }); }); @@ -191,8 +191,8 @@ describe('Neutron / Slinky', () => { await neutronClient.queryContractSmart(oracleContract, { get_all_currency_pairs: {}, }); - expect(res.currency_pairs[0].Base).toBe('AAVE'); - expect(res.currency_pairs[0].Quote).toBe('USD'); + expect(res.currency_pairs[0].base).toBe('AAVE'); + expect(res.currency_pairs[0].quote).toBe('USD'); }); }); describe('grpc marketmap', () => { @@ -203,14 +203,14 @@ describe('Neutron / Slinky', () => { last_updated: {}, }, ); - expect(res.last_updated).toBeGreaterThan(0); + expect(+res.last_updated).toBeGreaterThan(0); }); test('query market', async () => { const res: MarketResponse = await neutronClient.queryContractSmart( marketmapContract, { - market: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, + market: { currency_pair: { base: 'AAVE', quote: 'USD' } }, }, ); expect(res.market).toBeDefined(); @@ -220,7 +220,7 @@ describe('Neutron / Slinky', () => { const res: MarketResponse = await neutronClient.queryContractSmart( marketmapContract, { - market: { currency_pair: { Base: 'USDT', Quote: 'USD' } }, + market: { currency_pair: { base: 'USDT', quote: 'USD' } }, }, ); expect(res.market).toBeDefined(); @@ -265,19 +265,14 @@ export type GetPricesResponse = { }; export type CurrencyPair = { - Quote: string; - Base: string; + quote: string; + base: string; }; export type GetAllCurrencyPairsResponse = { currency_pairs: CurrencyPair[]; }; -export type CurrencyPair2 = { - base: string; - quote: string; -}; - export type LastUpdatedResponse = { last_updated: number; }; @@ -286,25 +281,6 @@ export type MarketResponse = { market: Market; }; -export type QuotePrice = { - price: string; - // // BlockTimestamp tracks the block height associated with this price update. - // // We include block timestamp alongside the price to ensure that smart - // // contracts and applications are not utilizing stale oracle prices - // block_timestamp: time.Time, - // BlockHeight is height of block mentioned above - block_height: number; -}; - -export type Params = { - admin: string; - market_authorities: string[]; -}; - -export type MarketMap = { - markets: Map; -}; - export type Market = { // Tickers is the full list of tickers and their associated configurations // to be stored on-chain. @@ -326,7 +302,7 @@ export type ProviderConfig = { // For example, if the desired Ticker is BTC/USD, this market could be reached // using: OffChainTicker = BTC/USDT NormalizeByPair = USDT/USD This field is // optional and nullable. - normalize_by_pair: CurrencyPair2; + normalize_by_pair: CurrencyPair; // Invert is a boolean indicating if the BASE and QUOTE of the market should // be inverted. i.e. BASE -> QUOTE, QUOTE -> BASE invert: boolean; @@ -337,7 +313,7 @@ export type ProviderConfig = { export type Ticker = { // CurrencyPair is the currency pair for this ticker. - currency_pair: CurrencyPair2; + currency_pair: CurrencyPair; // Decimals is the number of decimal places for the ticker. The number of // decimal places is used to convert the price to a human-readable format. decimals: number; diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index 3c496d04..02b72178 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -806,7 +806,6 @@ describe('Neutron / Tokenfactory', () => { subdenom, }, }); - console.log('res: ' + JSON.stringify(res)); expect(res.admin).toEqual(contractAddress); }); test('set_before_send_hook', async () => { From 114bbd5aee0804074731e796bea295b3214c54dc Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 14:17:27 +0400 Subject: [PATCH 8/9] fix lint --- src/testcases/run_in_band/interchain_kv_query.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 d54abf6b..1e589183 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 () => { - const queryId = await registerBalancesQuery( + await registerBalancesQuery( neutronClient, contractAddress, connectionId, @@ -361,7 +361,6 @@ describe('Neutron / Interchain KV Query', () => { [COSMOS_DENOM], testState.wallets.cosmos.val1.address, ); - console.log('queryId: ' + queryId) }); }); }); From c6f9fd4c1e6d61c50045340564ffd5e1427ee2c6 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 14:52:41 +0400 Subject: [PATCH 9/9] remove DEX.wasm --- src/helpers/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts index a3657ac0..2dbec105 100644 --- a/src/helpers/constants.ts +++ b/src/helpers/constants.ts @@ -58,7 +58,6 @@ export const CONTRACTS = { // https://github.com/CosmWasm/cosmwasm/tree/main/contracts/floaty FLOATY: '../contracts_thirdparty/floaty_2.0.wasm', DEX_GRPC: 'dex_grpc.wasm', - DEX_DEV: 'dex.wasm', CRON: 'cron.wasm', // TGE liquidity migration related contracts with fixed versions