Skip to content

Commit

Permalink
set rev reg state to push busted active rev reg to full
Browse files Browse the repository at this point in the history
Signed-off-by: sklump <[email protected]>
  • Loading branch information
sklump committed Sep 4, 2020
1 parent a2e1e8b commit 403880d
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 131 deletions.
10 changes: 8 additions & 2 deletions aries_cloudagent/protocols/issue_credential/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,10 @@ async def issue_credential(
)

# Make the current registry full
await active_reg.mark_full(self.context)
await active_reg.set_state(
self.context,
IssuerRevRegRecord.STATE_FULL,
)

except IssuerRevocationRegistryFullError:
active_rev_regs = await IssuerRevRegRecord.query_by_cred_def_id(
Expand Down Expand Up @@ -620,7 +623,10 @@ async def issue_credential(
retries=retries - 1,
)
else:
await active_reg.mark_full(self.context)
await active_reg.set_state(
self.context,
IssuerRevRegRecord.STATE_FULL,
)
raise

cred_ex_record.credential = json.loads(credential_json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ async def test_issue_credential(self):
max_creds=1000,
)
),
mark_full=async_mock.CoroutineMock(),
set_state=async_mock.CoroutineMock(),
revoc_reg_id=REV_REG_ID,
save=async_mock.CoroutineMock(),
publish_registry_entry=async_mock.CoroutineMock(),
Expand Down Expand Up @@ -1120,7 +1120,7 @@ async def test_issue_credential_rr_full(self):
)
),
revoc_reg_id=REV_REG_ID,
mark_full=async_mock.CoroutineMock(),
set_state=async_mock.CoroutineMock(),
)
]
)
Expand Down Expand Up @@ -1182,7 +1182,7 @@ async def test_issue_credential_rr_full_rr_staged_retry(self):
)
),
revoc_reg_id=REV_REG_ID,
mark_full=async_mock.CoroutineMock(),
set_state=async_mock.CoroutineMock(),
)
]

Expand All @@ -1196,7 +1196,7 @@ async def test_issue_credential_rr_full_rr_staged_retry(self):
)
),
revoc_reg_id=REV_REG_ID,
mark_full=async_mock.CoroutineMock(),
set_state=async_mock.CoroutineMock(),
)
]

Expand All @@ -1209,7 +1209,7 @@ async def test_issue_credential_rr_full_rr_staged_retry(self):
)
),
revoc_reg_id=REV_REG_ID,
mark_full=async_mock.CoroutineMock(),
set_state=async_mock.CoroutineMock(),
state="published",
save=async_mock.CoroutineMock(),
publish_registry_entry=async_mock.CoroutineMock(),
Expand Down
90 changes: 0 additions & 90 deletions aries_cloudagent/revocation/models/cred_rev_info_record.py

This file was deleted.

10 changes: 5 additions & 5 deletions aries_cloudagent/revocation/models/issuer_rev_reg_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Meta:
STATE_PUBLISHED = "published" # definition published
STATE_STAGED = "staged"
STATE_ACTIVE = "active" # first entry published
STATE_FULL = "full"
STATE_FULL = "full" # includes corrupt, out of sync, unusable

def __init__(
self,
Expand Down Expand Up @@ -369,10 +369,10 @@ async def retrieve_by_revoc_reg_id(
tag_filter = {"revoc_reg_id": revoc_reg_id}
return await cls.retrieve_by_tag_filter(context, tag_filter)

async def mark_full(self, context: InjectionContext):
"""Change the registry state to full."""
self.state = IssuerRevRegRecord.STATE_FULL
await self.save(context, reason="Marked full")
async def set_state(self, context: InjectionContext, state: str = None):
"""Change the registry state (default full)."""
self.state = state or IssuerRevRegRecord.STATE_FULL
await self.save(context, reason=f"Marked {self.state}")

def __eq__(self, other: Any) -> bool:
"""Comparison between records."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def test_generate_registry_etc(self):
)
assert retrieved.revoc_reg_id == rec.revoc_reg_id

await rec.mark_full(self.context)
await rec.set_state(self.context)
assert rec.state == IssuerRevRegRecord.STATE_FULL

data = rec.serialize()
Expand Down
Loading

0 comments on commit 403880d

Please sign in to comment.