Skip to content

Commit

Permalink
Merge pull request #2995 from jamshale/feat/2962
Browse files Browse the repository at this point in the history
Fix issue with requested to revoke before registry creation
  • Loading branch information
swcurran authored May 28, 2024
2 parents dca3ef7 + 675323d commit 7fbd329
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
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

0 comments on commit 7fbd329

Please sign in to comment.