-
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.
- Loading branch information
1 parent
e290803
commit 852f818
Showing
12 changed files
with
528 additions
and
247 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "itest/**/*.ts", | ||
"require": ["ts-node/register"], | ||
"timeout": 300000 | ||
} |
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 |
---|---|---|
|
@@ -10,4 +10,4 @@ COPY src src | |
|
||
RUN npm ci | ||
|
||
ENTRYPOINT [ "npm", "run", "deploy:all" ] | ||
ENTRYPOINT [ "npm", "run", "deploy:all" ] |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,44 +1,54 @@ | ||
import { ApolloClient, InMemoryCache, gql } from '@apollo/client'; | ||
import assert from 'assert'; | ||
import { ApolloClient, gql, InMemoryCache } from '@apollo/client'; | ||
import { equal } from 'assert'; | ||
import { DockerComposeEnvironment, Wait } from 'testcontainers'; | ||
|
||
const SECONDS = 1000; | ||
const MINUTES = 60 * SECONDS; | ||
const APIURL = 'http://localhost:8000/subgraphs/name/test/poco'; | ||
const client = new ApolloClient({ | ||
uri: APIURL, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
async function main() { | ||
console.log('Running integration tests..'); | ||
const environment = new DockerComposeEnvironment('docker/test/', 'docker-compose.yml') | ||
.withStartupTimeout(3 * 60 * 1000) | ||
.withWaitStrategy( | ||
'poco-subgraph-deployer-1', | ||
Wait.forLogMessage( | ||
'Deployed to http://graphnode:8000/subgraphs/name/test/poco/graphql', | ||
), | ||
describe('Integration tests', () => { | ||
/** | ||
* Services are started only once before running all tests to get a decent test | ||
* time in case of multiple tests. Please switch to `beforeEach` if necessary. | ||
* Shutdown of services is handled by `testcontainers` framework. | ||
*/ | ||
before(async () => { | ||
console.log('Starting services..'); | ||
const environment = new DockerComposeEnvironment('docker/test/', 'docker-compose.yml') | ||
.withStartupTimeout(3 * MINUTES) | ||
.withWaitStrategy( | ||
'poco-subgraph-deployer-1', | ||
Wait.forLogMessage( | ||
'Deployed to http://graphnode:8000/subgraphs/name/test/poco/graphql', | ||
), | ||
); | ||
await environment.up(); | ||
const secondsToWait = 5; | ||
console.log( | ||
`Waiting ${secondsToWait}s for graphnode to ingest a few blocks before querying it..`, | ||
); | ||
await environment.up(); | ||
// Wait for graphnode to ingest a few blocks before querying it | ||
const secondsToWait = 5; | ||
console.log(`Waiting ${secondsToWait}s..`); | ||
await new Promise((resolve) => { | ||
return setTimeout(resolve, secondsToWait * 1000); | ||
await new Promise((resolve) => { | ||
return setTimeout(resolve, secondsToWait * SECONDS); | ||
}); | ||
}); | ||
const client = new ApolloClient({ | ||
uri: APIURL, | ||
cache: new InMemoryCache(), | ||
}); | ||
const result = await client.query({ | ||
query: gql(` | ||
query { | ||
protocol(id: "iExec") { | ||
tvl | ||
id | ||
|
||
it('should get protocol', async () => { | ||
const result = await client.query({ | ||
query: gql(` | ||
query { | ||
protocol(id: "iExec") { | ||
id | ||
tvl | ||
} | ||
} | ||
} | ||
`), | ||
`), | ||
}); | ||
const protocol = result.data.protocol; | ||
equal(protocol.id, 'iExec'); | ||
equal(protocol.tvl, '0.02025'); | ||
}); | ||
const protocol = result.data.protocol; | ||
assert.equal(protocol.id, 'iExec'); | ||
assert.equal(protocol.tvl, '0.02025'); | ||
console.log('Completed integration tests ✔️'); | ||
} | ||
|
||
main(); | ||
}); |
Oops, something went wrong.