diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index faf2cbb86..6fd46d86f 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -35,10 +35,17 @@ 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: https://kuber-govtool.cardanoapi.io + NETWORK: ${{ vars.NETWORK }} + KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }} - name: Upload report if: always() 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 fb601c31b..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") +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) 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):