Skip to content

Commit

Permalink
Merge pull request #329 from neutron-org/feat/remove-stargate
Browse files Browse the repository at this point in the history
feat: fix tests accordingly to new contract schema #NTRN-326
  • Loading branch information
pr0n00gler authored Aug 13, 2024
2 parents f8334b0 + 64425ed commit c533ce8
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 109 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"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:dex_stargate && yarn test:dex_bindings && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory",
"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:dex_grpc && yarn test:dex_bindings && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory",
"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:stargate_queries": "vitest --run src/testcases/parallel/stargate_queries --bail 1",
"test:grpc_queries": "vitest --run src/testcases/parallel/grpc_queries --bail 1",
"test:interchaintx": "vitest --run src/testcases/run_in_band/interchaintx --bail 1",
"test:interchain_kv_query": "vitest --run src/testcases/run_in_band/interchain_kv_query --bail 1",
"test:interchain_tx_query_plain": "vitest --run src/testcases/run_in_band/interchain_tx_query_plain --bail 1",
Expand All @@ -26,7 +26,7 @@
"test:overrule": "vitest --run src/testcases/parallel/overrule --bail 1",
"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_stargate": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_stargate --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",
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const IBC_RELAYER_NEUTRON_ADDRESS =
export const CONTRACTS = {
IBC_TRANSFER: 'ibc_transfer.wasm',
MSG_RECEIVER: 'msg_receiver.wasm',
STARGATE_QUERIER: 'stargate_querier.wasm',
GRPC_QUERIER: 'grpc_querier.wasm',
INTERCHAIN_QUERIES: 'neutron_interchain_queries.wasm',
INTERCHAIN_TXS: 'neutron_interchain_txs.wasm',
REFLECT: 'reflect.wasm',
Expand Down Expand Up @@ -57,7 +57,7 @@ export const CONTRACTS = {
BEFORE_SEND_HOOK_TEST: 'before_send_hook_test.wasm',
// https://github.com/CosmWasm/cosmwasm/tree/main/contracts/floaty
FLOATY: '../contracts_thirdparty/floaty_2.0.wasm',
DEX_STARGATE: 'dex_stargate.wasm',
DEX_GRPC: 'dex_grpc.wasm',
DEX_DEV: 'dex.wasm',

// TGE liquidity migration related contracts with fixed versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MsgCreateDenom } from '@neutron-org/neutronjs/osmosis/tokenfactory/v1be
import { COSMOS_DENOM, NEUTRON_DENOM } from '../../helpers/constants';
import config from '../../config.json';

describe('Neutron / Stargate Queries', () => {
describe('Neutron / Grpc Queries', () => {
let testState: LocalState;
let neutronClient: SigningNeutronClient;
let neutronWallet: Wallet;
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Neutron / Stargate Queries', () => {
});

test('create denom, mint', async () => {
const denom = `teststargate`;
const denom = `testgrpc`;
const fee = {
gas: '500000',
amount: [{ denom: NEUTRON_DENOM, amount: '1250' }],
Expand Down Expand Up @@ -98,159 +98,154 @@ describe('Neutron / Stargate Queries', () => {
describe('Contract instantiation', () => {
test('instantiate', async () => {
contractAddress = await neutronClient.create(
CONTRACTS.STARGATE_QUERIER,
CONTRACTS.GRPC_QUERIER,
{},
'stargate_querier',
'grpc_querier',
);
});
});

// TODO: this function does not make much sense: remove it
async function querySmart(query: any): Promise<string> {
return await neutronClient.queryContractSmart(contractAddress, query);
}

describe('Stargate queries', () => {
describe('Grpc queries', () => {
test('bank balance should work', async () => {
const res = JSON.parse(
await querySmart({
bank_balance: {
address: neutronWallet.address,
denom: NEUTRON_DENOM,
},
}),
);
const res = await neutronClient.queryContractSmart(contractAddress, {
bank_balance: {
address: neutronWallet.address,
denom: NEUTRON_DENOM,
},
});
expect(res.balance.denom).toBe('untrn');
expect(+res.balance.amount).toBeGreaterThan(1000000);
});

test('bank denom metadata should work', async () => {
const res = JSON.parse(
await querySmart({
bank_denom_metadata: { denom: newTokenDenom },
}),
);
expect(res.metadatas[0].denom_units[0].denom).toBe(newTokenDenom);
const res = await neutronClient.queryContractSmart(contractAddress, {
bank_denom_metadata: {
denom: newTokenDenom,
},
});
expect(res.metadata.denom_units[0].denom).toBe(newTokenDenom);
});

test('bank params should work', async () => {
const res = JSON.parse(await querySmart({ bank_params: {} }));
const res = await neutronClient.queryContractSmart(contractAddress, {
bank_params: {},
});
expect(res.params.default_send_enabled).toBe(true);
});

test('bank supply of should work', async () => {
const res = JSON.parse(
await querySmart({
bank_supply_of: { denom: NEUTRON_DENOM },
}),
);
const res = await neutronClient.queryContractSmart(contractAddress, {
bank_supply_of: {
denom: NEUTRON_DENOM,
},
});
expect(res.amount.denom).toBe('untrn');
expect(+res.amount.amount).toBeGreaterThan(1000000);
});

test('auth account should work', async () => {
const res = JSON.parse(
await querySmart({
auth_account: {
address: neutronWallet.address,
},
}),
);
// response with the field of type `Any` is expected, but actual type is a different struct
test.skip('auth account should work', async () => {
const res = await neutronClient.queryContractSmart(contractAddress, {
auth_account: {
address: neutronWallet.address,
},
});
expect(res.account.address).toBe(neutronWallet.address);
});

test('transfer denom trace should work', async () => {
const res = JSON.parse(
await querySmart({
transfer_denom_trace: {
hash: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
},
}),
);
const res = await neutronClient.queryContractSmart(contractAddress, {
transfer_denom_trace: {
hash: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
},
});
expect(res.denom_trace.path).toBe('transfer/channel-0');
expect(res.denom_trace.base_denom).toBe('uatom');
});

test('ibc client state should work', async () => {
const res = JSON.parse(
await querySmart({
ibc_client_state: {
client_id: '07-tendermint-1',
},
}),
);
// response with the field of type `Any` is expected, but actual type is a different struct
test.skip('ibc client state should work', async () => {
const res = await neutronClient.queryContractSmart(contractAddress, {
ibc_client_state: {
client_id: '07-tendermint-1',
},
});
expect(res.client_state['@type']).toBe(
'/ibc.lightclients.tendermint.v1.ClientState',
);
expect(res.client_state.chain_id).toBe('test-2');
});

test('ibc consensus state should work', async () => {
const res = JSON.parse(
await querySmart({
ibc_consensus_state: {
client_id: '07-tendermint-1',
revision_number: 0,
revision_height: 0,
latest_height: true,
},
}),
);
// response with the field of type `Any` is expected, but actual type is a different struct
test.skip('ibc consensus state should work', async () => {
const res = await neutronClient.queryContractSmart(contractAddress, {
ibc_consensus_state: {
client_id: '07-tendermint-1',
revision_number: 0,
revision_height: 0,
latest_height: true,
},
});
expect(res.consensus_state['@type']).toBe(
'/ibc.lightclients.tendermint.v1.ConsensusState',
);
expect(+res.proof_height.revision_height).toBeGreaterThan(0);
});

test('ibc connection should work', async () => {
const res = JSON.parse(
await querySmart({
ibc_connection: {
connection_id: 'connection-0',
},
}),
);
const res = await neutronClient.queryContractSmart(contractAddress, {
ibc_connection: {
connection_id: 'connection-0',
},
});
expect(res.connection.client_id).toBe('07-tendermint-1');
expect(+res.proof_height.revision_height).toBeGreaterThan(0);
});

test('tokenfactory params should work', async () => {
const res = JSON.parse(await querySmart({ tokenfactory_params: {} }));
const res = await neutronClient.queryContractSmart(contractAddress, {
tokenfactory_params: {},
});
expect(res.params.denom_creation_gas_consume).toBe('0');
});

test('tokenfactory denom authority metadata should work', async () => {
const res = await querySmart({
const res = await neutronClient.queryContractSmart(contractAddress, {
tokenfactory_denom_authority_metadata: {
denom: newTokenDenom,
creator: neutronWallet.address,
subdenom: newTokenDenom,
},
});
expect(res).toBe(`{"authority_metadata":{"Admin":""}}`);
expect(res.authority_metadata.admin).toBe('');
});

test('denoms from creator should work', async () => {
const res = await querySmart({
test('tokenfactory denoms from creator should work', async () => {
const res = await neutronClient.queryContractSmart(contractAddress, {
tokenfactory_denoms_from_creator: {
creator: neutronWallet.address,
},
});
expect(res).toBe(`{"denoms":["${newTokenDenom}"]}`);
expect(res.denoms[0]).toBe(newTokenDenom);
});

test('interchaintx params should work', async () => {
const res = JSON.parse(await querySmart({ interchaintx_params: {} }));
test('interchaintxs params should work', async () => {
const res = await neutronClient.queryContractSmart(contractAddress, {
interchaintxs_params: {},
});
expect(+res.params.msg_submit_tx_max_messages).toBeGreaterThan(0);
});

test('interchainqueries params should work', async () => {
const res = JSON.parse(
await querySmart({ interchainqueries_params: {} }),
);
const res = await neutronClient.queryContractSmart(contractAddress, {
interchainqueries_params: {},
});
expect(+res.params.query_submit_timeout).toBeGreaterThan(0);
});

test('feeburner params should work', async () => {
const res = JSON.parse(await querySmart({ feeburner_params: {} }));
const res = await neutronClient.queryContractSmart(contractAddress, {
feeburner_params: {},
});
expect(res.params.neutron_denom).toBe('untrn');
});
});
Expand Down
Loading

0 comments on commit c533ce8

Please sign in to comment.