From 303f8eee31521a943a94006178d3f869f55f4fd4 Mon Sep 17 00:00:00 2001 From: Dimitar Manov <99065541+dimitarmanov@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:51:19 +0300 Subject: [PATCH] Test contracts --- .github/workflows/ci-deploy.yaml | 22 +++++++++++++++++----- hardhat/hardhat.config.ts | 6 +++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-deploy.yaml b/.github/workflows/ci-deploy.yaml index 6855188422..497000a3f1 100644 --- a/.github/workflows/ci-deploy.yaml +++ b/.github/workflows/ci-deploy.yaml @@ -39,11 +39,7 @@ jobs: - name: Deploy Contracts working-directory: ./hardhat - run: npx hardhat ignition deploy ./ignition/modules/Lock.ts --network localhost - - - name: Test Contracts - working-directory: ./hardhat - run: npx hardhat test test/Lock.ts --network localhost + run: npx hardhat ignition deploy ./ignition/modules/Lock.ts --network local - name: Autotag id: autotag @@ -78,3 +74,19 @@ jobs: tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-${{ steps.autotag.outputs.tag }} labels: ${{ steps.metadata.outputs.labels }} + - name: Start Geth Devnet + run: | + docker run -it --rm  + -p 8546:8545 + -p 30303:30303 + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.ENVIRONMENT }}-contracts-latest + --dev \ + --http --http.addr 0.0.0.0 + --http.api eth,net,web3,personal + --allow-insecure-unlock + echo "Waiting for Geth JSON-RPC..." + until curl -s http://localhost:8546; do sleep 1; done + + - name: Test Contracts + working-directory: ./hardhat + run: npx hardhat test test/Lock.ts --network localcontracts diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index b2eb00b58a..2e68ec164b 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -4,10 +4,14 @@ import "@nomicfoundation/hardhat-toolbox"; const config: HardhatUserConfig = { solidity: "0.8.28", networks: { - localhost: { + local: { url: "http://127.0.0.1:8545", chainId: 1337 }, + localcontracts: { + url: "http://127.0.0.1:8546", + chainId: 1337 + }, node: { url: "http:127.0.0.1:8545", chainId: 31337