Skip to content

Commit

Permalink
test: ignore blockHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jan 9, 2025
1 parent db95428 commit 2d2000c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/vaults-and-reserve-metrics-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,31 @@ jobs:
run: ./scripts/validateData.mjs
env:
entity: vaultManagerGovernances
blockHeight: 1212

- name: Test VaultManagerMetrics
run: ./scripts/validateData.mjs
env:
entity: vaultManagerMetrics
blockHeight: 1212

- name: Test VaultManagerMetricsDaily
run: ./scripts/validateData.mjs
env:
entity: vaultManagerMetricsDailies
blockHeight: 1212

- name: Test ReserveMetrics
run: ./scripts/validateData.mjs
env:
entity: reserveMetrics
blockHeight: 1212

- name: Test ReserveAllocationMetrics
run: ./scripts/validateData.mjs
env:
entity: reserveAllocationMetrics
blockHeight: 1212

- name: Test ReserveAllocationMetricsDaily
run: ./scripts/validateData.mjs
env:
entity: reserveAllocationMetricsDailies
blockHeight: 1212

- name: Notify About Failure
if: >
Expand Down
37 changes: 14 additions & 23 deletions scripts/queries.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
const buildFilter = (filters) => {
const filterStrings = Object.entries(filters).map(([key, value]) => {
return `${key}: {equalTo: "${value}"}`;
});
return `(filter: {${filterStrings.join(', ')}})`;
};

export const getQuery = (entity, filters) => {
const filterString = buildFilter(filters);

const queries = {
vaultManagerGovernances: `query {
vaultManagerGovernances ${filterString} {
vaultManagerGovernances (first: 1) {
nodes {
id
debtLimit
Expand All @@ -28,7 +19,7 @@ export const getQuery = (entity, filters) => {
}
}`,
vaultManagerMetrics: `query {
vaultManagerMetrics ${filterString} {
vaultManagerMetrics (first: 1) {
nodes {
id
liquidatingCollateralBrand
Expand All @@ -52,7 +43,7 @@ export const getQuery = (entity, filters) => {
}
}`,
vaultManagerMetricsDailies: `query {
vaultManagerMetricsDailies ${filterString} {
vaultManagerMetricsDailies (first: 1) {
nodes {
path
liquidatingCollateralBrand
Expand All @@ -77,7 +68,7 @@ export const getQuery = (entity, filters) => {
}
}`,
reserveMetrics: `query {
reserveMetrics ${filterString} {
reserveMetrics (first: 1) {
nodes {
id
shortfallBalance
Expand All @@ -87,7 +78,7 @@ export const getQuery = (entity, filters) => {
}
}`,
reserveAllocationMetrics: `query {
reserveAllocationMetrics ${filterString} {
reserveAllocationMetrics (first: 1) {
nodes {
id
denom
Expand All @@ -97,7 +88,7 @@ export const getQuery = (entity, filters) => {
}
}`,
reserveAllocationMetricsDailies: `query {
reserveAllocationMetricsDailies ${filterString} {
reserveAllocationMetricsDailies (first: 1) {
nodes {
denom
key
Expand All @@ -113,8 +104,8 @@ export const getQuery = (entity, filters) => {

export const expectations = {
vaultManagerGovernances: {
id: 'published.vaultFactory.managers.manager1.governance',
debtLimit: '1000000000',
id: 'published.vaultFactory.managers.manager0.governance',
debtLimit: '123000000000000',
interestRateDenominator: '100',
interestRateNumerator: '1',
liquidationMarginDenominator: '100',
Expand All @@ -127,20 +118,20 @@ export const expectations = {
mintFeeNumerator: '50',
},
vaultManagerMetrics: {
liquidatingCollateralBrand: 'stATOM',
liquidatingCollateralBrand: 'ATOM',
liquidatingCollateralValue: '0',
liquidatingDebtBrand: 'IST',
liquidatingDebtValue: '0',
lockedQuoteDenominator: '0',
lockedQuoteNumerator: '0',
numActiveVaults: '0',
lockedQuoteDenominator: '12010000',
lockedQuoteNumerator: '1000000',
numActiveVaults: '7',
numLiquidatingVaults: '0',
numLiquidationsAborted: '0',
numLiquidationsCompleted: '0',
retainedCollateral: '0',
totalCollateral: '0',
totalCollateral: '5982000000',
totalCollateralSold: '0',
totalDebt: '0',
totalDebt: '35996713915',
totalOverageReceived: '0',
totalProceedsReceived: '0',
totalShortfallReceived: '0',
Expand Down
14 changes: 6 additions & 8 deletions scripts/validateData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ import { assertAllDefined } from '@agoric/internal';
const apiUrl = 'http://localhost:3000/';
console.log(`API URL set to: ${apiUrl}`);

const { entity, blockHeight } = process.env;
console.log(`Entity: ${entity}, Block Height: ${blockHeight}`);
const { entity } = process.env;
console.log(`Entity: ${entity}`);

assertAllDefined({ entity, blockHeight });

const dailyEntities = ['vaultManagerMetricsDailies', 'reserveAllocationMetricsDailies', 'vaultStatesDailies'];
const filter = dailyEntities.includes(entity) ? { blockHeightLast: blockHeight } : { blockHeight };
assertAllDefined({ entity });

try {
const graphqlQuery = { query: getQuery(entity, filter) };
const graphqlQuery = { query: getQuery(entity) };

const response = await fetch(apiUrl, {
method: 'POST',
Expand All @@ -34,7 +31,8 @@ try {
console.log('Node:', nodes);

for (const key of Object.keys(expectations[entity])) {
equal(nodes[0]?.[key], expectations[entity][key]);
console.log(`Checking ${entity} ${key}...`);
equal(nodes[0]?.[key], expectations[entity][key]), `Expected ${key} to be ${expectations[entity][key]}`;
}
} catch (error) {
console.error('Error:', error);
Expand Down

0 comments on commit 2d2000c

Please sign in to comment.