Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix tests accordingly to new contract schema #NTRN-326 #329

Merged
merged 9 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 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": "jest -b src/testcases/parallel",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && 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:feemarket && yarn test:globalfee && yarn test:tokenfactory",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && 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:feemarket && yarn test:globalfee && yarn test:tokenfactory",
"test:simple": "jest -b src/testcases/parallel/simple",
"test:slinky": "jest -b src/testcases/run_in_band/slinky",
"test:stargate_queries": "jest -b src/testcases/parallel/stargate_queries",
"test:grpc_queries": "jest -b src/testcases/parallel/grpc_queries",
"test:interchaintx": "jest -b src/testcases/run_in_band/interchaintx",
"test:interchain_kv_query": "jest -b src/testcases/run_in_band/interchain_kv_query",
"test:interchain_tx_query_plain": "jest -b src/testcases/run_in_band/interchain_tx_query_plain",
Expand All @@ -31,7 +31,7 @@
"test:tge:investors_vesting_vault": "jest -b src/testcases/parallel/tge.investors_vesting_vault",
"test:voting_registry": "jest -b src/testcases/parallel/voting_registry",
"test:float": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/float",
"test:dex_stargate": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/dex_stargate",
"test:dex_grpc": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/dex_grpc",
"test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/dex_bindings",
"test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/feemarket",
"test:globalfee": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/globalfee",
Expand All @@ -47,7 +47,7 @@
"@cosmos-client/core": "^0.47.4",
"@cosmos-client/cosmwasm": "^0.40.3",
"@cosmos-client/ibc": "^1.2.1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#649e7d91d09e5f91246e082ffa4bd29c01ab19e8",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#52ceecbc3cddcc0958c902b5a2fcf3985b86e121",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down Expand Up @@ -93,4 +93,4 @@
"engines": {
"node": ">=16.0 <17"
}
}
NeverHappened marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Neutron / Simple', () => {
});

test('create denom, mint', async () => {
const denom = `teststargate`;
const denom = `testgrpc`;

const data = await msgCreateDenom(
neutronAccount,
Expand All @@ -82,166 +82,166 @@ describe('Neutron / Simple', () => {
describe('Contract instantiation', () => {
let codeId: CodeId;
test('store contract', async () => {
codeId = await neutronAccount.storeWasm(NeutronContract.STARGATE_QUERIER);
codeId = await neutronAccount.storeWasm(NeutronContract.GRPC_QUERIER);
expect(codeId).toBeGreaterThan(0);
});
test('instantiate', async () => {
const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'stargate_querier',
'grpc_querier',
);
contractAddress = res[0]._contract_address;
});
});

async function querySmart(query: any): Promise<string> {
return await neutronChain.queryContract<string>(contractAddress, query);
async function querySmart(query: any): Promise<any> {
return await neutronChain.queryContract<any>(contractAddress, query);
}

describe('Stargate queries', () => {
describe('Grpc queries', () => {
test('bank balance should work', async () => {
const res = JSON.parse(
await querySmart({
bank_balance: {
address: neutronAccount.wallet.address.toString(),
denom: NEUTRON_DENOM,
},
}),
);
const res = await querySmart({
bank_balance: {
address: neutronAccount.wallet.address.toString(),
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 querySmart({
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 querySmart({
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 querySmart({
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: neutronAccount.wallet.address.toString(),
},
}),
);
// response with the field of type `Any` is expected, but actual type is a different struct
test.skip('auth account should work', async () => {
NeverHappened marked this conversation as resolved.
Show resolved Hide resolved
const res = await querySmart({
auth_account: {
address: neutronAccount.wallet.address.toString(),
},
});
expect(res.account.address).toBe(
neutronAccount.wallet.address.toString(),
);
});

test('transfer denom trace should work', async () => {
const res = JSON.parse(
await querySmart({
transfer_denom_trace: {
hash: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
},
}),
);
const res = await querySmart({
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 querySmart({
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 querySmart({
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 querySmart({
NeverHappened marked this conversation as resolved.
Show resolved Hide resolved
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 querySmart({
tokenfactory_params: {},
});
expect(res.params.denom_creation_gas_consume).toBe('0');
});

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

test('denoms from creator should work', async () => {
test('tokenfactory denoms from creator should work', async () => {
const res = await querySmart({
tokenfactory_denoms_from_creator: {
creator: neutronAccount.wallet.address.toString(),
},
});
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 querySmart({
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 querySmart({
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 querySmart({
feeburner_params: {},
});
expect(res.params.neutron_denom).toBe('untrn');
});
});
Expand Down
Loading
Loading