Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSUB-980: Adjust contract addresses for testing against Devnet & Testnet #1508

Merged
merged 7 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions .github/workflows/runtime-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,6 @@ jobs:
run: |
./scripts/wait-for-sync.sh ${{ needs.setup.outputs.last_block_number }}

- name: Install Docker engine
run: |
./scripts/install-docker-engine-from-upstream.sh

- name: Start local Ethereum node
run: |
sudo docker run --name hardhat-dev --rm -p 8545:8545 -d gluwa/hardhat-dev

- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -530,6 +522,7 @@ jobs:
run: |
yarn --cwd ./integration-tests/ test --config testnet.config.ts
env:
CREDITCOIN_API_URL: ws://127.0.0.1:9944
ETHEREUM_NODE_URL: ${{ secrets.TESTNET_ETHEREUM_NODE_URL }}
LENDER_PRIVATE_KEY: ${{ secrets.TESTNET_LENDER_PRIVATE_KEY }}
LENDER_SEED: "${{ secrets.TESTNET_LENDER_SEED }}"
Expand All @@ -543,11 +536,6 @@ jobs:
name: logs
path: "*.log"

- name: Kill hardhat-dev
if: always()
run: |
sudo docker kill hardhat-dev

- name: Kill creditcoin-node
run: |
# if all went well kill the node. Otherwise GitHub Actions would exit on the
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

Install Node.js and Yarn. You can do so from here: <https://nodejs.org/en/download>

**WARNING:** Node.js 14.x || 16.x is required
**WARNING:** Node.js 20.x is required

Alternatively, a convenient tool to manage Node/npm installations is `nvm`.
You can get it here: <https://github.com/nvm-sh/nvm#installing-and-updating>

And then install the required version as follows.

```bash
nvm install 16
nvm alias default 16
nvm use 16
nvm install 20
nvm alias default 20
nvm use 20
```

We use Yarn for our package management and build scripts. To install Yarn enter:
Expand Down Expand Up @@ -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.


Expand All @@ -96,7 +96,7 @@ yarn install
2. Execute the test suite:

```bash
export ETHEREUM_NODE_URL=https://goerli.infura.io/v3/abcdef
export ETHEREUM_NODE_URL=https://sepolia.infura.io/v3/abcdef
export LENDER_PRIVATE_KEY=XXXXXX
export BORROWER_PRIVATE_KEY=YYYY

Expand Down
2 changes: 0 additions & 2 deletions integration-tests/src/creditcoinForkSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const setup = async () => {
// to satisfy the regexp in metrics.test.ts
(global as any).CREDITCOIN_NETWORK_SHORT_NAME = '.*-fork';

(global as any).CREDITCOIN_SWITCH_TO_POS_ALREADY_CALLED = process.env.SWITCH_TO_POS_ALREADY_CALLED === '1';

(global as any).CREDITCOIN_USES_FAST_RUNTIME = false;

await globalSetup();
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/src/devnetSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const setup = async () => {
(global as any).CREDITCOIN_ETHEREUM_USE_HARDHAT_WALLET = false;

(global as any).CREDITCOIN_EXECUTE_SETUP_AUTHORITY = false;
(global as any).CREDITCOIN_NETWORK_LONG_NAME = 'Creditcoin Dev';
(global as any).CREDITCOIN_NETWORK_SHORT_NAME = 'creditcoin_dev';
(global as any).CREDITCOIN_NETWORK_LONG_NAME = 'PoS Devnet';
(global as any).CREDITCOIN_NETWORK_SHORT_NAME = 'creditcoin_pos_devnet';
(global as any).CREDITCOIN_METRICS_BASE = 'http://dev-rpc-creditcoin-rpc-2.centralus.cloudapp.azure.com:9615';
(global as any).CREDITCOIN_REUSE_EXISTING_ADDRESSES = true;

// This is on Goerli, https://goerli.etherscan.io/address/0x80C9A853B906fc4a30A5F9E4982F1F5AC1798cd0
(global as any).CREDITCOIN_CTC_CONTRACT_ADDRESS = '0x80C9A853B906fc4a30A5F9E4982F1F5AC1798cd0';
// This is on Goerli, https://sepolia.etherscan.io/address/0xd2f6CBE058b7233FE5fd1a790A8D85328e3a5d3D
(global as any).CREDITCOIN_CTC_CONTRACT_ADDRESS = '0xd2f6CBE058b7233FE5fd1a790A8D85328e3a5d3D';
// we need a new tx hash every time so we call .burn() in globalSetup()! See ctc-deploy.ts
(global as any).CREDITCOIN_CTC_BURN_TX_HASH = undefined;

Expand Down
6 changes: 5 additions & 1 deletion integration-tests/src/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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) {
Expand Down
9 changes: 4 additions & 5 deletions integration-tests/src/testnetSetup.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -38,8 +38,7 @@ const createWallet = (who: 'lender' | 'borrower') => {
};

const setup = async () => {
(global as any).CREDITCOIN_SWITCH_TO_POS_ALREADY_CALLED = true;
(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;
Expand All @@ -59,8 +58,8 @@ const setup = async () => {
(global as any).CREDITCOIN_METRICS_BASE = 'http://test-rpc-creditcoin-rpc-2.eastus.cloudapp.azure.com:9615';
(global as any).CREDITCOIN_REUSE_EXISTING_ADDRESSES = true;

// This is on Goerli, https://goerli.etherscan.io/address/0x833cc7c2598D80d327767De33B22ac426f4248e2
(global as any).CREDITCOIN_CTC_CONTRACT_ADDRESS = '0x833cc7c2598D80d327767De33B22ac426f4248e2';
// This is on Goerli, https://sepolia.etherscan.io/address/0x47c30768e4c153b40d55b90f58472bb2291971e6
(global as any).CREDITCOIN_CTC_CONTRACT_ADDRESS = '0x47c30768e4c153b40d55b90f58472bb2291971e6';
// we need a new tx hash every time so we call .burn() in globalSetup()! See ctc-deploy.ts
(global as any).CREDITCOIN_CTC_BURN_TX_HASH = undefined;

Expand Down
Loading