Skip to content

Commit

Permalink
Merge branch 'main' into feat/market_map_in_genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Jul 6, 2024
2 parents efe85ab + 726f5e0 commit 95abe11
Showing 1 changed file with 99 additions and 35 deletions.
134 changes: 99 additions & 35 deletions src/testcases/run_in_band/slinky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<LastUpdatedResponse>(
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
Expand All @@ -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<GetPricesResponse>(
contractAddress,
oracleContract,
{
get_prices: {
currency_pair_ids: ['AAVE/USD'],
Expand All @@ -115,7 +193,7 @@ describe('Neutron / Slinky', () => {

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

test('query currencies', async () => {
const res = await neutronChain.queryContract<GetAllCurrencyPairsResponse>(
contractAddress,
oracleContract,
{
get_all_currency_pairs: {},
},
Expand All @@ -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<LastUpdatedResponse>(
contractAddress,
marketmapContract,
{
last_updated: {},
},
Expand All @@ -161,7 +225,7 @@ describe('Neutron / Slinky', () => {

test('query market', async () => {
const res = await neutronChain.queryContract<MarketResponse>(
contractAddress,
marketmapContract,
{
market: { currency_pair: { Base: 'AAVE', Quote: 'USD' } },
},
Expand All @@ -171,7 +235,7 @@ describe('Neutron / Slinky', () => {

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

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

0 comments on commit 95abe11

Please sign in to comment.