Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with requested to revoke before registry creation #2995

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions aries_cloudagent/ledger/indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,29 @@ async def get_revoc_reg_delta(
) from err

response_value = response["data"]["value"]
accum_to = response_value.get("accum_to")

# If accum_to is not present, then the timestamp_to was before the registry
# was created. In this case, we need to fetch the registry creation timestamp and
# re-calculate the delta.
if not accum_to:
try:
(_, timestamp) = await self.get_revoc_reg_entry(
revoc_reg_id, int(time())
)
fetch_req = ledger.build_get_revoc_reg_delta_request(
public_info and public_info.did,
revoc_reg_id,
timestamp_from,
timestamp,
)
response = await self._submit(fetch_req, sign_did=public_info)
response_value = response["data"]["value"]
except VdrError as err:
raise LedgerError(
f"get_revoc_reg_delta failed for revoc_reg_id='{revoc_reg_id}'"
) from err

delta_value = {
"accum": response_value["accum_to"]["value"]["accum"],
"issued": response_value.get("issued", []),
Expand Down
50 changes: 50 additions & 0 deletions aries_cloudagent/ledger/tests/test_indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,56 @@ async def test_get_revoc_reg_delta(
1234567890,
)

@pytest.mark.asyncio
async def test_get_revoc_reg_delta_without_accum_to(
self,
ledger: IndyVdrLedger,
):
async with ledger:
reg_id = (
"55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0"
)
ledger.pool_handle.submit_request.side_effect = [
# First call to get_revoc_reg_delta
{
"data": {
"value": {},
"revocRegDefId": reg_id,
},
},
# Get registry with test_get_revoc_reg_entry
{
"data": {
"id": reg_id,
"txnTime": 1234567890,
"value": "...",
"revocRegDefId": reg_id,
},
},
# Second call to get_revoc_reg_delta
{
"data": {
"value": {
"accum_to": {
"value": {"accum": "ACCUM"},
"txnTime": 1234567890,
},
"issued": [1, 2],
"revoked": [3, 4],
},
"revocRegDefId": reg_id,
},
},
]
result = await ledger.get_revoc_reg_delta(reg_id)
assert result == (
{
"ver": "1.0",
"value": {"accum": "ACCUM", "issued": [1, 2], "revoked": [3, 4]},
},
1234567890,
)

@pytest.mark.asyncio
async def test_send_revoc_reg_def(
self,
Expand Down