mirror of https://github.com/nucypher/nucypher.git
Use constants for timeout values for reencryption and decryption.
parent
3891bd6bea
commit
4398c63892
|
@ -147,7 +147,7 @@ class DKGOmniscientDecryptionClient(ThresholdDecryptionClient):
|
|||
self,
|
||||
encrypted_requests: Dict[ChecksumAddress, EncryptedThresholdDecryptionRequest],
|
||||
threshold: int,
|
||||
timeout: int = 15,
|
||||
timeout: int = ThresholdDecryptionClient.DEFAULT_DECRYPTION_TIMEOUT,
|
||||
) -> Tuple[
|
||||
Dict[ChecksumAddress, EncryptedThresholdDecryptionResponse],
|
||||
Dict[ChecksumAddress, str],
|
||||
|
@ -221,7 +221,7 @@ class DoomedDecryptionClient(ThresholdDecryptionClient):
|
|||
self,
|
||||
encrypted_requests,
|
||||
threshold: int,
|
||||
timeout: int = 15,
|
||||
timeout: int = ThresholdDecryptionClient.DEFAULT_DECRYPTION_TIMEOUT,
|
||||
) -> Tuple[
|
||||
Dict[ChecksumAddress, EncryptedThresholdDecryptionResponse],
|
||||
Dict[ChecksumAddress, str],
|
||||
|
|
|
@ -510,7 +510,7 @@ class Bob(Character):
|
|||
alice_verifying_key: PublicKey, # KeyFrag signer's key
|
||||
encrypted_treasure_map: EncryptedTreasureMap,
|
||||
publisher_verifying_key: Optional[PublicKey] = None,
|
||||
timeout: int = 10,
|
||||
timeout: int = PRERetrievalClient.DEFAULT_RETRIEVAL_TIMEOUT,
|
||||
**context, # TODO: dont use one context to rule them all
|
||||
) -> List[PolicyMessageKit]:
|
||||
"""
|
||||
|
@ -707,7 +707,7 @@ class Bob(Character):
|
|||
threshold_message_kit: ThresholdMessageKit,
|
||||
context: Optional[dict] = None,
|
||||
ursulas: Optional[List["Ursula"]] = None,
|
||||
decryption_timeout: int = 15,
|
||||
decryption_timeout: int = ThresholdDecryptionClient.DEFAULT_DECRYPTION_TIMEOUT,
|
||||
) -> bytes:
|
||||
ritual_id = self.get_ritual_id_from_public_key(
|
||||
public_key=threshold_message_kit.acp.public_key
|
||||
|
|
|
@ -12,6 +12,8 @@ from nucypher.utilities.concurrency import BatchValueFactory, WorkerPool
|
|||
|
||||
|
||||
class ThresholdDecryptionClient(ThresholdAccessControlClient):
|
||||
DEFAULT_DECRYPTION_TIMEOUT = 15
|
||||
|
||||
class ThresholdDecryptionRequestFailed(Exception):
|
||||
"""Raised when a decryption request returns a non-zero status code."""
|
||||
|
||||
|
@ -27,7 +29,7 @@ class ThresholdDecryptionClient(ThresholdAccessControlClient):
|
|||
self,
|
||||
encrypted_requests: Dict[ChecksumAddress, EncryptedThresholdDecryptionRequest],
|
||||
threshold: int,
|
||||
timeout: int = 15,
|
||||
timeout: int = DEFAULT_DECRYPTION_TIMEOUT,
|
||||
) -> Tuple[
|
||||
Dict[ChecksumAddress, EncryptedThresholdDecryptionResponse],
|
||||
Dict[ChecksumAddress, str],
|
||||
|
|
|
@ -293,7 +293,7 @@ class RestMiddleware:
|
|||
self,
|
||||
ursula: "characters.lawful.Ursula",
|
||||
reencryption_request_bytes: bytes,
|
||||
timeout: int = 10,
|
||||
timeout: int,
|
||||
):
|
||||
response = self.client.post(
|
||||
node_or_sprout=ursula,
|
||||
|
@ -307,7 +307,7 @@ class RestMiddleware:
|
|||
self,
|
||||
ursula: "characters.lawful.Ursula",
|
||||
decryption_request_bytes: bytes,
|
||||
timeout: int = 15,
|
||||
timeout: int,
|
||||
):
|
||||
response = self.client.post(
|
||||
node_or_sprout=ursula,
|
||||
|
|
|
@ -180,6 +180,8 @@ class PRERetrievalClient(ThresholdAccessControlClient):
|
|||
Capsule frag retrieval machinery shared between Bob and Porter.
|
||||
"""
|
||||
|
||||
DEFAULT_RETRIEVAL_TIMEOUT = 10
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
@ -260,7 +262,7 @@ class PRERetrievalClient(ThresholdAccessControlClient):
|
|||
alice_verifying_key: PublicKey, # KeyFrag signer's key
|
||||
bob_encrypting_key: PublicKey, # User's public key (reencryption target)
|
||||
bob_verifying_key: PublicKey,
|
||||
timeout: int = 10,
|
||||
timeout: int = DEFAULT_RETRIEVAL_TIMEOUT,
|
||||
**context,
|
||||
) -> Tuple[List[RetrievalResult], List[RetrievalError]]:
|
||||
ursulas_in_map = treasure_map.destinations.keys()
|
||||
|
|
|
@ -52,5 +52,5 @@ def test_middleware_response_status_code_processing(
|
|||
)
|
||||
with pytest.raises(expected_exception_class):
|
||||
mock_rest_middleware.reencrypt(
|
||||
ursula=ursula, reencryption_request_bytes=b"reencryption_request"
|
||||
ursula=ursula, reencryption_request_bytes=b"reencryption_request", timeout=2
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue