Skip to content

Commit 0317a27

Browse files
test: update test utilities and environment preparation scripts
1 parent 8047fca commit 0317a27

File tree

3 files changed

+20
-46
lines changed

3 files changed

+20
-46
lines changed

tests/scripts/prepare-bellecour-fork-for-tests.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
toBeHex,
1010
} from 'ethers';
1111

12-
const { DRONE } = process.env;
13-
1412
const VOUCHER_HUB_ADDRESS = '0x3137B6DF4f36D338b82260eDBB2E7bab034AFEda';
1513
const TARGET_VOUCHER_MANAGER_WALLET =
1614
'0x44cA21A3c4efE9B1A0268e2e9B2547E7d9C8f19C'; // Should be same wallet as TEST_CHAIN.voucherManagerWallet
@@ -23,7 +21,7 @@ const LEARN_WORKERPOOL_ENS = 'prod-v8-learn.main.pools.iexec.eth';
2321
const PROD_WORKERPOOL_ENS = 'prod-v8-bellecour.main.pools.iexec.eth';
2422
const WEB3_MAIL_DAPP_ADDRESS_ENS = 'web3mail.apps.iexec.eth';
2523

26-
const rpcURL = DRONE ? 'http://bellecour-fork:8545' : 'http://127.0.0.1:8545';
24+
const rpcURL = 'http://127.0.0.1:8545';
2725

2826
const provider = new JsonRpcProvider(
2927
rpcURL,
@@ -42,7 +40,7 @@ const WEB3_MAIL_DAPP_ADDRESS = await provider.resolveName(
4240
);
4341

4442
const setBalance = async (address, weiAmount) => {
45-
fetch(rpcURL, {
43+
await fetch(rpcURL, {
4644
method: 'POST',
4745
body: JSON.stringify({
4846
method: 'anvil_setBalance',

tests/scripts/prepare-test-env.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { mkdirSync, writeFileSync } from 'fs';
2-
import { join } from 'path';
1+
import { writeFileSync } from 'fs';
32

4-
const forkUrl = process.env.BELLECOUR_FORK_URL || 'https://bellecour.iex.ec';
3+
const forkUrl = 'https://bellecour.iex.ec';
54

65
fetch(forkUrl, {
76
method: 'POST',
@@ -15,31 +14,19 @@ fetch(forkUrl, {
1514
.then((res) => res.json())
1615
.then((jsonRes) => {
1716
const forkBlockNumber = parseInt(jsonRes.result.substring(2), 16);
18-
if (process.env.DRONE) {
19-
const LOCAL_STACK_ENV_DIR = 'local-stack-env';
20-
console.log(
21-
`Creating ${LOCAL_STACK_ENV_DIR} directory for drone test-stack`
22-
);
23-
mkdirSync(LOCAL_STACK_ENV_DIR, { recursive: true });
24-
writeFileSync(join(LOCAL_STACK_ENV_DIR, 'BELLECOUR_FORK_URL'), forkUrl);
25-
writeFileSync(
26-
join(LOCAL_STACK_ENV_DIR, 'BELLECOUR_FORK_BLOCK'),
27-
`${forkBlockNumber}`
28-
);
29-
} else {
30-
console.log('Creating .env file for docker-compose test-stack');
31-
writeFileSync(
32-
'.env',
33-
`############ THIS FILE IS GENERATED ############
17+
18+
console.log('Creating .env file for docker-compose test-stack');
19+
writeFileSync(
20+
'.env',
21+
`############ THIS FILE IS GENERATED ############
3422
# run "node prepare-test-env.js" to regenerate #
3523
################################################
3624
3725
# blockchain node to use as the reference for the local fork
3826
BELLECOUR_FORK_URL=${forkUrl}
3927
# block number to fork from
4028
BELLECOUR_FORK_BLOCK=${forkBlockNumber}`
41-
);
42-
}
29+
);
4330
})
4431
.catch((e) => {
4532
throw Error(`Failed to get current block number from ${forkUrl}: ${e}`);

tests/test-utils.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,16 @@ import { randomInt } from 'crypto';
1010
import { getSignerFromPrivateKey } from 'iexec/utils';
1111

1212
export const TEST_CHAIN = {
13-
rpcURL: process.env.DRONE
14-
? 'http://bellecour-fork:8545'
15-
: 'http://127.0.0.1:8545',
13+
rpcURL: 'http://127.0.0.1:8545',
1614
chainId: '134',
17-
smsURL: process.env.DRONE ? 'http://sms:13300' : 'http://127.0.0.1:13300',
18-
resultProxyURL: process.env.DRONE
19-
? 'http://result-proxy:13200'
20-
: 'http://127.0.0.1:13200',
21-
iexecGatewayURL: process.env.DRONE
22-
? 'http://market-api:3000'
23-
: 'http://127.0.0.1:3000',
15+
smsURL: 'http://127.0.0.1:13300',
16+
resultProxyURL: 'http://127.0.0.1:13200',
17+
iexecGatewayURL: 'http://127.0.0.1:3000',
2418
voucherHubAddress: '0x3137B6DF4f36D338b82260eDBB2E7bab034AFEda',
2519
voucherManagerWallet: new Wallet(
2620
'0x2c906d4022cace2b3ee6c8b596564c26c4dcadddf1e949b769bcb0ad75c40c33'
2721
),
28-
voucherSubgraphURL: process.env.DRONE
29-
? 'http://graphnode:8000/subgraphs/name/bellecour/iexec-voucher'
30-
: 'http://127.0.0.1:8000/subgraphs/name/bellecour/iexec-voucher',
22+
voucherSubgraphURL: 'http://127.0.0.1:8000/subgraphs/name/bellecour/iexec-voucher',
3123
learnProdWorkerpool: 'prod-v8-learn.main.pools.iexec.eth',
3224
learnProdWorkerpoolOwnerWallet: new Wallet(
3325
'0x800e01919eadf36f110f733decb1cc0f82e7941a748e89d7a3f76157f6654bb3'
@@ -40,7 +32,7 @@ export const TEST_CHAIN = {
4032
'0xa911b93e50f57c156da0b8bff2277d241bcdb9345221a3e246a99c6e7cedcde5'
4133
),
4234
provider: new JsonRpcProvider(
43-
process.env.DRONE ? 'http://bellecour-fork:8545' : 'http://127.0.0.1:8545',
35+
'http://127.0.0.1:8545',
4436
undefined,
4537
{
4638
pollingInterval: 1000, // speed up tests
@@ -94,13 +86,10 @@ export const getTestConfig = (
9486
const ethProvider = getTestWeb3SignerProvider(privateKey);
9587
const options = {
9688
iexecOptions: getTestIExecOption(),
97-
ipfsGateway: process.env.DRONE
98-
? 'http://ipfs:8080'
99-
: 'http://127.0.0.1:8080',
100-
ipfsNode: process.env.DRONE ? 'http://ipfs:5001' : 'http://127.0.0.1:5001',
101-
dataProtectorSubgraph: process.env.DRONE
102-
? 'http://graphnode:8000/subgraphs/name/DataProtector-v2'
103-
: 'http://127.0.0.1:8000/subgraphs/name/DataProtector-v2',
89+
ipfsGateway: 'http://127.0.0.1:8080',
90+
ipfsNode: 'http://127.0.0.1:5001',
91+
dataProtectorSubgraph:
92+
'http://127.0.0.1:8000/subgraphs/name/DataProtector-v2',
10493
};
10594
return [ethProvider, options];
10695
};

0 commit comments

Comments
 (0)