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

Test CI #76

Merged
merged 8 commits into from
Oct 5, 2022
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
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests CI

on:
push:
branches: [main, develop]
pull_request:
workflow_dispatch:

env:
RELAY_IMAGE_TAG: 0.8.0
NETWORK_NODE_IMAGE_TAG: 0.30.0-alpha.2
HAVEGED_IMAGE_TAG: 0.30.0-alpha.2
MIRROR_IMAGE_TAG: 0.64.0

jobs:

tests:

name: Tests

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [ 16.x ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: npm ci

- name: Install Docker Compose
run: |
sudo curl -SL -o /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
sudo chmod +x /usr/local/bin/docker-compose

- name: Prepare the local node
run: |
echo 'hedera.recordStream.compressFilesOnCreation=true' >> node_modules/@hashgraph/hedera-local/compose-network/network-node/data/config/bootstrap.properties
echo 'contracts.chainId=298' >> node_modules/@hashgraph/hedera-local/compose-network/network-node/data/config/bootstrap.properties
sed -i 's/ STREAM_EXTENSION: "rcd"/ STREAM_EXTENSION: "rcd.gz"/' node_modules/@hashgraph/hedera-local/docker-compose.yml

- name: Start the local node
run: npx hedera start -d

- name: Run tests
run: npx hardhat test

- name: Stop the local node
run: npx hedera stop
3 changes: 2 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports = {
url: 'http://localhost:7546',
accounts: [
"0x2e1d968b041d84dd120a5860cee60cd83f9374ef527ca86996317ada3d0d03e7"
]
],
chainId: 298,
}
}
};
15 changes: 7 additions & 8 deletions test/safe-hts-precompile/SafeHTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,27 @@ describe("SafeHTS library tests", function () {
});

const tokenAddressReceipt = await tokenAddressTx.wait();
const {tokenAddress} = tokenAddressReceipt.events.filter(e => e.event === 'tokenCreatedEvent')[0].args;

const tokenAddress = tokenAddressReceipt.events.filter(e => e.event === 'TokenCreated')[0].args[0];
return tokenAddress;
}

it("should be able to get token info", async function () {
const tokenInfoTx = await safeOperationsContract.safeGetTokenInfo(fungibleTokenAddress);
const tokenInfoReceipt = await tokenInfoTx.wait();
const {tokenInfo} = tokenInfoReceipt.events.filter(e => e.event === 'tokenInfoEvent')[0].args;
const tokenInfo = tokenInfoReceipt.events.filter(e => e.event === 'TokenInfoEvent')[0].args[0];

expect(tokenInfo.hedera.name).to.equal("tokenName");
expect(tokenInfo.hedera.symbol).to.equal("tokenSymbol");
expect(tokenInfo.token.name).to.equal("tokenName");
expect(tokenInfo.token.symbol).to.equal("tokenSymbol");
expect(tokenInfo.totalSupply).to.equal(200);
});

it("should be able to get fungible token info", async function () {
const fungibleTokenInfoTx = await safeOperationsContract.safeGetFungibleTokenInfo(fungibleTokenAddress);
const fungibleTokenInfoReceipt = await fungibleTokenInfoTx.wait();
const {fungibleTokenInfo} = fungibleTokenInfoReceipt.events.filter(e => e.event === 'fungibleTokenInfoEvent')[0].args;
const fungibleTokenInfo = fungibleTokenInfoReceipt.events.filter(e => e.event === 'FungibleTokenInfoEvent')[0].args[0];

expect(fungibleTokenInfo.tokenInfo.hedera.name).to.equal("tokenName");
expect(fungibleTokenInfo.tokenInfo.hedera.symbol).to.equal("tokenSymbol");
expect(fungibleTokenInfo.tokenInfo.token.name).to.equal("tokenName");
expect(fungibleTokenInfo.tokenInfo.token.symbol).to.equal("tokenSymbol");
expect(fungibleTokenInfo.tokenInfo.totalSupply).to.equal(200);
expect(fungibleTokenInfo.decimals).to.equal(8);
});
Expand Down