Skip to content

Commit d8260ed

Browse files
committed
also test for last_updated query before marketmap created
1 parent ab6ae4d commit d8260ed

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

src/testcases/run_in_band/slinky.test.ts

+49-36
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];
@@ -157,23 +198,9 @@ describe('Neutron / Slinky', () => {
157198
});
158199

159200
describe('wasmbindings oracle', () => {
160-
let contractAddress: string;
161-
162-
test('setup contract', async () => {
163-
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
164-
expect(codeId).toBeGreaterThan(0);
165-
166-
const res = await neutronAccount.instantiateContract(
167-
codeId,
168-
'{}',
169-
'oracle',
170-
);
171-
contractAddress = res[0]._contract_address;
172-
});
173-
174201
test('query prices', async () => {
175202
const res = await neutronChain.queryContract<GetPricesResponse>(
176-
contractAddress,
203+
oracleContract,
177204
{
178205
get_prices: {
179206
currency_pair_ids: ['TIA/USD'],
@@ -186,7 +213,7 @@ describe('Neutron / Slinky', () => {
186213

187214
test('query price', async () => {
188215
const res = await neutronChain.queryContract<GetPriceResponse>(
189-
contractAddress,
216+
oracleContract,
190217
{
191218
get_price: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
192219
},
@@ -196,7 +223,7 @@ describe('Neutron / Slinky', () => {
196223

197224
test('query currencies', async () => {
198225
const res = await neutronChain.queryContract<GetAllCurrencyPairsResponse>(
199-
contractAddress,
226+
oracleContract,
200227
{
201228
get_all_currency_pairs: {},
202229
},
@@ -206,23 +233,9 @@ describe('Neutron / Slinky', () => {
206233
});
207234
});
208235
describe('wasmbindings marketmap', () => {
209-
let contractAddress: string;
210-
211-
test('setup contract', async () => {
212-
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
213-
expect(codeId).toBeGreaterThan(0);
214-
215-
const res = await neutronAccount.instantiateContract(
216-
codeId,
217-
'{}',
218-
'marketmap',
219-
);
220-
contractAddress = res[0]._contract_address;
221-
});
222-
223236
test('query last', async () => {
224237
const res = await neutronChain.queryContract<LastUpdatedResponse>(
225-
contractAddress,
238+
marketmapContract,
226239
{
227240
last_updated: {},
228241
},
@@ -232,7 +245,7 @@ describe('Neutron / Slinky', () => {
232245

233246
test('query market', async () => {
234247
const res = await neutronChain.queryContract<MarketResponse>(
235-
contractAddress,
248+
marketmapContract,
236249
{
237250
market: { currency_pair: { Base: 'TIA', Quote: 'USD' } },
238251
},
@@ -242,7 +255,7 @@ describe('Neutron / Slinky', () => {
242255

243256
test('query market with empty metadata_JSON', async () => {
244257
const res = await neutronChain.queryContract<MarketResponse>(
245-
contractAddress,
258+
marketmapContract,
246259
{
247260
market: { currency_pair: { Base: 'USDT', Quote: 'USD' } },
248261
},
@@ -252,7 +265,7 @@ describe('Neutron / Slinky', () => {
252265

253266
test('query market map', async () => {
254267
const res = await neutronChain.queryContract<MarketMapResponse>(
255-
contractAddress,
268+
marketmapContract,
256269
{
257270
market_map: {},
258271
},
@@ -265,7 +278,7 @@ describe('Neutron / Slinky', () => {
265278

266279
test('query params', async () => {
267280
const res = await neutronChain.queryContract<ParamsResponse>(
268-
contractAddress,
281+
marketmapContract,
269282
{
270283
params: {},
271284
},

0 commit comments

Comments
 (0)