diff --git a/aries_cloudagent/ledger/indy_vdr.py b/aries_cloudagent/ledger/indy_vdr.py index 1c04677e2d..3e8c2dbb2b 100644 --- a/aries_cloudagent/ledger/indy_vdr.py +++ b/aries_cloudagent/ledger/indy_vdr.py @@ -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", []), diff --git a/aries_cloudagent/ledger/tests/test_indy_vdr.py b/aries_cloudagent/ledger/tests/test_indy_vdr.py index 9b33cff259..98ecc12ced 100644 --- a/aries_cloudagent/ledger/tests/test_indy_vdr.py +++ b/aries_cloudagent/ledger/tests/test_indy_vdr.py @@ -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,