diff --git a/.github/workflows/dapp.yml b/.github/workflows/dapp.yml index da72539ccb..d7cdb7c5c7 100644 --- a/.github/workflows/dapp.yml +++ b/.github/workflows/dapp.yml @@ -51,11 +51,14 @@ jobs: - name: Build Typescript run: npx lerna run build - - name: Run RPC Server - run: npm run integration:prerequisite & + - name: Start the hedera local node + run: npx hedera start -d - - name: Check local node - run: npm run check:node + - name: Stop the local node's relay + run: docker stop json-rpc-relay + + - name: Start the local relay + run: npm run start & - name: Build, Bootstrap & Test the dapp in Docker run: docker-compose up --exit-code-from synpress @@ -70,7 +73,7 @@ jobs: - name: Tar logs if: ${{ always() && !cancelled() }} run: tar cvzf ./logs.tgz ./logs - + - name: Upload logs to GitHub if: ${{ always() && !cancelled() }} uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 diff --git a/.github/workflows/dev-tool-workflow.yml b/.github/workflows/dev-tool-workflow.yml index f7a548aefe..2f1a47d3e0 100644 --- a/.github/workflows/dev-tool-workflow.yml +++ b/.github/workflows/dev-tool-workflow.yml @@ -46,16 +46,18 @@ jobs: - name: Build Typescript run: npx lerna run build - - name: Run RPC Server - run: npm run integration:prerequisite & + - name: Start the hedera local node + run: npx hedera start -d + + - name: Stop the local node's relay + run: docker stop json-rpc-relay + + - name: Start the local relay + run: npm run start & - name: Install dependencies run: cd ${{ inputs.directory }}/ && npm ci - - name: Check local node - run: npm run check:node - timeout-minutes: 8 - - name: Run the tests uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: diff --git a/.github/workflows/postman.yml b/.github/workflows/postman.yml index 9f226990c2..d0d1a6af4f 100644 --- a/.github/workflows/postman.yml +++ b/.github/workflows/postman.yml @@ -10,7 +10,7 @@ on: concurrency: group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true - + jobs: setup-local-hedera: name: Postman Endpoint Tests @@ -46,13 +46,19 @@ jobs: - name: Build Typescript run: npx lerna run build - - name: Run RPC Server - run: npm run integration:prerequisite & + - name: Start the hedera local node + run: npx hedera start -d + + - name: Stop the local node's relay + run: docker stop json-rpc-relay + + - name: Start the local relay + run: npm run start & - name: Install newman run: npm install -g newman - - name: Run the newman script + - name: Run the newman script uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: max_attempts: 10 diff --git a/package.json b/package.json index e03b93f2d7..1aaf95b70f 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,6 @@ "start:docker": "docker run --name hedera-relay -d -p 7546:7546 ${npm_package_name}:latest", "test": "npx lerna run test", "openrpctest": "ts-mocha packages/relay/tests/lib/openrpc.spec.ts --exit", - "integration:prerequisite": "ts-node packages/server/tests/helpers/prerequisite.ts", - "check:node": "ts-node packages/server/tests/helpers/nodeCheck.ts", "bump-version": "SEM_VER=${npm_config_semver} SNAPSHOT=${npm_config_snapshot} node scripts/.bump-version.js", "prepare": "husky install" }, diff --git a/packages/server/package.json b/packages/server/package.json index 77d1033577..f0bd78da49 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,8 +47,7 @@ "compile": "tsc -b tsconfig.json", "acceptancetest": "ts-mocha tests/acceptance/index.spec.ts", "start": "node dist/index.js", - "test": "nyc ts-mocha --recursive ./tests/integration/*.spec.ts --exit", - "integration:prerequisite": "ts-node ./tests/helpers/prerequisite.ts" + "test": "nyc ts-mocha --recursive ./tests/integration/*.spec.ts --exit" }, "nyc": { "check-coverage": false, diff --git a/packages/server/tests/helpers/nodeCheck.ts b/packages/server/tests/helpers/nodeCheck.ts deleted file mode 100644 index 5ec5f63871..0000000000 --- a/packages/server/tests/helpers/nodeCheck.ts +++ /dev/null @@ -1,26 +0,0 @@ -const net = require('net'); - -(async function () { - const supportedEnvs = ['previewnet', 'testnet', 'mainnet']; - const network = process.env.HEDERA_NETWORK || '{}'; - - const isLocalNode = !supportedEnvs.includes(network.toLowerCase()); - if (isLocalNode) { - let nodeStarted = false; - const retries = 10; - while (!nodeStarted && retries >= 0) { - net - .createConnection('5600', '127.0.0.1') - .on('data', function () { - nodeStarted = true; - console.log('Local node has been succefully started!'); - }) - .on('error', (err) => { - console.log(`Waiting for local node, retrying in 15 seconds...`); - }); - - await new Promise((r) => setTimeout(r, 15000)); - } - } - process.exit(0); -})(); diff --git a/packages/server/tests/helpers/prerequisite.ts b/packages/server/tests/helpers/prerequisite.ts deleted file mode 100644 index 1e1b90cb87..0000000000 --- a/packages/server/tests/helpers/prerequisite.ts +++ /dev/null @@ -1,27 +0,0 @@ -import app from '../../src/server'; -import shell from 'shelljs'; -import dotenv from 'dotenv'; -import path from 'path'; - -dotenv.config({ path: path.resolve(__dirname, '../../../.env') }); - -const USE_LOCAL_NODE = process.env.LOCAL_NODE || 'true'; -const LOCAL_RELAY_URL = 'http://localhost:7546'; -const RELAY_URL = process.env.E2E_RELAY_HOST || LOCAL_RELAY_URL; - -(function () { - if (USE_LOCAL_NODE) { - console.log('Installing local node...'); - shell.exec(`npm install @hashgraph/hedera-local -g`); - - console.log('Starting local node...'); - shell.exec(`hedera start -d --verbose=trace`); - console.log('Hedera Hashgraph local node env started'); - } - - if (RELAY_URL === LOCAL_RELAY_URL) { - shell.exec('docker stop json-rpc-relay'); - console.log(`Start relay on port ${process.env.SERVER_PORT}`); - app.listen({ port: process.env.SERVER_PORT }); - } -})(); diff --git a/packages/ws-server/package.json b/packages/ws-server/package.json index bb722521ca..4478d13c4d 100644 --- a/packages/ws-server/package.json +++ b/packages/ws-server/package.json @@ -47,8 +47,7 @@ "compile": "tsc -b tsconfig.json", "acceptancetest": "ts-mocha tests/acceptance/index.spec.ts", "start": "node dist/index.js", - "test:unit": "nyc ts-mocha --recursive './tests/unit/**/*.spec.ts' --exit", - "integration:prerequisite": "ts-node ./tests/helpers/prerequisite.ts" + "test:unit": "nyc ts-mocha --recursive './tests/unit/**/*.spec.ts' --exit" }, "nyc": { "check-coverage": false,