Skip to content

Commit 7fbd329

Browse files
authored
Merge pull request #2995 from jamshale/feat/2962
Fix issue with requested to revoke before registry creation
2 parents dca3ef7 + 675323d commit 7fbd329

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

aries_cloudagent/ledger/indy_vdr.py

+23
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,29 @@ async def get_revoc_reg_delta(
10921092
) from err
10931093

10941094
response_value = response["data"]["value"]
1095+
accum_to = response_value.get("accum_to")
1096+
1097+
# If accum_to is not present, then the timestamp_to was before the registry
1098+
# was created. In this case, we need to fetch the registry creation timestamp and
1099+
# re-calculate the delta.
1100+
if not accum_to:
1101+
try:
1102+
(_, timestamp) = await self.get_revoc_reg_entry(
1103+
revoc_reg_id, int(time())
1104+
)
1105+
fetch_req = ledger.build_get_revoc_reg_delta_request(
1106+
public_info and public_info.did,
1107+
revoc_reg_id,
1108+
timestamp_from,
1109+
timestamp,
1110+
)
1111+
response = await self._submit(fetch_req, sign_did=public_info)
1112+
response_value = response["data"]["value"]
1113+
except VdrError as err:
1114+
raise LedgerError(
1115+
f"get_revoc_reg_delta failed for revoc_reg_id='{revoc_reg_id}'"
1116+
) from err
1117+
10951118
delta_value = {
10961119
"accum": response_value["accum_to"]["value"]["accum"],
10971120
"issued": response_value.get("issued", []),

aries_cloudagent/ledger/tests/test_indy_vdr.py

+50
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,56 @@ async def test_get_revoc_reg_delta(
972972
1234567890,
973973
)
974974

975+
@pytest.mark.asyncio
976+
async def test_get_revoc_reg_delta_without_accum_to(
977+
self,
978+
ledger: IndyVdrLedger,
979+
):
980+
async with ledger:
981+
reg_id = (
982+
"55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0"
983+
)
984+
ledger.pool_handle.submit_request.side_effect = [
985+
# First call to get_revoc_reg_delta
986+
{
987+
"data": {
988+
"value": {},
989+
"revocRegDefId": reg_id,
990+
},
991+
},
992+
# Get registry with test_get_revoc_reg_entry
993+
{
994+
"data": {
995+
"id": reg_id,
996+
"txnTime": 1234567890,
997+
"value": "...",
998+
"revocRegDefId": reg_id,
999+
},
1000+
},
1001+
# Second call to get_revoc_reg_delta
1002+
{
1003+
"data": {
1004+
"value": {
1005+
"accum_to": {
1006+
"value": {"accum": "ACCUM"},
1007+
"txnTime": 1234567890,
1008+
},
1009+
"issued": [1, 2],
1010+
"revoked": [3, 4],
1011+
},
1012+
"revocRegDefId": reg_id,
1013+
},
1014+
},
1015+
]
1016+
result = await ledger.get_revoc_reg_delta(reg_id)
1017+
assert result == (
1018+
{
1019+
"ver": "1.0",
1020+
"value": {"accum": "ACCUM", "issued": [1, 2], "revoked": [3, 4]},
1021+
},
1022+
1234567890,
1023+
)
1024+
9751025
@pytest.mark.asyncio
9761026
async def test_send_revoc_reg_def(
9771027
self,

0 commit comments

Comments
 (0)