Skip to content

Commit 02b05ec

Browse files
authored
🧪 Test AnonCreds revocation (#1401)
* 🧪 Test AnonCreds revocation * 🧪 Test proof revoked credential for anoncreds * 🧪 Indy/AnonCreds proof types * 🧪 Assert expected error; drop unnecessary test * 🎨 Consistent return types * ✨ Create transaction for endorser * 🔊 Log to debug 422 error * 🧪 Update tests * ✅ Fix unit test * 🐛 Fix iterating txns * ✅ * 🚧 Test with added log * 🎨 Default empty list * 🚧 Test cloudcontroller with `rrid2crid` int fix didx-xyz/aries-cloudcontroller-python#241 * 🎨 Modify expected types * 🐛 Fix iterating None type * 🧪 Add sleep to account for anoncreds not providing transaction id to await acknowledgement * ⏪ Revert test acapy image * ⬆️ Use latest cloudcontroller * ⬆️ Update lock files * 🧪 Increase sleep for revoke check * ✅ Test coverage for empty response * 🧪 Skip broken test * 🎨 Fix fixture name * ⬆️ Update lock files
1 parent 5851c67 commit 02b05ec

File tree

12 files changed

+774
-471
lines changed

12 files changed

+774
-471
lines changed

app/models/issuer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def extract_revoked_info(
133133
) -> Dict[str, Any]:
134134
if isinstance(values, dict) and "txn" in values:
135135
# This is a List of TransactionRecord
136-
txn_list: List[Dict[str, Any]] = values.get("txn")
136+
txn_list: List[Dict[str, Any]] = values.get("txn") or []
137137
cred_rev_ids_published = {}
138138

139139
for txn in txn_list:

app/poetry.lock

+77-88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ python = "~3.12.8"
1313

1414
aiohttp = "~3.11.7"
1515
aiocache = "~0.12.0"
16-
aries-cloudcontroller = "==1.2.1.post20250228"
16+
aries-cloudcontroller = "==1.2.1.post20250319"
1717
base58 = "~2.1.1"
1818
fastapi = "~0.115.10"
1919
httpx = "~0.28.0"

app/routes/revocation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ async def publish_revocations(
197197
bound_logger.debug("No revocations to publish.")
198198
return RevokedResponse()
199199

200-
# TODO The anoncreds response seems to be broken, looks like agent response model not what it's
201-
# supposed to be. Need to investigate further.
202-
endorser_transaction_ids = [txn.transaction_id for txn in result.txn]
200+
endorser_transaction_ids = (
201+
[txn.transaction_id for txn in result.txn] if result.txn else []
202+
)
203203
for endorser_transaction_id in endorser_transaction_ids:
204204
bound_logger.debug(
205205
"Wait for publish complete on transaction id: {}",

app/services/revocation_registry.py

+31-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
IssuerCredRevRecord,
1010
IssuerRevRegRecord,
1111
PublishRevocations,
12+
PublishRevocationsOptions,
13+
PublishRevocationsResultSchemaAnoncreds,
1214
PublishRevocationsSchemaAnoncreds,
1315
RevokeRequest,
1416
RevokeRequestSchemaAnoncreds,
@@ -200,7 +202,7 @@ async def revoke_credential(
200202

201203
async def publish_pending_revocations(
202204
controller: AcaPyClient, revocation_registry_credential_map: Dict[str, List[str]]
203-
) -> TxnOrPublishRevocationsResult:
205+
) -> Optional[TxnOrPublishRevocationsResult]:
204206
"""
205207
Publish pending revocations
206208
@@ -226,7 +228,8 @@ async def publish_pending_revocations(
226228
if wallet_type == "askar-anoncreds":
227229
acapy_call = controller.anoncreds_revocation.publish_revocations
228230
body = PublishRevocationsSchemaAnoncreds(
229-
rrid2crid=revocation_registry_credential_map
231+
rrid2crid=revocation_registry_credential_map,
232+
options=PublishRevocationsOptions(create_transaction_for_endorser=True),
230233
)
231234
else: # wallet_type == "askar":
232235
acapy_call = controller.revocation.publish_revocations
@@ -242,20 +245,37 @@ async def publish_pending_revocations(
242245
f"Failed to publish pending revocations: {e.detail}", e.status_code
243246
) from e
244247

245-
if not result.txn or not result.txn[0].transaction_id:
248+
if isinstance(result, TxnOrPublishRevocationsResult):
249+
if not result.txn or not result.txn[0].transaction_id:
250+
bound_logger.warning(
251+
"Published pending revocations but received no endorser transaction id. Got result: {}",
252+
result,
253+
)
254+
return
255+
256+
bound_logger.debug(
257+
"Successfully published pending Indy revocations. Endorser transaction ids: {}.",
258+
[txn.transaction_id for txn in result.txn],
259+
)
260+
return result
261+
elif isinstance(result, PublishRevocationsResultSchemaAnoncreds):
262+
bound_logger.info(
263+
"Successfully published pending AnonCreds revocations: {}.", result
264+
)
265+
# Cast integer cred_rev_ids to string
266+
rrid2crid = result.rrid2crid if result.rrid2crid else {}
267+
rrid2crid = {k: [str(i) for i in v] for k, v in result.rrid2crid.items()}
268+
return TxnOrPublishRevocationsResult(
269+
rrid2crid=rrid2crid,
270+
txn=None,
271+
)
272+
else:
246273
bound_logger.warning(
247-
"Published pending revocations but received no endorser transaction id. Got result: {}",
274+
"Unexpected response from publish_revocations: `{}`. Perhaps empty publish request?",
248275
result,
249276
)
250277
return
251278

252-
endorse_transaction_ids = [txn.transaction_id for txn in result.txn]
253-
bound_logger.debug(
254-
"Successfully published pending revocations. Endorser transaction ids: {}.",
255-
endorse_transaction_ids,
256-
)
257-
return result
258-
259279

260280
async def clear_pending_revocations(
261281
controller: AcaPyClient, revocation_registry_credential_map: Dict[str, List[str]]

0 commit comments

Comments
 (0)