Skip to content

Commit

Permalink
chore: refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Jul 8, 2024
1 parent 078ff52 commit fc13407
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 89 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test-aptos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run Tests for Aptos

on: pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
arch: [amd64]
steps:
- name: Download and Install Aptos Binary
run: |
wget --no-check-certificate https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v1.0.4/aptos-cli-1.0.4-Ubuntu-22.04-x86_64.zip
unzip aptos-cli-1.0.4-Ubuntu-22.04-x86_64.zip
sudo mv aptos /usr/local/bin
- name: Cleanup
run: rm -rf target aptos-cli-1.0.4-Ubuntu-22.04-x86_64.zip

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16

- name: Checkout code
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build:aptos

- name: Test
timeout-minutes: 15
run: |
nohup sh -c "aptos node run-local-testnet --with-faucet" > nohup.out 2> nohup.err < /dev/null &
nohup sh -c "anvil -p 8545 > /dev/null 2>&1" < /dev/null &
sleep 30
npm run test:aptos
40 changes: 40 additions & 0 deletions .github/workflows/test-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run Tests for Core
on: pull_request

jobs:
test-core:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["16.x", "18.x", "20.x"]
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Checkout code
uses: actions/checkout@v4

- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Build
run: npm run build:core

- name: Test
timeout-minutes: 15
run: |
nohup sh -c "anvil -p 8545 > /dev/null 2>&1" < /dev/null &
nohup sh -c "anvil -p 8546 > /dev/null 2>&1" < /dev/null &
sleep 5
npm run test:core
58 changes: 58 additions & 0 deletions .github/workflows/test-multiversex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run Tests for MultiVersX

on: pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
arch: [amd64]
services:
elasticsearch:
image: "docker.elastic.co/elasticsearch/elasticsearch:8.12.0"
env:
discovery.type: single-node
xpack.security.enabled: false
ports:
- "9200:9200"
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout code
uses: actions/checkout@v4

- name: Download and Install Multiversx Binary
run: |
pip3 install multiversx-sdk-cli==v9.3.1
mxpy localnet setup
cp -rf ./packages/axelar-local-dev-multiversx/external.toml ./localnet/validator00/config
cp -rf ./packages/axelar-local-dev-multiversx/external.toml ./localnet/validator01/config
cp -rf ./packages/axelar-local-dev-multiversx/external.toml ./localnet/validator02/config
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build:multiversx

- name: Test
timeout-minutes: 15
run: |
nohup sh -c "mxpy localnet start" > nohup.out 2> nohup.err < /dev/null &
nohup sh -c "anvil -p 8545 > /dev/null 2>&1" < /dev/null &
sleep 30
npm run test:multiversx
55 changes: 55 additions & 0 deletions .github/workflows/test-sui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Tests for Sui

on: pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
arch: [amd64]
steps:
- name: Setup Dependencies for Sui Binary
run: sudo apt-get update && sudo apt-get install -y libpq-dev

- name: Download and Install Sui Binary
run: |
wget https://github.com/MystenLabs/sui/releases/download/mainnet-v1.11.2/sui-mainnet-v1.11.2-ubuntu-x86_64.tgz
tar -xvf sui-mainnet-v1.11.2-ubuntu-x86_64.tgz
sudo mv ./target/release/sui-test-validator-ubuntu-x86_64 /usr/local/bin/sui-test-validator
sudo mv ./target/release/sui-ubuntu-x86_64 /usr/local/bin/sui
- name: Cleanup
run: rm -rf target aptos-cli-1.0.4-Ubuntu-22.04-x86_64.zip sui-devnet-v1.7.0-ubuntu-x86_64.tgz

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout code
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Test
timeout-minutes: 15
run: |
nohup sh -c "sui-test-validator" > nohup.out 2> nohup.err < /dev/null &
nohup sh -c "anvil -p 8545" > anvil1.out 2>&1 &
sleep 30
npm run test:sui
81 changes: 0 additions & 81 deletions .github/workflows/tests.yml

This file was deleted.

6 changes: 3 additions & 3 deletions packages/axelar-local-dev/src/__tests__/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ describe('export', () => {
chains: [
{
name: 'Ethereum',
rpcUrl: 'http://localhost:8545',
rpcUrl: process.env.EVM_NODE_1 || 'http://127.0.0.1:8545',
},
{
name: 'Avalanche',
rpcUrl: 'http://localhost:8546',
rpcUrl: process.env.EVM_NODE_2 || 'http://127.0.0.1:8546',
},
],
})) as Network[];
Expand All @@ -155,7 +155,7 @@ describe('export', () => {
});

// Note: This test is expecting the host to run a local blockchain on port 8545 and 8546.
it('should be able to relay tokens from chain A to chain B', async () => {
it.only('should be able to relay tokens from chain A to chain B', async () => {
const contract1 = await deployContract(srcOwner, ExecuteWithToken, [chain1.gateway.address, chain1.gasService.address]).then(
(contract) => ExecuteWithTokenFactory.connect(contract.address, srcOwner)
);
Expand Down
4 changes: 2 additions & 2 deletions packages/axelar-local-dev/src/__tests__/network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Network', () => {
await createNetwork({
port,
});
network = await getNetwork(`http://localhost:${port}`);
network = await getNetwork(`http://127.0.0.1:${port}`);
validateNetwork(network);
});

Expand All @@ -74,7 +74,7 @@ describe('Network', () => {
logging: { quiet: true },
});
await server.listen(port);
network = await setupNetwork(`http://localhost:${port}`, {
network = await setupNetwork(`http://127.0.0.1:${port}`, {
ownerKey: new Wallet(accounts[0].secretKey),
});
validateNetwork(network);
Expand Down
4 changes: 2 additions & 2 deletions packages/axelar-local-dev/src/exportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function createAndExport(options: CreateLocalOptions = {}) {
});
const testnet = (testnetInfo as any)[name];
const info = chain.getCloneInfo() as any;
info.rpc = `http://localhost:${_options.port}/${i}`;
info.rpc = `http://127.0.0.1:${_options.port}/${i}`;
(info.tokenName = testnet?.tokenName), (info.tokenSymbol = testnet?.tokenSymbol), localChains.push(info);
const [user] = chain.userWallets;
for (const account of _options.accountsToFund) {
Expand Down Expand Up @@ -177,7 +177,7 @@ export async function forkAndExport(options: CloneLocalOptions = {}) {
for (const chain of chains) {
const network = await forkNetwork(chain, _options.networkOptions);
const info = network.getCloneInfo() as any;
info.rpc = `http://localhost:${options.port}/${i}`;
info.rpc = `http://127.0.0.1:${options.port}/${i}`;
(info.tokenName = chain?.tokenName), (info.tokenSymbol = chain?.tokenSymbol), chains_local.push(info);
const [user] = network.userWallets;
for (const account of _options.accountsToFund) {
Expand Down
2 changes: 1 addition & 1 deletion packages/axelar-local-dev/src/networkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,5 @@ export function getDepositAddress(
};
return address;
}
return httpGet(`http:/localhost:${port}/getDepositAddress/${from}/${to}/${destinationAddress}/${alias}`);
return httpGet(`http:/127.0.0.1:${port}/getDepositAddress/${from}/${to}/${destinationAddress}/${alias}`);
}

0 comments on commit fc13407

Please sign in to comment.