Skip to content

Commit

Permalink
chore: fix aptos test and update axelar-cgp-aptos version (#70)
Browse files Browse the repository at this point in the history
* chore: use tx.success instead of comparing string from vm_status

* chore: check gateway if gateway is deployed

* 1.3.2-alpha.1

* chore: fix aptos test

* chore: bump to 1.3.2-alpha.2

* chore: remove build-aptos from build script

* chore: update test workflow

chore: move aptos download in workflow to the top

chore: update publish to npm workflow

chore: remove test.js

chore: merge jobs in workflow

chore: adjust jest timeout

chore: formatting

chore: test running ga

chore: move running aptos to the same step

chore: redirect all outputs for nohup command

chore: move aptos server running

chore: revert workflow

* chore: update code format

* 1.4.1

* chore: cache node_modules
  • Loading branch information
npty authored Mar 24, 2023
1 parent 9381301 commit f55eee8
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 502 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "publish to npm"
name: "Publish to NPM"

on:
workflow_dispatch:
Expand All @@ -7,15 +7,20 @@ on:

jobs:
publish-to-npm:
name: "Publish to npm"
name: "Publish to NPM"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: npm install
- name: Cache node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run build
- run: npm publish
env:
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ jobs:
matrix:
os: [ubuntu-22.04]
arch: [amd64]

steps:
- name: Download 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
chmod +x aptos
cp aptos /usr/local/bin
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Cache node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install
run: |
npm ci
- name: Build
run: |
npm run build
npm run build-aptos
- name: Test
run: |
nohup sh -c "aptos node run-local-testnet --with-faucet" > nohup.out 2> nohup.err < /dev/null &
sleep 10
npm run test
86 changes: 31 additions & 55 deletions package-lock.json

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

14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@axelar-network/axelar-local-dev",
"version": "1.4.0",
"version": "1.4.1",
"description": "",
"main": "dist/index.js",
"scripts": {
"contract-test": "npx hardhat test",
"test": "jest",
"build-ts": "rm -rf dist && tsc",
"build-contract": "rm -rf src/artifacts && hardhat compile && mv artifacts src/artifacts",
"build-aptos": "",
"build-near": "cd ./src/near/contracts/test/near-axelar-contract-call-example && ./build.sh",
"copy-near-wasm": "cp ./node_modules/@axelar-network/axelar-cgp-near/dist/axelar_cgp_near.wasm src/near/contracts/ && mkdir -p dist/near/contracts && cp -r src/near/contracts/axelar_cgp_near.wasm dist/near/contracts",
"build": "run-s build-contract build-aptos build-near build-ts copy-near-wasm",
"build": "run-s build-contract build-near build-ts copy-near-wasm",
"build-aptos": "bash ./aptos/build.sh",
"prepare": "run-s build",
"lint": "solhint 'src/contracts/**/*.sol' && eslint 'test/**/*.js'",
"prettier": "prettier --write 'src/contracts/**/*.sol' 'test/**/*.js' 'src/**/*.ts'"
Expand All @@ -30,12 +30,14 @@
"url": "https://github.com/axelarnetwork/axelar-local-dev/issues"
},
"homepage": "https://github.com/axelarnetwork/axelar-local-dev#readme",
"files": ["dist"],
"files": [
"dist"
],
"dependencies": {
"@axelar-network/axelar-cgp-aptos": "^1.0.3",
"@axelar-network/axelar-cgp-aptos": "^1.0.4",
"@axelar-network/axelar-cgp-near": "^1.0.0",
"@axelar-network/axelar-cgp-solidity": "github:axelarnetwork/axelar-cgp-solidity#feat/forecaller-service",
"@axelar-network/axelar-gmp-sdk-solidity": "^3.2.1",
"@axelar-network/axelar-cgp-near": "^1.0.0",
"aptos": "^1.3.16",
"ethers": "^5.6.5",
"fs-extra": "^10.1.0",
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/aptos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ import path from 'path';
import { ethers } from 'ethers';
const { keccak256, toUtf8Bytes } = ethers.utils;

describe.skip('aptos', () => {
describe('aptos', () => {
jest.setTimeout(60000);
let client: any;

it('should be able to deploy axelar framework modules', async () => {
beforeEach(async () => {
client = await createAptosNetwork();
});

it('should be able to call approve_contract_call', async () => {
const commandId = new HexString('0x350f78556f96ae42254e3a639bf1808695ada7509fcbce72217e477664ec4d7b').toUint8Array();
const payloadHash = new HexString('0x3202c028a4832bd0c3a59e1eee55d53a225f0a94cee17b16183eed85265c48cb').toUint8Array();
const payloadHash = ethers.utils.randomBytes(32);
const args = [
'ethereum',
'0xD62F0cF0801FAC878F66ebF316AB42DED01F25D8',
'0x8ac1b8ff9583ac8e661c7f0ee462698c57bb7fc454f587e3fa25a57f9406acc0::hello_world',
];
const tx = await client.approveContractCall(commandId, args[0], args[1], args[2], payloadHash);
const tx = await client.approveContractCall(ethers.utils.randomBytes(32), args[0], args[1], args[2], payloadHash);
expect(tx.success).toBeTruthy();
});

it('should be able to call validate_contract_call', async () => {
const compiledModules = ['hello_world.mv'];
const modulePath = '../aptos/modules/test/build/HelloWorld';
const modulePath = '../../aptos/modules/test/build/HelloWorld';
const packageMetadata = fs.readFileSync(path.join(__dirname, modulePath, 'package-metadata.bcs'));
const moduleDatas = compiledModules.map((module) => {
return fs.readFileSync(path.join(__dirname, modulePath, 'bytecode_modules', module));
Expand All @@ -41,7 +41,7 @@ describe.skip('aptos', () => {
console.log(`Error: ${pubTx.vm_status}`);
}

const commandId = new HexString('0x350f78556f96ae42254e3a639bf1808695ada7509fcbce72217e477664ec4163').toUint8Array();
const commandId = ethers.utils.randomBytes(32);
const toSend = 'Hello Test World!';
const payload = toUtf8Bytes(toSend);
const payloadHash = new HexString(keccak256(payload)).toUint8Array();
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/forking.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface NetworkUsdc extends Network {
}

describe("forking", () => {
jest.setTimeout(600000);
jest.setTimeout(1200000);

afterEach(async () => {
await stopAll();
Expand Down
Loading

0 comments on commit f55eee8

Please sign in to comment.