From 96af13b247d9ca339c6b75cd0c07ecb3fde9caf0 Mon Sep 17 00:00:00 2001 From: ff137 Date: Wed, 11 Dec 2024 18:15:16 +0200 Subject: [PATCH] :art: Clean up constants --- app/routes/revocation.py | 7 ++----- app/services/definitions/credential_definitions.py | 3 +-- app/services/onboarding/util/register_issuer_did.py | 7 ++----- shared/constants.py | 5 +++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/routes/revocation.py b/app/routes/revocation.py index be9f418be..b3398bb41 100644 --- a/app/routes/revocation.py +++ b/app/routes/revocation.py @@ -1,5 +1,4 @@ import asyncio -import os from typing import Optional from aries_cloudcontroller import IssuerCredRevRecord, RevRegWalletUpdatedResult @@ -18,15 +17,13 @@ ) from app.services import revocation_registry from app.util.retry_method import coroutine_with_retry_until_value +from shared import PUBLISH_REVOCATIONS_TIMEOUT from shared.log_config import get_logger logger = get_logger(__name__) router = APIRouter(prefix="/v1/issuer/credentials", tags=["revocation"]) -# Config for /publish-revocations -publish_revocations_timeout = int(os.getenv("PUBLISH_REVOCATIONS_TIMEOUT", "60")) - @router.post("/revoke", summary="Revoke a Credential (if revocable)") async def revoke_credential( @@ -213,7 +210,7 @@ async def publish_revocations( field_name="state", expected_value="transaction_acked", logger=bound_logger, - max_attempts=publish_revocations_timeout, + max_attempts=PUBLISH_REVOCATIONS_TIMEOUT, retry_delay=1, ) except asyncio.TimeoutError as e: diff --git a/app/services/definitions/credential_definitions.py b/app/services/definitions/credential_definitions.py index a54420f0a..9c7d0acf5 100644 --- a/app/services/definitions/credential_definitions.py +++ b/app/services/definitions/credential_definitions.py @@ -12,8 +12,7 @@ from app.util.assert_public_did import assert_public_did from app.util.definitions import credential_definition_from_acapy from app.util.transaction_acked import wait_for_transaction_ack -from shared import REGISTRY_SIZE -from shared.constants import CRED_DEF_ACK_TIMEOUT +from shared import CRED_DEF_ACK_TIMEOUT, REGISTRY_SIZE from shared.log_config import get_logger logger = get_logger(__name__) diff --git a/app/services/onboarding/util/register_issuer_did.py b/app/services/onboarding/util/register_issuer_did.py index 340135b48..06c5aad5a 100644 --- a/app/services/onboarding/util/register_issuer_did.py +++ b/app/services/onboarding/util/register_issuer_did.py @@ -1,5 +1,4 @@ import asyncio -import os from logging import Logger from aries_cloudcontroller import ( @@ -17,9 +16,7 @@ set_endorser_info, set_endorser_role, ) -from shared import ACAPY_ENDORSER_ALIAS - -MAX_ATTEMPTS = int(os.getenv("WAIT_ISSUER_DID_MAX_ATTEMPTS", "30")) +from shared import ACAPY_ENDORSER_ALIAS, ISSUER_DID_ENDORSE_TIMEOUT async def create_connection_with_endorser( @@ -258,7 +255,7 @@ async def wait_transactions_endorsed( issuer_controller: AcaPyClient, issuer_connection_id: str, logger: Logger, - max_attempts: int = MAX_ATTEMPTS, + max_attempts: int = ISSUER_DID_ENDORSE_TIMEOUT, retry_delay: float = 1.0, ) -> None: attempt = 0 diff --git a/shared/constants.py b/shared/constants.py index e36fff6d0..85e186dfb 100644 --- a/shared/constants.py +++ b/shared/constants.py @@ -59,12 +59,13 @@ # client.py TEST_CLIENT_TIMEOUT = int(os.getenv("TEST_CLIENT_TIMEOUT", "300")) -MAX_NUM_RETRIES = int(os.getenv("MAX_NUM_RETRIES", "3")) -# timeout for waiting for registries to be created +# timeout for endorsement events and registry creation CRED_DEF_ACK_TIMEOUT = int(os.getenv("CRED_DEF_ACK_TIMEOUT", "60")) +PUBLISH_REVOCATIONS_TIMEOUT = int(os.getenv("PUBLISH_REVOCATIONS_TIMEOUT", "60")) REGISTRY_CREATION_TIMEOUT = int(os.getenv("REGISTRY_CREATION_TIMEOUT", "60")) REGISTRY_SIZE = int(os.getenv("REGISTRY_SIZE", "32767")) +ISSUER_DID_ENDORSE_TIMEOUT = int(os.getenv("ISSUER_DID_ENDORSE_TIMEOUT", "30")) # NATS NATS_SERVER = os.getenv("NATS_SERVER", "nats://nats:4222")