Skip to content

Commit 726f5e0

Browse files
authored
Merge pull request #321 from neutron-org/fix/empty-metadata
fix: add test that empty metadata_JSON does not break deserialization #ntrn-346
2 parents 43b9d50 + d0797f1 commit 726f5e0

File tree

1 file changed

+78
-35
lines changed

1 file changed

+78
-35
lines changed

src/testcases/run_in_band/slinky.test.ts

+78-35
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ describe('Neutron / Slinky', () => {
3535

3636
let proposalId: number;
3737

38+
let oracleContract: string;
39+
let marketmapContract: string;
40+
3841
beforeAll(async () => {
3942
testState = new TestStateLocalCosmosTestNet(config);
4043
await testState.init();
@@ -66,6 +69,44 @@ describe('Neutron / Slinky', () => {
6669
});
6770
});
6871

72+
describe('prepare: deploy contract', () => {
73+
test('setup oracle contract', async () => {
74+
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
75+
expect(codeId).toBeGreaterThan(0);
76+
77+
const res = await neutronAccount.instantiateContract(
78+
codeId,
79+
'{}',
80+
'oracle',
81+
);
82+
oracleContract = res[0]._contract_address;
83+
});
84+
85+
test('setup marketmap contract', async () => {
86+
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
87+
expect(codeId).toBeGreaterThan(0);
88+
89+
const res = await neutronAccount.instantiateContract(
90+
codeId,
91+
'{}',
92+
'marketmap',
93+
);
94+
marketmapContract = res[0]._contract_address;
95+
});
96+
});
97+
98+
describe('before create market map', () => {
99+
test('query last should return null', async () => {
100+
const res = await neutronChain.queryContract<LastUpdatedResponse>(
101+
marketmapContract,
102+
{
103+
last_updated: {},
104+
},
105+
);
106+
expect(res.last_updated).toBe(null);
107+
});
108+
});
109+
69110
describe('submit proposal', () => {
70111
test('create proposal', async () => {
71112
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
@@ -94,6 +135,26 @@ describe('Neutron / Slinky', () => {
94135
},
95136
],
96137
},
138+
{
139+
ticker: {
140+
currency_pair: {
141+
Base: 'USDT',
142+
Quote: 'USD',
143+
},
144+
decimals: 6,
145+
min_provider_count: 1,
146+
enabled: false,
147+
metadata_JSON: '',
148+
},
149+
provider_configs: [
150+
{
151+
name: 'kraken_api',
152+
off_chain_ticker: 'USDTUSD',
153+
invert: false,
154+
metadata_JSON: '',
155+
},
156+
],
157+
},
97158
],
98159
);
99160
});
@@ -137,23 +198,9 @@ describe('Neutron / Slinky', () => {
137198
});
138199

139200
describe('wasmbindings oracle', () => {
140-
let contractAddress: string;
141-
142-
test('setup contract', async () => {
143-
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
144-
expect(codeId).toBeGreaterThan(0);
145-
146-
const res = await neutronAccount.instantiateContract(
147-
codeId,
148-
'{}',
149-
'oracle',
150-
);
151-
contractAddress = res[0]._contract_address;
152-
});
153-
154201
test('query prices', async () => {
155202
const res = await neutronChain.queryContract<GetPricesResponse>(
156-
contractAddress,
203+
oracleContract,
157204
{
158205
get_prices: {
159206
currency_pair_ids: ['TIA/USD'],
@@ -166,7 +213,7 @@ describe('Neutron / Slinky', () => {
166213

167214
test('query price', async () => {
168215
const res = await neutronChain.queryContract<GetPriceResponse>(
169-
contractAddress,
216+
oracleContract,
170217
{
171218
get_price: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
172219
},
@@ -176,7 +223,7 @@ describe('Neutron / Slinky', () => {
176223

177224
test('query currencies', async () => {
178225
const res = await neutronChain.queryContract<GetAllCurrencyPairsResponse>(
179-
contractAddress,
226+
oracleContract,
180227
{
181228
get_all_currency_pairs: {},
182229
},
@@ -186,23 +233,9 @@ describe('Neutron / Slinky', () => {
186233
});
187234
});
188235
describe('wasmbindings marketmap', () => {
189-
let contractAddress: string;
190-
191-
test('setup contract', async () => {
192-
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
193-
expect(codeId).toBeGreaterThan(0);
194-
195-
const res = await neutronAccount.instantiateContract(
196-
codeId,
197-
'{}',
198-
'marketmap',
199-
);
200-
contractAddress = res[0]._contract_address;
201-
});
202-
203236
test('query last', async () => {
204237
const res = await neutronChain.queryContract<LastUpdatedResponse>(
205-
contractAddress,
238+
marketmapContract,
206239
{
207240
last_updated: {},
208241
},
@@ -212,17 +245,27 @@ describe('Neutron / Slinky', () => {
212245

213246
test('query market', async () => {
214247
const res = await neutronChain.queryContract<MarketResponse>(
215-
contractAddress,
248+
marketmapContract,
216249
{
217250
market: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
218251
},
219252
);
220253
expect(res.market).toBeDefined();
221254
});
222255

256+
test('query market with empty metadata_JSON', async () => {
257+
const res = await neutronChain.queryContract<MarketResponse>(
258+
marketmapContract,
259+
{
260+
market: { currency_pair: { Base: 'USDT', Quote: 'USD' } },
261+
},
262+
);
263+
expect(res.market).toBeDefined();
264+
});
265+
223266
test('query market map', async () => {
224267
const res = await neutronChain.queryContract<MarketMapResponse>(
225-
contractAddress,
268+
marketmapContract,
226269
{
227270
market_map: {},
228271
},
@@ -235,7 +278,7 @@ describe('Neutron / Slinky', () => {
235278

236279
test('query params', async () => {
237280
const res = await neutronChain.queryContract<ParamsResponse>(
238-
contractAddress,
281+
marketmapContract,
239282
{
240283
params: {},
241284
},

0 commit comments

Comments
 (0)