Skip to content

Commit

Permalink
Merge pull request #335 from neutron-org/fix/failures-fields
Browse files Browse the repository at this point in the history
 fix failures fields NTRN-359
  • Loading branch information
pr0n00gler authored Sep 4, 2024
2 parents bfa5f59 + fd7dd0c commit 9a4e55e
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 352 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/stargate": "0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@neutron-org/neutronjs": "https://github.com/neutron-org/neutronjs.git#f5334307decfa549283d03e626cd45582667c13f",
"@neutron-org/neutronjs": "https://github.com/neutron-org/neutronjs.git#1e70c1f68e997857f42bab7647227c8ca9dc8aa1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#1e4527ef6971f4dc2c202cb3cc2a50b0a4491f54",
"@types/lodash": "^4.14.182",
"axios": "1.6.0",
Expand Down Expand Up @@ -89,4 +89,4 @@
"engines": {
"node": ">=20.0"
}
}
}
2 changes: 1 addition & 1 deletion src/testcases/parallel/grpc_queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RunnerTestSuite, inject } from 'vitest';
import { SigningNeutronClient } from '../../helpers/signing_neutron_client';
import { defaultRegistryTypes, SigningStargateClient } from '@cosmjs/stargate';
import { Registry } from '@cosmjs/proto-signing';
import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx';
import { MsgTransfer } from '@neutron-org/neutronjs/ibc/applications/transfer/v1/tx';
import { MsgCreateDenom } from '@neutron-org/neutronjs/osmosis/tokenfactory/v1beta1/tx';
import { COSMOS_DENOM, NEUTRON_DENOM } from '../../helpers/constants';
import config from '../../config.json';
Expand Down
50 changes: 20 additions & 30 deletions src/testcases/parallel/ibc_transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import { SigningNeutronClient } from '../../helpers/signing_neutron_client';
import { MsgTransfer as GaiaMsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx';
import { MsgTransfer as NeutronMsgTransfer } from '@neutron-org/neutronjs/ibc/applications/transfer/v1/tx';
import { defaultRegistryTypes } from '@cosmjs/stargate';
import {
QueryClientImpl as ContractManagerQuery,
QueryFailuresResponse,
} from '@neutron-org/cosmjs-types/neutron/contractmanager/query';
import { QueryClientImpl as BankQueryClient } from '@neutron-org/cosmjs-types/cosmos/bank/v1beta1/query';
import { QueryClientImpl as IbcQueryClient } from '@neutron-org/cosmjs-types/ibc/applications/transfer/v1/query';
import { QueryFailuresResponse } from '@neutron-org/neutronjs/neutron/contractmanager/query';
import { QueryClientImpl as BankQueryClient } from '@neutron-org/neutronjs/cosmos/bank/v1beta1/query.rpc.Query';
import { QueryClientImpl as IbcQueryClient } from '@neutron-org/neutronjs/ibc/applications/transfer/v1/query.rpc.Query';
import {
COSMOS_DENOM,
IBC_RELAYER_NEUTRON_ADDRESS,
Expand All @@ -22,6 +19,7 @@ import { waitBlocks } from '@neutron-org/neutronjsplus/dist/wait';
import { Wallet } from '../../helpers/wallet';
import { getIBCDenom } from '@neutron-org/neutronjsplus/dist/cosmos';
import config from '../../config.json';
import { QueryClientImpl as ContractManagerQuery } from '@neutron-org/neutronjs/neutron/contractmanager/query.rpc.Query';

const TRANSFER_CHANNEL = 'channel-0';
const IBC_TOKEN_DENOM =
Expand Down Expand Up @@ -117,7 +115,10 @@ describe('Neutron / IBC transfer', () => {
expect(res.code).toEqual(0);
});
test('check balance', async () => {
const res = await bankQuerier.AllBalances({ address: ibcContract });
const res = await bankQuerier.allBalances({
resolveDenom: false,
address: ibcContract,
});
expect(res.balances).toEqual([
{ amount: '50000', denom: NEUTRON_DENOM },
]);
Expand Down Expand Up @@ -191,7 +192,7 @@ describe('Neutron / IBC transfer', () => {
expect(balance.amount).toEqual('1000');
});
test('check that weird IBC denom is uatom indeed', async () => {
const res = await ibcQuerier.DenomTrace({
const res = await ibcQuerier.denomTrace({
hash: '27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
});
expect(res.denomTrace.baseDenom).toEqual(COSMOS_DENOM);
Expand Down Expand Up @@ -449,12 +450,9 @@ describe('Neutron / IBC transfer', () => {
});
});
test('execute contract with failing sudo', async () => {
const failuresBeforeCall = await contractManagerQuerier.AddressFailures(
{
failureId: 0n, // bug: should not be in query
address: ibcContract,
},
);
const failuresBeforeCall = await contractManagerQuerier.failures({
address: ibcContract,
});
expect(failuresBeforeCall.failures.length).toEqual(0);

// Mock sudo handler to fail
Expand Down Expand Up @@ -500,8 +498,7 @@ describe('Neutron / IBC transfer', () => {
const failuresAfterCall =
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
contractManagerQuerier.failures({
address: ibcContract,
}),
// Wait until there 4 failures in the list
Expand Down Expand Up @@ -579,8 +576,7 @@ describe('Neutron / IBC transfer', () => {

const res = await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
contractManagerQuerier.failures({
address: ibcContract,
}),
// Wait until there 6 failures in the list
Expand All @@ -600,8 +596,7 @@ describe('Neutron / IBC transfer', () => {
await neutronClient.waitBlocks(2);

// Try to resubmit failure
const failuresResBefore = await contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
const failuresResBefore = await contractManagerQuerier.failures({
address: ibcContract,
});

Expand All @@ -616,8 +611,7 @@ describe('Neutron / IBC transfer', () => {
await neutronClient.waitBlocks(5);

// check that failures count is the same
const failuresResAfter = await contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
const failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});
expect(failuresResAfter.failures.length).toEqual(6);
Expand All @@ -631,8 +625,7 @@ describe('Neutron / IBC transfer', () => {

test('successful resubmit failure', async () => {
// Resubmit failure
const failuresResBefore = await contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
const failuresResBefore = await contractManagerQuerier.failures({
address: ibcContract,
});
const failure = failuresResBefore.failures[0];
Expand All @@ -646,8 +639,7 @@ describe('Neutron / IBC transfer', () => {
await neutronClient.waitBlocks(5);

// check that failures count is changed
const failuresResAfter = await contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
const failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});
expect(failuresResAfter.failures.length).toEqual(5);
Expand All @@ -663,8 +655,7 @@ describe('Neutron / IBC transfer', () => {
countTotal: false,
reverse: false,
};
const res = await contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
const res = await contractManagerQuerier.failures({
address: ibcContract,
pagination,
});
Expand All @@ -679,8 +670,7 @@ describe('Neutron / IBC transfer', () => {
reverse: false,
};
await expect(
contractManagerQuerier.AddressFailures({
failureId: 0n, // bug: should not be in query
contractManagerQuerier.failures({
address: ibcContract,
pagination,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/ibc_hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RunnerTestSuite, inject } from 'vitest';
import { SigningNeutronClient } from '../../helpers/signing_neutron_client';
import { defaultRegistryTypes, SigningStargateClient } from '@cosmjs/stargate';
import { Registry } from '@cosmjs/proto-signing';
import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx';
import { MsgTransfer } from '@neutron-org/neutronjs/ibc/applications/transfer/v1/tx';

import config from '../../config.json';
import { waitBlocks } from '@neutron-org/neutronjsplus/dist/wait';
Expand Down
4 changes: 3 additions & 1 deletion src/testcases/run_in_band/interchain_kv_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ describe('Neutron / Interchain KV Query', () => {
gaiaWallet.address,
);

balances = await bankQuerier.AllBalances({ address: contractAddress });
balances = await bankQuerier.AllBalances({
address: contractAddress,
});

expect(balances.balances.length).toEqual(0);
});
Expand Down
57 changes: 21 additions & 36 deletions src/testcases/run_in_band/interchaintx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import {
QueryClientImpl as StakingQueryClient,
QueryDelegatorDelegationsResponse,
} from '@neutron-org/cosmjs-types/cosmos/staking/v1beta1/query';
import {
QueryClientImpl as IbcQueryClient,
QueryChannelsResponse,
} from '@neutron-org/cosmjs-types/ibc/core/channel/v1/query';
import {
QueryClientImpl as ContractManagerQuery,
QueryFailuresResponse,
} from '@neutron-org/cosmjs-types/neutron/contractmanager/query';
import { QueryChannelsResponse } from '@neutron-org/neutronjs/ibc/core/channel/v1/query';
import { QueryClientImpl as IbcQueryClient } from '@neutron-org/neutronjs/ibc/core/channel/v1/query.rpc.Query';
import { QueryFailuresResponse } from '@neutron-org/neutronjs/neutron/contractmanager/query';
import { getWithAttempts } from '../../helpers/misc';
import { QueryClientImpl as ContractManagerQuery } from '@neutron-org/neutronjs/neutron/contractmanager/query.rpc.Query';

import { Wallet } from '../../helpers/wallet';
import {
AcknowledgementResult,
Expand Down Expand Up @@ -150,7 +147,7 @@ describe('Neutron / Interchain TXs', () => {
test('multiple IBC accounts created', async () => {
const channels =
await neutronClient.getWithAttempts<QueryChannelsResponse>(
() => ibcQuerier.Channels({}),
() => ibcQuerier.channels({}),
// Wait until there are 3 channels:
// - one exists already, it is open for IBC transfers;
// - two more should appear soon since we are opening them implicitly
Expand Down Expand Up @@ -587,15 +584,15 @@ describe('Neutron / Interchain TXs', () => {
});
expect(res.code).toEqual(0);
await neutronClient.getWithAttempts(
async () => ibcQuerier.Channels({}),
async () => ibcQuerier.channels({}),
// Wait until there are 5 channels:
// - one exists already, it is open for IBC transfers;
// - three channels are already opened via ICA registration before
// - one more, we are opening it right now
async (channels) => channels.channels.length == 5,
);
await neutronClient.getWithAttempts(
() => ibcQuerier.Channels({}),
() => ibcQuerier.channels({}),
async (channels) =>
channels.channels.findLast(
(c) => c.portId === `icacontroller-${contractAddress}.test1`,
Expand Down Expand Up @@ -648,9 +645,8 @@ describe('Neutron / Interchain TXs', () => {
beforeAll(async () => {
await cleanAckResults(neutronClient, contractAddress);

const failures = await contractManagerQuerier.AddressFailures({
const failures = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
expect(failures.failures.length).toEqual(0);

Expand All @@ -677,9 +673,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 1,
100,
Expand Down Expand Up @@ -714,9 +709,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 2,
100,
Expand Down Expand Up @@ -751,9 +745,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 3,
100,
Expand Down Expand Up @@ -790,9 +783,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 4,
100,
Expand Down Expand Up @@ -828,9 +820,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 5,
100,
Expand Down Expand Up @@ -868,9 +859,8 @@ describe('Neutron / Interchain TXs', () => {
// wait until sudo is called and processed and failure is recorder
await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
contractManagerQuerier.AddressFailures({
contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
}),
async (data) => data.failures.length == 6,
100,
Expand All @@ -887,9 +877,8 @@ describe('Neutron / Interchain TXs', () => {
});

test('check stored failures and acks', async () => {
const failures = await contractManagerQuerier.AddressFailures({
const failures = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
// 4 ack failures, 2 timeout failure, just as described in the tests above
expect(failures.failures).toEqual([
Expand Down Expand Up @@ -941,9 +930,8 @@ describe('Neutron / Interchain TXs', () => {
await neutronClient.waitBlocks(5);

// Try to resubmit failure
const failuresResBefore = await contractManagerQuerier.AddressFailures({
const failuresResBefore = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
await expect(
neutronClient.execute(contractAddress, {
Expand All @@ -956,9 +944,8 @@ describe('Neutron / Interchain TXs', () => {
await neutronClient.waitBlocks(5);

// check that failures count is the same
const failuresResAfter = await contractManagerQuerier.AddressFailures({
const failuresResAfter = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
expect(failuresResAfter.failures.length).toEqual(6);

Expand All @@ -975,9 +962,8 @@ describe('Neutron / Interchain TXs', () => {

test('successful resubmit failure', async () => {
// Resubmit failure
const failuresResBefore = await contractManagerQuerier.AddressFailures({
const failuresResBefore = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
const failure = failuresResBefore.failures[0];
const failureId = failure.id;
Expand All @@ -991,9 +977,8 @@ describe('Neutron / Interchain TXs', () => {
await neutronClient.waitBlocks(5);

// check that failures count is changed
const failuresResAfter = await contractManagerQuerier.AddressFailures({
const failuresResAfter = await contractManagerQuerier.failures({
address: contractAddress,
failureId: 0n,
});
expect(failuresResAfter.failures.length).toEqual(5);

Expand Down Expand Up @@ -1040,7 +1025,7 @@ describe('Neutron / Interchain TXs', () => {
timeout: 'message',
});

const channel = (await ibcQuerier.Channels({})).channels.find(
const channel = (await ibcQuerier.channels({})).channels.find(
(c) => c.ordering === Order.ORDER_UNORDERED,
);
expect(channel.state).toEqual(State.STATE_OPEN);
Expand Down
4 changes: 2 additions & 2 deletions src/testcases/run_in_band/tokenfactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
MsgMint,
MsgSetBeforeSendHook,
} from '@neutron-org/neutronjs/osmosis/tokenfactory/v1beta1/tx';
import { QueryClientImpl as BankQueryClient } from '@neutron-org/cosmjs-types/cosmos/bank/v1beta1/query';
import { QueryClientImpl as BankQueryClient } from '@neutron-org/neutronjs/cosmos/bank/v1beta1/query.rpc.Query';
import { createRPCQueryClient as createOsmosisClient } from '@neutron-org/neutronjs/osmosis/rpc.query';
import { OsmosisQuerier } from '@neutron-org/neutronjs/querier_types';
import { NEUTRON_DENOM } from '@neutron-org/neutronjsplus/dist/constants';
Expand Down Expand Up @@ -705,7 +705,7 @@ describe('Neutron / Tokenfactory', () => {
},
});

const metadata = await bankQuerier.DenomMetadata({ denom: denom });
const metadata = await bankQuerier.denomMetadata({ denom: denom });
expect(metadata.metadata.base).toEqual(denom);
expect(metadata.metadata.uri).toEqual(denom);
expect(metadata.metadata.display).toEqual(denom);
Expand Down
Loading

0 comments on commit 9a4e55e

Please sign in to comment.