Skip to content

Commit bf23446

Browse files
committed
feat: add typechain generation script and update dependencies
- Added a new script to generate TypeChain types for ethers-v6 in package.json. - Updated the start-test-stack script to ensure proper environment setup. - Modified the itest script to include NETWORK_NAME in the environment. - Removed unused callHandlers from subgraph.yaml. - Enhanced docker-compose.yml to include a stack-ready service for better orchestration. - Updated prepare-test-env.js to conditionally update networks.json based on NETWORK_NAME. - Introduced tsconfig.json for TypeScript configuration with strict settings.
1 parent 6208908 commit bf23446

File tree

9 files changed

+731
-48
lines changed

9 files changed

+731
-48
lines changed

.mocharc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"extension": ["ts"],
33
"spec": "itest/**/*.ts",
44
"require": ["ts-node/register"],
5-
"timeout": 1000000
5+
"timeout": 1000000,
6+
"node-option": [
7+
"experimental-specifier-resolution=node",
8+
"loader=ts-node/esm"
9+
]
610
}

itest/integration.test.ts

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
import { ApolloClient, gql, InMemoryCache } from '@apollo/client';
1+
import { InMemoryCache } from '@apollo/client/cache';
2+
import { ApolloClient, gql } from '@apollo/client/core';
23
import { equal } from 'assert';
3-
import { DockerComposeEnvironment, Wait } from 'testcontainers';
4+
import { JsonRpcProvider, Wallet, ZeroHash } from 'ethers';
5+
import { AppRegistry__factory, IexecInterfaceToken__factory } from '../generated/typechain';
6+
import config from '../networks.json' assert { type: 'json' };
47

5-
const SECONDS = 1000;
6-
const MINUTES = 60 * SECONDS;
7-
const APIURL = 'http://localhost:8000/subgraphs/name/test/poco';
8+
const APIURL = `http://localhost:8000/subgraphs/name/${process.env.NETWORK_NAME}/poco`;
89
const client = new ApolloClient({
910
uri: APIURL,
1011
cache: new InMemoryCache(),
1112
});
13+
const networkName = process.env.NETWORK_NAME!;
14+
const iexecProxyAddress = (config as any)[networkName].ERC1538.address;
1215

1316
describe('Integration tests', () => {
14-
/**
15-
* Services are started only once before running all tests to get a decent test
16-
* suite duration with multiple tests. Please switch to `beforeEach` if necessary.
17-
* Shutdown of services is handled by `testcontainers` framework.
18-
*/
19-
before(async () => {
20-
console.log('Starting services..');
21-
const environment = new DockerComposeEnvironment('docker/test/', 'docker-compose.yml')
22-
.withStartupTimeout(5 * MINUTES)
23-
.withWaitStrategy(
24-
'poco-subgraph-deployer-1',
25-
Wait.forLogMessage(
26-
'Deployed to http://graphnode:8000/subgraphs/name/test/poco/graphql',
27-
),
28-
);
29-
await environment.up();
30-
const secondsToWait = 10;
31-
console.log(
32-
`Waiting ${secondsToWait}s for graphnode to ingest a few blocks before querying it..`,
17+
it('should get protocol', async () => {
18+
const provider = new JsonRpcProvider(`http://localhost:8545`);
19+
const wallet = Wallet.createRandom(provider);
20+
21+
const iexecProxy = IexecInterfaceToken__factory.connect(iexecProxyAddress, wallet);
22+
const appRegistryAddress = await iexecProxy.appregistry();
23+
const appRegistry = AppRegistry__factory.connect(appRegistryAddress, wallet);
24+
25+
const appName = 'myy-app' + Date.now().toString();
26+
const tx = await appRegistry.createApp(
27+
wallet.address,
28+
appName,
29+
'DOCKER',
30+
ZeroHash,
31+
ZeroHash,
32+
ZeroHash,
3333
);
34-
await new Promise((resolve) => {
35-
return setTimeout(resolve, secondsToWait * SECONDS);
36-
});
37-
});
34+
await tx.wait();
3835

39-
it('should get protocol', async () => {
4036
const result = await client.query({
4137
query: gql(`
42-
query {
43-
protocol(id: "iExec") {
44-
id
45-
tvl
46-
}
47-
}
38+
{apps(where: {name:"${appName}"}) {
39+
id
40+
name
41+
multiaddr
42+
mrenclave
43+
checksum
44+
}}
4845
`),
4946
});
50-
const protocol = result.data.protocol;
51-
equal(protocol.id, 'iExec');
52-
equal(protocol.tvl, '0.02025');
47+
const app = result.data.apps[0];
48+
equal(app.name, appName);
49+
equal(app.multiaddr, ZeroHash);
50+
equal(app.mrenclave, ZeroHash);
51+
equal(app.checksum, ZeroHash);
5352
});
5453
});

networks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"WorkerpoolRegistry": {
2020
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
2121
"startBlock": 4543300
22-
}
22+
}
2323
},
2424
"mainnet": {
2525
"ERC1538": {
@@ -41,6 +41,6 @@
4141
"WorkerpoolRegistry": {
4242
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
4343
"startBlock": 9917600
44-
}
44+
}
4545
}
4646
}

0 commit comments

Comments
 (0)