Skip to content

Commit

Permalink
add tests for create_public_did and set_public_did
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Nov 21, 2019
1 parent c9814af commit 4cfc48a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aries_cloudagent/wallet/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ async def create_local_did(
raise WalletError(str(x_indy))
if metadata:
await self.replace_local_did_metadata(did, metadata)
else:
metadata = {}
return DIDInfo(did, verkey, metadata)

async def get_local_dids(self) -> Sequence[DIDInfo]:
Expand Down
40 changes: 40 additions & 0 deletions aries_cloudagent/wallet/tests/test_basic_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,46 @@ async def test_local_metadata(self, wallet):
self.missing_did, self.test_update_metadata
)

@pytest.mark.asyncio
async def test_create_public_did(self, wallet):
info = await wallet.create_local_did(
self.test_seed, self.test_did, self.test_metadata
)
assert not info.metadata.get("public")

info_public = await wallet.create_public_did()
assert info_public.metadata.get("public")

# test replace
info_replace = await wallet.create_public_did()
assert info_replace.metadata.get("public")
info_check = await wallet.get_local_did(info_public.did)
assert not info_check.metadata.get("public")

@pytest.mark.asyncio
async def test_set_public_did(self, wallet):
info = await wallet.create_local_did(
self.test_seed, self.test_did, self.test_metadata
)
assert not info.metadata.get("public")

with pytest.raises(WalletNotFoundError):
await wallet.set_public_did("55GkHamhTU1ZbTbV2ab9DF")

# test assign
info_same = await wallet.set_public_did(info.did)
assert info_same.did == info.did
assert info_same.metadata.get("public")

info_new = await wallet.create_local_did()
assert info_new.did != info_same.did
assert not info_new.metadata.get("public")

# test replace
info_final = await wallet.set_public_did(info_new.did)
assert info_final.did == info_new.did
assert info_final.metadata.get("public")

@pytest.mark.asyncio
async def test_sign_verify(self, wallet):
info = await wallet.create_local_did(self.test_seed, self.test_did)
Expand Down

0 comments on commit 4cfc48a

Please sign in to comment.