Skip to content

Commit

Permalink
Clean up create revoc logic
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Feb 9, 2024
1 parent a7b60c3 commit 382b8a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions aries_cloudagent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ async def store_revocation_registry_list(self, result: RevListResult):
) from err

async def finish_revocation_list(
self, job_id: str, rev_reg_def_id: str, options: dict = {}
self, job_id: str, rev_reg_def_id: str
):
"""Mark a revocation list as finished."""
async with self.profile.transaction() as txn:
Expand All @@ -512,7 +512,7 @@ async def finish_revocation_list(
)
await txn.commit()

await self.notify(RevListFinishedEvent.with_payload(rev_reg_def_id, options))
await self.notify(RevListFinishedEvent.with_payload(rev_reg_def_id))

async def update_revocation_list(
self,
Expand Down
11 changes: 7 additions & 4 deletions aries_cloudagent/anoncreds/revocation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ async def on_cred_def(self, profile: Profile, event: CredDefFinishedEvent):
async def on_rev_reg_def(self, profile: Profile, event: RevRegDefFinishedEvent):
"""Handle rev reg def finished."""
payload = event.payload
auto_create_revocation = is_author_role(profile) and profile.settings.get(
"endorser.auto_create_rev_reg", False
)

if payload.options.get("support_revocation", False) or auto_create_revocation:
auto_create_revocation = True
if is_author_role(profile):
auto_create_revocation = profile.settings.get(
"endorser.auto_create_rev_reg", False
)

if auto_create_revocation:
revoc = AnonCredsRevocation(profile)
await revoc.upload_tails_file(payload.rev_reg_def)
await revoc.create_and_register_revocation_list(
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/anoncreds/tests/test_revocation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ async def test_on_rev_reg_def_with_support_revoc_option_registers_list(
issuer_id="CsQY9MGeD3CQP4EyuVFo5m",
type="CL_ACCUM",
),
options={
"support_revocation": True,
},
options={},
)
)

Expand Down Expand Up @@ -221,9 +219,11 @@ async def test_on_rev_reg_def_author_and_auto_create_rev_reg(
"create_and_register_revocation_list",
return_value=None,
)
async def test_on_rev_reg_def_no_support_revoc_or_author_and_auto_create(
async def test_on_rev_reg_def_author_and_do_not_auto_create_rev_reg(
self, mock_register, mock_upload
):
self.profile.settings["endorser.author"] = True
self.profile.settings["endorser.auto_create_rev_reg"] = False
event = RevRegDefFinishedEvent(
RevRegDefFinishedPayload(
rev_reg_def_id="rev_reg_def_id",
Expand Down

0 comments on commit 382b8a5

Please sign in to comment.