Skip to content

Commit

Permalink
chore: fix example
Browse files Browse the repository at this point in the history
chore: update aptos ports

chore: update dep version

chore: bump version

chore: bump timeout to 10m

chore: add skipAptos and skipCosmos flags

chore: test start the server

chore: add NODE_ENV=ci

chore: update local-dev cosmos version

chore: update alpha 14

debug: gh actions #1

debug: github actions #2

debug: log error in startAll

chore: update axelar-local-dev-cosmos version

chore: bump axelar-local-dev-cosmos version

chore: check if folder exists

chore: run test instead of run start

chore: add send_receive.wasm for testing

chore: update drop connections

chore: bump to 23

chore: add back examples

chore: revert aptos port

chore: update env example
  • Loading branch information
npty committed Dec 7, 2023
1 parent 64691f7 commit 426be7b
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify-cli-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Override config/ci.json
run: |
echo '{"aptos": {"enabled": true}}' > config/ci.json
echo '{"aptos": {"enabled": true},"cosmos": {"enabled": true}}' > config/ci.json
- name: Test
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ aptos-artifacts
.vscode
chain-config/*.json
.aptos
!./**/artifacts/send_receive.wasm
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = {
recursive: true,
timeout: 20000,
timeout: 600000,
slow: 15000,
file: ['examples/tests/checkExamples.js'],
};
7 changes: 7 additions & 0 deletions examples/cosmos/call-contract/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: compile

compile:
docker run --rm -v ./wasm-contract:/code \
--mount type=volume,source="call-contract_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.13
Binary file not shown.
57 changes: 43 additions & 14 deletions examples/tests/checkExamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {
} = require('@axelar-network/axelar-local-dev');
const fs = require('fs-extra');
const { configPath } = require('../../config');
const { config } = require('dotenv');
const { stopAll } = require('@axelar-network/axelar-local-dev-cosmos');

// disable logging
setLogger((...args) => {});
Expand Down Expand Up @@ -47,21 +47,21 @@ describe('Check Examples Execution', function () {
const wallet = getWallet();
const testChains = ['Avalanche', 'Fantom', 'Polygon'];

beforeEach(async () => {
// Remove local-evm8.json before each test to ensure a clean start
if (fs.existsSync(configPath.localEvmChains)) {
fs.unlinkSync(configPath.localEvmChains);
}
describe('EVM Examples', function () {
const allExamples = [...examples];

await start([wallet.address], testChains, { relayInterval: 500 });
});
beforeEach(async () => {
// Remove local-evm.json before each test to ensure a clean start
if (fs.existsSync(configPath.localEvmChains)) {
fs.unlinkSync(configPath.localEvmChains);
}

afterEach(async () => {
await destroyExported(relayers);
});
await start([wallet.address], testChains, { relayInterval: 500, skipCosmos: true, skipAptos: true });
});

describe('EVM Examples', function () {
const allExamples = [...examples];
afterEach(async () => {
await destroyExported(relayers);
});

for (const exampleName of allExamples) {
it(exampleName, async function () {
Expand All @@ -78,6 +78,19 @@ describe('Check Examples Execution', function () {
});

describe('Aptos Examples', function () {
before(async () => {
// Remove local-evm.json before each test to ensure a clean start
if (fs.existsSync(configPath.localEvmChains)) {
fs.unlinkSync(configPath.localEvmChains);
}

await start([wallet.address], testChains, { relayInterval: 500, skipCosmos: true });
});

after(async () => {
await destroyExported(relayers);
});

for (const exampleName of aptosExamples) {
it(exampleName, async function () {
const example = rootRequire(`examples/aptos/${exampleName}/index.js`);
Expand All @@ -91,10 +104,26 @@ describe('Check Examples Execution', function () {
});

describe('Cosmos Examples', function () {
let dropConnections;
beforeEach(async () => {
// Remove local-evm.json before each test to ensure a clean start
if (fs.existsSync(configPath.localEvmChains)) {
fs.unlinkSync(configPath.localEvmChains);
}

dropConnections = await start([wallet.address], ['Ethereum'], { relayInterval: 2000, skipAptos: true });
});

afterEach(async () => {
await destroyExported(relayers);
await stopAll();
await dropConnections();
});

for (const exampleName of cosmosExamples) {
it(exampleName, async function () {
const example = rootRequire(`examples/cosmos/${exampleName}/index.js`);
const chains = getEVMChains('local', testChains);
const chains = getEVMChains('local', ['Ethereum']);

if (example.deploy) await deploy('local', chains, wallet, example);

Expand Down
20 changes: 9 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"dependencies": {
"@axelar-network/axelar-chains-config": "^0.1.0",
"@axelar-network/axelar-gmp-sdk-solidity": "^5.4.0",
"@axelar-network/axelar-local-dev": "^2.2.0-alpha.10",
"@axelar-network/axelar-local-dev-cosmos": "^2.2.0-alpha.10",
"@axelar-network/axelar-local-dev": "^2.2.0-alpha.11",
"@axelar-network/axelar-local-dev-cosmos": "^2.2.0-alpha.23",
"@axelar-network/axelarjs-sdk": "^0.12.8",
"@openzeppelin/contracts": "^4.5.0",
"axios": "^0.27.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/libs/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function executeAptosExample(chains, args, wallet, example) {
});
}

async function executeCosmosExample(chains, args, wallet, example) {
async function executeCosmosExample(_env, chains, args, wallet, example) {
const evmChain = chains.find((chain) => chain.name === example.sourceChain);

evmChain.provider = getDefaultProvider(evmChain.rpc);
Expand Down
30 changes: 27 additions & 3 deletions scripts/libs/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { createAndExport, EvmRelayer, RelayerType } = require('@axelar-network/ax
const { IBCRelayerService, AxelarRelayerService, defaultAxelarChainInfo } = require('@axelar-network/axelar-local-dev-cosmos');
const { enabledAptos, enabledCosmos } = require('./config');
const { configPath } = require('../../config');
const path = require('path');

const evmRelayer = new EvmRelayer();

Expand All @@ -16,18 +17,24 @@ const relayers = { evm: evmRelayer };
* @param {*} chains - chains to start. All chains are started if not specified (Avalanche, Moonbeam, Polygon, Fantom, Ethereum).
*/
async function start(fundAddresses = [], chains = [], options = {}) {
if (enabledAptos) {
// For testing purpose
const { skipAptos, skipCosmos } = options;
const dropConnections = [];

if (!skipAptos && enabledAptos) {
const { AptosRelayer, createAptosNetwork } = require('@axelar-network/axelar-local-dev-aptos');
await initAptos(createAptosNetwork);
relayers.aptos = new AptosRelayer();
evmRelayer.setRelayer(RelayerType.Aptos, relayers.aptos);
}

if (enabledCosmos) {
if (!skipCosmos && enabledCosmos) {
const { startAll } = require('@axelar-network/axelar-local-dev-cosmos');

// Spin up cosmos chains in docker containers
await startAll();
await startAll().catch((e) => {
console.log(e);
});

const ibcRelayer = await IBCRelayerService.create();
// Setup IBC Channels. This command will take a while to complete. (should be around 2-3 mins)
Expand All @@ -44,8 +51,19 @@ async function start(fundAddresses = [], chains = [], options = {}) {

await relayers.wasm.listenForEvents();

dropConnections.push(() => relayers.wasm.stopListening());

await ibcRelayer.runInterval();

dropConnections.push(() => ibcRelayer.stopInterval());

// check if folder is available
const dirname = path.dirname(configPath.localCosmosChains);

if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
}

// write that to cosmos config path
fs.writeFileSync(configPath.localCosmosChains, JSON.stringify(cosmosConfig, null, 2));
}
Expand All @@ -58,6 +76,12 @@ async function start(fundAddresses = [], chains = [], options = {}) {
relayers,
relayInterval: options.relayInterval,
});

return async () => {
for (const dropConnection of dropConnections) {
await dropConnection();
}
};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/runExecute.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ if (exampleName.split('/')[0] === 'evm') {
executeAptosExample(chains, args, wallet, example);
} else if (exampleName.split('/')[0] === 'cosmos') {
const chains = getEVMChains(env);
executeCosmosExample(chains, args, wallet, example);
executeCosmosExample(env, chains, args, wallet, example);
}

0 comments on commit 426be7b

Please sign in to comment.