-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
195-Integration-tests-invariants (#225)
test: smoke tests chore: correct smoke test logic test: run smoke tests on release branches
- Loading branch information
Showing
10 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Config } from 'jest' | ||
|
||
const config: Config = { | ||
verbose: true, | ||
workerThreads: true, | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
setupFiles: ['./jest/smoke.js'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js'], | ||
testMatch: [ '**/smoke-tests/**/*.test.ts' ], | ||
transform: { | ||
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` | ||
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: './tsconfig.json', | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const axios = require('axios') | ||
const STAGING_URL = 'https://api.subquery.network/sq/centrifuge/pools-multichain__Y2Vud' | ||
|
||
async function subql(query) { | ||
const response = await axios.post('/', { query }, { baseURL: STAGING_URL }).catch((err) => err.response.data) | ||
return response.data | ||
} | ||
|
||
global.subql = subql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare global { | ||
function subql<T>(query: string): Promise<T> | ||
} | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as Models from '../src/types/models' | ||
|
||
const snapshotModels = Object.keys(Models) | ||
.filter((modelName) => modelName.endsWith('Snapshot')) | ||
.map((modelName) => `${modelName.charAt(0).toLowerCase() + modelName.slice(1)}s`) | ||
|
||
describe('Entities snapshots', () => { | ||
test.each(snapshotModels)('%s should have some snapshots', async (snapshotModel) => { | ||
const queryModelName = `${snapshotModel}` | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const subqlResponse = await subql<any>(`{ ${queryModelName} { totalCount } }`) | ||
const { totalCount } = subqlResponse.data[queryModelName] | ||
expect(totalCount).toBeGreaterThan(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const lastMidnight = new Date().setHours(0, 0, 0, 0) | ||
|
||
const chainIds = { | ||
CFG: '0xb3db41421702df9a7fcac62b53ffeac85f7853cc4e689e0b93aeb3db18c09d82', | ||
ETH: '1', | ||
} | ||
|
||
const chains = Object.keys(chainIds) | ||
|
||
describe('SubQl Nodes', () => { | ||
test.each(chains)('%s node is fully synced', async (chain) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const response = await subql<any>(` | ||
{ | ||
timekeeper(id: "${chainIds[chain]}") { | ||
lastPeriodStart | ||
} | ||
} | ||
`) | ||
const lastPeriodStart = Date.parse(response.data.timekeeper.lastPeriodStart) | ||
expect(lastPeriodStart).toBe(lastMidnight) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const knownTVL = { | ||
'2024-01-01': '253434909261717851940121572', | ||
'2024-07-01': '12008948422649000000000000', | ||
} | ||
|
||
const sampleDates = Object.keys(knownTVL) | ||
|
||
describe('TVL at known intervals', () => { | ||
test.each(sampleDates)('TVL at %s', async (sampleDate) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const response = await subql<any>(` | ||
{ poolSnapshots(filter: { periodStart: { equalTo: "${sampleDate}" } }) { aggregates { sum { normalizedNAV } } } } | ||
`) | ||
const { normalizedNAV } = response.data.poolSnapshots.aggregates.sum | ||
expect(normalizedNAV).toBe(knownTVL[sampleDate]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters