diff --git a/integration-tests/README.md b/integration-tests/README.md index 2c81592bec..204e8527f8 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -79,8 +79,8 @@ options replace `test` with `jest`. For example: yarn jest src/test/collect-coins.test.ts ``` -You can use `CREDITCOIN_WS_PORT` and `CREDITCOIN_METRICS_PORT` environment variables -to adjust the port values when running this test suite against a local node. That's mainly +You can use `CREDITCOIN_API_URL`, `CREDITCOIN_WS_PORT` and `CREDITCOIN_METRICS_PORT` environment variables +to adjust the some values when running this test suite against a local node. That's mainly useful for executing the loan cycle against a Zombienet chain running locally. diff --git a/integration-tests/src/globalSetup.ts b/integration-tests/src/globalSetup.ts index d38572b777..6180b47a41 100644 --- a/integration-tests/src/globalSetup.ts +++ b/integration-tests/src/globalSetup.ts @@ -21,6 +21,10 @@ declare global { var CREDITCOIN_CTC_CONTRACT: GluwaCreditVestingToken; } +export const creditcoinApiUrl = (defaultUrl: string) => { + return process.env.CREDITCOIN_API_URL || defaultUrl; +}; + const setup = async () => { process.env.NODE_ENV = 'test'; @@ -39,7 +43,7 @@ const setup = async () => { if ((global as any).CREDITCOIN_API_URL === undefined) { const wsPort = process.env.CREDITCOIN_WS_PORT || '9944'; - (global as any).CREDITCOIN_API_URL = `ws://127.0.0.1:${wsPort}`; + (global as any).CREDITCOIN_API_URL = creditcoinApiUrl(`ws://127.0.0.1:${wsPort}`); } if ((global as any).CREDITCOIN_METRICS_BASE === undefined) { diff --git a/integration-tests/src/testnetSetup.ts b/integration-tests/src/testnetSetup.ts index 3999dbbf20..9c7c02d4c9 100644 --- a/integration-tests/src/testnetSetup.ts +++ b/integration-tests/src/testnetSetup.ts @@ -1,5 +1,5 @@ import { providers, Keyring, KeyringPair, Wallet } from 'creditcoin-js'; -import { default as globalSetup } from './globalSetup'; +import { default as globalSetup, creditcoinApiUrl } from './globalSetup'; const createSigner = (keyring: Keyring, who: 'lender' | 'borrower' | 'sudo'): KeyringPair => { switch (who) { @@ -38,7 +38,7 @@ const createWallet = (who: 'lender' | 'borrower') => { }; const setup = async () => { - (global as any).CREDITCOIN_API_URL = 'wss://rpc.testnet.creditcoin.network/ws'; + (global as any).CREDITCOIN_API_URL = creditcoinApiUrl('wss://rpc.testnet.creditcoin.network/ws'); (global as any).CREDITCOIN_USES_FAST_RUNTIME = false; (global as any).CREDITCOIN_CREATE_SIGNER = createSigner; (global as any).CREDITCOIN_CREATE_WALLET = createWallet;