Skip to content

Commit

Permalink
Acceptance test CICD (#120)
Browse files Browse the repository at this point in the history
* More test cases and ethereum transaction start

Add support for Acceptance tests to run in CI/CD flow

- Add a `localAcceptance.env` that provides configurations for local-node runs
- Update package to pull latest npm version of `hedera-local-node`

Co-authored-by: Nana-EC <nana@swirldslabs.com>
  • Loading branch information
Ivo-Yankov and Nana-EC authored May 31, 2022
1 parent c8a0572 commit 7ac4ff8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Acceptance Tests

on:
pull_request:
branches: [ main, release/** ]
push:
branches: [ main, release/** ]
tags: [ v* ]

jobs:
setup-local-hedera:
name: Acceptance Tests
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16

- name: Checkout repo
uses: actions/checkout@v2

- name: Install packages
run: npm ci

- name: Create .env file
run: cp ./packages/server/tests/localAcceptance.env .env

- name: Lerna Bootstrap
run: npm run setup

- name: Install pnpm
run: npm install -g pnpm

- name: Build Typescript
run: npx lerna run build

- name: Run acceptance tests
run: npm run acceptancetest
8 changes: 5 additions & 3 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 packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"pino-pretty": "^7.6.1"
},
"devDependencies": {
"@hashgraph/hedera-local": "^1.0.1",
"@hashgraph/hedera-local": "github:hashgraph/hedera-local-node",
"@koa/cors": "^3.1.0",
"@types/chai": "^4.3.0",
"@types/cors": "^2.8.12",
Expand All @@ -40,7 +40,7 @@
"compile": "tsc -b tsconfig.json",
"acceptancetest": "ts-mocha ./tests/acceptance.spec.ts",
"start": "node dist/index.js",
"test": "nyc ts-mocha --recursive ./tests/*.spec.ts"
"test": "nyc ts-mocha --recursive ./tests/server.spec.ts"
},
"nyc": {
"check-coverage": false,
Expand Down
11 changes: 11 additions & 0 deletions packages/server/tests/acceptance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,17 @@ describe('RPC Server Integration Tests', async function () {
return { executedTimestamp, executedTransactionId };
};

const getRecordResponseDetails = async (resp: TransactionResponse) => {
const record = await resp.getRecord(client);
const nanoString = record.consensusTimestamp.nanos.toString();
const executedTimestamp = `${record.consensusTimestamp.seconds}.${nanoString.padStart(9, '0')}`;
const transactionId = record.transactionId;
const transactionIdNanoString = transactionId.validStart.nanos.toString();
const executedTransactionId = `${transactionId.accountId}@${transactionIdNanoString.padStart(9, '0')}`;
console.log(`executedTimestamp: ${executedTimestamp}, executedTransactionId: ${executedTransactionId}`);
return { executedTimestamp, executedTransactionId };
};

const numberTo0x = (input: number): string => {
return `0x${input.toString(16)}`;
};
Expand Down
7 changes: 7 additions & 0 deletions packages/server/tests/localAcceptance.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
HEDERA_NETWORK={"127.0.0.1:50211":"0.0.3"}
OPERATOR_ID_MAIN=0.0.2
OPERATOR_KEY_MAIN=302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137
CHAIN_ID=0x12a
MIRROR_NODE_URL=http://127.0.0.1:5551
LOCAL_NODE=true
SERVER_PORT=7546

0 comments on commit 7ac4ff8

Please # to comment.