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

fix: add test that empty metadata_JSON does not break deserialization #ntrn-346 #321

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Changes from all 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
113 changes: 78 additions & 35 deletions src/testcases/run_in_band/slinky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('Neutron / Slinky', () => {

let proposalId: number;

let oracleContract: string;
let marketmapContract: string;

beforeAll(async () => {
testState = new TestStateLocalCosmosTestNet(config);
await testState.init();
Expand Down Expand Up @@ -66,6 +69,44 @@ describe('Neutron / Slinky', () => {
});
});

describe('prepare: deploy contract', () => {
test('setup oracle contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'oracle',
);
oracleContract = res[0]._contract_address;
});

test('setup marketmap contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'marketmap',
);
marketmapContract = res[0]._contract_address;
});
});

describe('before create market map', () => {
test('query last should return null', async () => {
const res = await neutronChain.queryContract<LastUpdatedResponse>(
marketmapContract,
{
last_updated: {},
},
);
expect(res.last_updated).toBe(null);
});
});

describe('submit proposal', () => {
test('create proposal', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
Expand Down Expand Up @@ -94,6 +135,26 @@ describe('Neutron / Slinky', () => {
},
],
},
{
ticker: {
currency_pair: {
Base: 'USDT',
Quote: 'USD',
},
decimals: 6,
min_provider_count: 1,
enabled: false,
metadata_JSON: '',
},
provider_configs: [
{
name: 'kraken_api',
off_chain_ticker: 'USDTUSD',
invert: false,
metadata_JSON: '',
},
],
},
],
);
});
Expand Down Expand Up @@ -137,23 +198,9 @@ describe('Neutron / Slinky', () => {
});

describe('wasmbindings oracle', () => {
let contractAddress: string;

test('setup contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'oracle',
);
contractAddress = res[0]._contract_address;
});

test('query prices', async () => {
const res = await neutronChain.queryContract<GetPricesResponse>(
contractAddress,
oracleContract,
{
get_prices: {
currency_pair_ids: ['TIA/USD'],
Expand All @@ -166,7 +213,7 @@ describe('Neutron / Slinky', () => {

test('query price', async () => {
const res = await neutronChain.queryContract<GetPriceResponse>(
contractAddress,
oracleContract,
{
get_price: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
},
Expand All @@ -176,7 +223,7 @@ describe('Neutron / Slinky', () => {

test('query currencies', async () => {
const res = await neutronChain.queryContract<GetAllCurrencyPairsResponse>(
contractAddress,
oracleContract,
{
get_all_currency_pairs: {},
},
Expand All @@ -186,23 +233,9 @@ describe('Neutron / Slinky', () => {
});
});
describe('wasmbindings marketmap', () => {
let contractAddress: string;

test('setup contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'marketmap',
);
contractAddress = res[0]._contract_address;
});

test('query last', async () => {
const res = await neutronChain.queryContract<LastUpdatedResponse>(
contractAddress,
marketmapContract,
{
last_updated: {},
},
Expand All @@ -212,17 +245,27 @@ describe('Neutron / Slinky', () => {

test('query market', async () => {
const res = await neutronChain.queryContract<MarketResponse>(
contractAddress,
marketmapContract,
{
market: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
},
);
expect(res.market).toBeDefined();
});

test('query market with empty metadata_JSON', async () => {
const res = await neutronChain.queryContract<MarketResponse>(
marketmapContract,
{
market: { currency_pair: { Base: 'USDT', Quote: 'USD' } },
},
);
expect(res.market).toBeDefined();
});

test('query market map', async () => {
const res = await neutronChain.queryContract<MarketMapResponse>(
contractAddress,
marketmapContract,
{
market_map: {},
},
Expand All @@ -235,7 +278,7 @@ describe('Neutron / Slinky', () => {

test('query params', async () => {
const res = await neutronChain.queryContract<ParamsResponse>(
contractAddress,
marketmapContract,
{
params: {},
},
Expand Down
Loading