diff --git a/src/testcases/run_in_band/slinky.test.ts b/src/testcases/run_in_band/slinky.test.ts index 997f8ede..2f55d682 100644 --- a/src/testcases/run_in_band/slinky.test.ts +++ b/src/testcases/run_in_band/slinky.test.ts @@ -33,6 +33,11 @@ describe('Neutron / Slinky', () => { let daoMember1: DaoMember; let dao: Dao; + let proposalId: number; + + let oracleContract: string; + let marketmapContract: string; + beforeAll(async () => { testState = new TestStateLocalCosmosTestNet(config); await testState.init(); @@ -64,6 +69,93 @@ 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( + marketmapContract, + { + last_updated: {}, + }, + ); + expect(res.last_updated).toBe(null); + }); + }); + + describe('submit proposal', () => { + test('create proposal', async () => { + const chainManagerAddress = (await neutronChain.getChainAdmins())[0]; + proposalId = await daoMember1.submitCreateMarketMap( + chainManagerAddress, + 'Proposal for update marketmap', + 'Add new marketmap with currency pair to set last_updated field', + [ + { + ticker: { + currency_pair: { + Base: 'DROP', + Quote: 'USD', + }, + decimals: 8, + min_provider_count: 1, + enabled: true, + metadata_JSON: '', + }, + provider_configs: [ + { + name: 'kraken_api', + off_chain_ticker: 'DROPUSD', + invert: false, + metadata_JSON: '{}', + }, + ], + }, + ], + ); + }); + + describe('vote for proposal', () => { + test('vote YES', async () => { + await daoMember1.voteYes(proposalId); + }); + }); + + describe('execute proposal', () => { + test('check if proposal is passed', async () => { + await neutronChain.blockWaiter.waitBlocks(5); + await dao.checkPassedProposal(proposalId); + }); + test('execute passed proposal', async () => { + await daoMember1.executeProposalWithAttempts(proposalId); + }); + }); + }); + describe('module fetches prices', () => { test('currency pairs not empty', async () => { // wait to make sure we updated the price in oracle module @@ -86,23 +178,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( - contractAddress, + oracleContract, { get_prices: { currency_pair_ids: ['AAVE/USD'], @@ -115,7 +193,7 @@ describe('Neutron / Slinky', () => { test('query price', async () => { const res = await neutronChain.queryContract( - contractAddress, + oracleContract, { get_price: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, }, @@ -125,7 +203,7 @@ describe('Neutron / Slinky', () => { test('query currencies', async () => { const res = await neutronChain.queryContract( - contractAddress, + oracleContract, { get_all_currency_pairs: {}, }, @@ -135,23 +213,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( - contractAddress, + marketmapContract, { last_updated: {}, }, @@ -161,7 +225,7 @@ describe('Neutron / Slinky', () => { test('query market', async () => { const res = await neutronChain.queryContract( - contractAddress, + marketmapContract, { market: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, }, @@ -171,7 +235,7 @@ describe('Neutron / Slinky', () => { test('query market map', async () => { const res = await neutronChain.queryContract( - contractAddress, + marketmapContract, { market_map: {}, }, @@ -184,7 +248,7 @@ describe('Neutron / Slinky', () => { test('query params', async () => { const res = await neutronChain.queryContract( - contractAddress, + marketmapContract, { params: {}, },