From 4b6f91548aa7407852d82c66d18ca2e4857f5320 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 15:20:36 +0000 Subject: [PATCH 01/11] feat: enabling e2e tests --- .github/workflows/test-e2e.yaml | 91 +++++++++++++++++++++++++++++++++ .gitmodules | 3 ++ tests/thor-e2e-tests | 1 + 3 files changed, 95 insertions(+) create mode 100644 .github/workflows/test-e2e.yaml create mode 160000 tests/thor-e2e-tests diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml new file mode 100644 index 000000000..579dbd662 --- /dev/null +++ b/.github/workflows/test-e2e.yaml @@ -0,0 +1,91 @@ +name: E2E Tests + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build-docker-image: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and export + uses: docker/build-push-action@v5 + with: + context: . + tags: vechain/thor:${{ github.sha }} + outputs: type=docker,dest=/tmp/vechain-thor.tar + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: vechain-thor-image + path: /tmp/vechain-thor.tar + retention-days: 7 + + run-tests: + runs-on: ubuntu-latest + needs: build-docker-image + env: + THOR_IMAGE: vechain/thor:${{ github.sha }} + name: Run E2E Tests + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: vechain-thor-image + path: /tmp + + - name: Setup Node JS + uses: actions/setup-node@v4 + with: + node-version: '18.x' + + - name: Load image + run: | + docker load --input /tmp/vechain-thor.tar + docker image ls -a + + - name: Run Tests + working-directory: ./tests/thor-e2e-tests + run: | + export THOR_IMAGE=vechain/thor:${{ github.sha }} + yarn install + yarn test:report + + - name: Publish Results + uses: dorny/test-reporter@v1 + id: test-reporter + if: success() || failure() + with: + name: Integration Tests + only-summary: 'false' + list-suites: 'all' + list-tests: 'all' + fail-on-error: 'true' + reporter: 'mocha-json' + path: | + ./tests/thor-e2e-results/results.json + + - name: Echo Report URL + run: | + echo ${{steps.test-reporter.outputs.url_html}} diff --git a/.gitmodules b/.gitmodules index e69de29bb..3441a15eb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests/thor-e2e-tests"] + path = tests/thor-e2e-tests + url = https://github.com/vechain/thor-e2e-tests.git diff --git a/tests/thor-e2e-tests b/tests/thor-e2e-tests new file mode 160000 index 000000000..35227261f --- /dev/null +++ b/tests/thor-e2e-tests @@ -0,0 +1 @@ +Subproject commit 35227261fa3e23bc3140cb95f706c762db2e83a5 From 0f79c07c4f33c8db7932275e394f32602a0d10eb Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 15:29:07 +0000 Subject: [PATCH 02/11] fix: github actions report location --- .github/workflows/test-e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index 579dbd662..68d9846cb 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -84,7 +84,7 @@ jobs: fail-on-error: 'true' reporter: 'mocha-json' path: | - ./tests/thor-e2e-results/results.json + ./results.json - name: Echo Report URL run: | From d2ab612d2fdf7546cec9239c7130cc1936058bbc Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 15:34:57 +0000 Subject: [PATCH 03/11] fix: add debug step to e2e --- .github/workflows/test-e2e.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index 68d9846cb..923c5bb8b 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -72,6 +72,11 @@ jobs: yarn install yarn test:report + - name: Debug + run: | + pwd + ls -la + - name: Publish Results uses: dorny/test-reporter@v1 id: test-reporter From 1a5afe228eca30c26d1155bfa7a8fcbae2b60aea Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 15:39:53 +0000 Subject: [PATCH 04/11] fix: update results path --- .github/workflows/test-e2e.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index 923c5bb8b..39242f163 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -74,8 +74,7 @@ jobs: - name: Debug run: | - pwd - ls -la + ls -la ./tests/thor-e2e-tests - name: Publish Results uses: dorny/test-reporter@v1 @@ -89,7 +88,7 @@ jobs: fail-on-error: 'true' reporter: 'mocha-json' path: | - ./results.json + ./tests/thor-e2e-tests/results.json - name: Echo Report URL run: | From 3ed1791ea8fb854f830a0887233975c1db670982 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 16:26:06 +0000 Subject: [PATCH 05/11] fix: update contributing.md --- .github/CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8f2cb4c9d..84fef578b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -34,7 +34,8 @@ current development landscape. ```bash make test ``` - - **Note:**: Please refer to the [README](https://github.com/vechain/thor/blob/master/README.md) for information on how to start the node and interact with the + - **Note:**: Please refer to the [README](https://github.com/vechain/thor/blob/master/README.md) for information on + how to start the node and interact with the API. 5. Make your changes and commit them with a clear and concise commit message. 6. Push your changes to your forked repository: @@ -57,3 +58,49 @@ current development landscape. - We follow the [Effective Go](https://golang.org/doc/effective_go) guidelines. Please make sure your code is idiomatic and follows the guidelines. + +## Testing + +### Unit Tests + +```bash +make test +``` + +### Unit Tests with Coverage + +```bash +make test-coverage +``` + +### E2E Tests + +Our E2E tests are written in TypeScript, utilizing hardhat contract solidity development tools. Before running the E2E +tests, ensure you have the following prerequisites installed: + +- [Docker](https://docs.docker.com/get-docker/) +- [Node.js](https://nodejs.org/en/download/) +- [Yarn](https://classic.yarnpkg.com/en/docs/install/) +- [Git](https://git-scm.com/downloads) + + +The E2E tests are located in the tests/thor-e2e-tests directory as a submodule. If you haven't initialized the submodule yet, run: + +```bash +git submodule update --init --recursive +``` + +To run the E2E tests, build the Docker image first: + +```bash +docker build -t vechain/thor-e2e . +export THOR_IMAGE=vechain/thor-e2e +``` + +Then, you can run the tests: + +```bash +cd tests/thor-e2e-tests +yarn install +yarn test +``` From ced9285b08f563abb8387de01898b7ba51a4dbe7 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 16:33:00 +0000 Subject: [PATCH 06/11] chore: add .dockerignore --- .dockerignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..85376b5eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +tests +README.md +thorest.png +CODE_OF_CONDUCT.md From 59588d6eba2d6b02963bc4343c478eeddea1426e Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 16:41:49 +0000 Subject: [PATCH 07/11] chore: remove debug step" --- .github/workflows/test-e2e.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index 39242f163..bfd77b637 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -72,10 +72,6 @@ jobs: yarn install yarn test:report - - name: Debug - run: | - ls -la ./tests/thor-e2e-tests - - name: Publish Results uses: dorny/test-reporter@v1 id: test-reporter From 022e5795a5322b3415bdaadc353d4a7c918cdd5f Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Mon, 15 Jan 2024 14:51:02 +0000 Subject: [PATCH 08/11] chore: update tests ref --- tests/thor-e2e-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/thor-e2e-tests b/tests/thor-e2e-tests index 35227261f..c33c98529 160000 --- a/tests/thor-e2e-tests +++ b/tests/thor-e2e-tests @@ -1 +1 @@ -Subproject commit 35227261fa3e23bc3140cb95f706c762db2e83a5 +Subproject commit c33c985298bb70406cdacbd51fce80e6dd50c3d7 From 8dad6bc2de9db7c1d6f4cec9e1f23b4f78842857 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Mon, 15 Jan 2024 16:01:53 +0000 Subject: [PATCH 09/11] fix: update gh actions --- .github/workflows/test-e2e.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index bfd77b637..ada0b11fe 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -70,7 +70,7 @@ jobs: run: | export THOR_IMAGE=vechain/thor:${{ github.sha }} yarn install - yarn test:report + yarn test - name: Publish Results uses: dorny/test-reporter@v1 @@ -82,9 +82,9 @@ jobs: list-suites: 'all' list-tests: 'all' fail-on-error: 'true' - reporter: 'mocha-json' + reporter: "jest-junit" path: | - ./tests/thor-e2e-tests/results.json + ./tests/thor-e2e-tests/junit.xml - name: Echo Report URL run: | From 55d762f4517f0e79c12a6bc48210516465e93fd6 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Mon, 15 Jan 2024 16:16:02 +0000 Subject: [PATCH 10/11] fix: update gh actions --- .github/workflows/test-e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index ada0b11fe..9deed66d5 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -77,7 +77,7 @@ jobs: id: test-reporter if: success() || failure() with: - name: Integration Tests + name: E2E Test Results only-summary: 'false' list-suites: 'all' list-tests: 'all' From 47cf767508e991d30c6ff30afb3f8f3114b788e0 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Mon, 15 Jan 2024 16:25:12 +0000 Subject: [PATCH 11/11] fix: update gh actions --- .github/CONTRIBUTING.md | 2 -- .github/workflows/test-e2e.yaml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 19f73e8a7..7c11002f0 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -109,5 +109,3 @@ cd tests/thor-e2e-tests yarn install yarn test ``` -======= - diff --git a/.github/workflows/test-e2e.yaml b/.github/workflows/test-e2e.yaml index 9deed66d5..b9151fabf 100644 --- a/.github/workflows/test-e2e.yaml +++ b/.github/workflows/test-e2e.yaml @@ -80,7 +80,7 @@ jobs: name: E2E Test Results only-summary: 'false' list-suites: 'all' - list-tests: 'all' + list-tests: 'failed' fail-on-error: 'true' reporter: "jest-junit" path: |