From ca8e7fc65591e0bbc018f6d969fac4155370480d Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 4 Dec 2024 12:07:36 +0545 Subject: [PATCH 1/5] chore: update proposal.details type and add additional field types --- tests/govtool-backend/models/TestData.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/govtool-backend/models/TestData.py b/tests/govtool-backend/models/TestData.py index e4eb7e3ec..3f89f4149 100644 --- a/tests/govtool-backend/models/TestData.py +++ b/tests/govtool-backend/models/TestData.py @@ -18,13 +18,14 @@ class Proposal(TypedDict): txHash: str index: int type: str - details: Optional[dict] + details: Optional[dict] | Optional[list] expiryDate: str expiryEpochNo: int createdDate: str createdEpochNo: int url: str metadataHash: str + protocolParams: Optional[dict] title: Optional[str] abstract: Optional[str] motivation: Optional[str] @@ -38,6 +39,8 @@ class Proposal(TypedDict): poolYesVotes: int poolNoVotes: int poolAbstainVotes: int + prevGovActionIndex: Optional[int] + prevGovActionTxHash: Optional[str] class Drep(TypedDict): From 739c227531f9359fbeb30a7c772cd3381b73ecca Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 4 Dec 2024 12:27:41 +0545 Subject: [PATCH 2/5] chore: use kuber api url from github vars --- .github/workflows/test_backend.yml | 2 +- tests/govtool-backend/config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index faf2cbb86..7d2ebdf6d 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -38,7 +38,7 @@ jobs: env: BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }} FAUCET_API_KEY: ${{ secrets.FAUCET_API_KEY }} - KUBER_API_URL: https://kuber-govtool.cardanoapi.io + KUBER_API_URL: ${{ vars.KUBER_API_URL }} - name: Upload report if: always() diff --git a/tests/govtool-backend/config.py b/tests/govtool-backend/config.py index fb601c31b..2832c42df 100644 --- a/tests/govtool-backend/config.py +++ b/tests/govtool-backend/config.py @@ -11,5 +11,5 @@ RECORD_METRICS_API = os.getenv("RECORD_METRICS_API") METRICS_API_SECRET = os.getenv("METRICS_API_SECRET") -KUBER_API_URL = os.getenv("KUBER_API_URL") +KUBER_API_URL = os.getenv("KUBER_API_URL", "https://preview.kuber.cardanoapi.io") KUBER_API_KEY = os.getenv("KUBER_API_KEY") From 9da2cde27180f3b8951245f2e931594635c0f6fb Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 4 Dec 2024 12:35:59 +0545 Subject: [PATCH 3/5] chore: add missing kuber api key env on backend test workflow --- .github/workflows/test_backend.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 7d2ebdf6d..e13660cc9 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -39,6 +39,7 @@ jobs: BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }} FAUCET_API_KEY: ${{ secrets.FAUCET_API_KEY }} KUBER_API_URL: ${{ vars.KUBER_API_URL }} + KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }} - name: Upload report if: always() From 6e04854a1ac195ad3ef813f634642f13257d4f40 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 4 Dec 2024 13:53:33 +0545 Subject: [PATCH 4/5] chore: set kuber api url and faucet url based on network --- tests/govtool-backend/.env.example | 3 ++- tests/govtool-backend/config.py | 4 +++- tests/govtool-backend/lib/faucet_api.py | 5 +++-- tests/govtool-backend/lib/kuber_api.py | 6 ++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/govtool-backend/.env.example b/tests/govtool-backend/.env.example index 3bed52954..7e492cd11 100644 --- a/tests/govtool-backend/.env.example +++ b/tests/govtool-backend/.env.example @@ -5,4 +5,5 @@ METRICS_API_SECRET= `api_secret` # required for setup KUBER_API_URL = "https://kuber-govtool.cardanoapi.io" KUBER_API_KEY = "" # optional -FAUCET_API_KEY= """ \ No newline at end of file +FAUCET_API_KEY= """ +NETWORK= preview \ No newline at end of file diff --git a/tests/govtool-backend/config.py b/tests/govtool-backend/config.py index 2832c42df..e40af8b6d 100644 --- a/tests/govtool-backend/config.py +++ b/tests/govtool-backend/config.py @@ -11,5 +11,7 @@ RECORD_METRICS_API = os.getenv("RECORD_METRICS_API") METRICS_API_SECRET = os.getenv("METRICS_API_SECRET") -KUBER_API_URL = os.getenv("KUBER_API_URL", "https://preview.kuber.cardanoapi.io") +KUBER_API_URL = f'https://{os.getenv("NETWORK","preview")}.kuber.cardanoapi.io' KUBER_API_KEY = os.getenv("KUBER_API_KEY") +FAUCET_API_URL = f'https://faucet.${os.getenv("NETWORK","preview")}.world.dev.cardano.org' +FACUET_API_KEY = os.getenv("FAUCET_API_KEY") diff --git a/tests/govtool-backend/lib/faucet_api.py b/tests/govtool-backend/lib/faucet_api.py index ed0150390..b6c63c9de 100644 --- a/tests/govtool-backend/lib/faucet_api.py +++ b/tests/govtool-backend/lib/faucet_api.py @@ -1,3 +1,4 @@ +from config import FAUCET_API_URL,FACUET_API_KEY import os from typing import TypedDict @@ -21,8 +22,8 @@ def __init__(self, api_key: str, base_url: str = "https://faucet.sanchonet.world @staticmethod def from_env(): - api_key = os.getenv("FAUCET_API_KEY") - base_url = os.getenv("FAUCET_API_URL", "https://faucet.sanchonet.world.dev.cardano.org") + api_key = FACUET_API_KEY + base_url = FAUCET_API_URL if not api_key: raise ValueError("FAUCET_API_KEY environment variable not set.") return CardanoFaucet(api_key, base_url) diff --git a/tests/govtool-backend/lib/kuber_api.py b/tests/govtool-backend/lib/kuber_api.py index d70fedca2..788701d12 100644 --- a/tests/govtool-backend/lib/kuber_api.py +++ b/tests/govtool-backend/lib/kuber_api.py @@ -1,4 +1,5 @@ import json +from config import KUBER_API_KEY,KUBER_API_URL import sys import time from typing import Any, Optional @@ -69,11 +70,12 @@ def wait_for_txout(self, txin: str, timeout=400, log: bool = False): @staticmethod def from_env() -> "KuberApi": - api_url = os.environ.get("KUBER_API_URL") + api_url = KUBER_API_URL + print(f"KUBER_API_URL: {api_url}") if api_url is not None: api_url = api_url[:-1] if api_url.endswith("/") else api_url print(f"KUBER_API_URL: {api_url}") - api_key = os.environ.get("KUBER_API_KEY") + api_key = KUBER_API_KEY return KuberApi(api_url, api_key) else: print("KUBER_API_URL environment variable is not set.", file=sys.stderr) From fcf3cf071640b9f9f29475502e72742c8b73b528 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 4 Dec 2024 13:54:10 +0545 Subject: [PATCH 5/5] chore: use faucet api key based on network --- .github/workflows/test_backend.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index e13660cc9..6fd46d86f 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -35,10 +35,16 @@ jobs: pip install -r requirements.txt python ./setup.py python -m pytest --alluredir allure-results + if [[ "${{ env.NETWORK }}" == "preprod" ]]; then + echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREPROD }}" >> $GITHUB_ENV + elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then + echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_SANCHONET }}" >> $GITHUB_ENV + else + echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREVIEW }}" >> $GITHUB_ENV + fi env: BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }} - FAUCET_API_KEY: ${{ secrets.FAUCET_API_KEY }} - KUBER_API_URL: ${{ vars.KUBER_API_URL }} + NETWORK: ${{ vars.NETWORK }} KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }} - name: Upload report