Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when removing a wallet on askar-profile #1518

Merged
merged 8 commits into from
Dec 1, 2021

Conversation

baegjae
Copy link
Contributor

@baegjae baegjae commented Nov 25, 2021

This PR fixes error when removing a wallet on askar-profile

Environment

askar-profile

Problem

Error occurred when removing a wallet.

Fix

Unlike other options, in askar-profile, the profiles of sub wallet are not stored in self._instances.
However, current code always try to delete the profile in self._instances when removing a wallet.
This PR resolves the above problem.

Thanks!

Signed-off-by: Ethan Sung [email protected]

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2021

Codecov Report

Merging #1518 (56dc521) into main (04a0264) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1518   +/-   ##
=======================================
  Coverage   95.70%   95.70%           
=======================================
  Files         521      521           
  Lines       32160    32165    +5     
=======================================
+ Hits        30779    30784    +5     
  Misses       1381     1381           

Copy link
Contributor

@ianco ianco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. There are two separate instances of the multitenant manager that derive from base - one is MultitenantManager and one is AskarProfileMultitenantManager. Both add loaded sub-wallets to the self._instances array.

I suspect that the wrong instance type of the manager is getting loaded when running in askar mode (i.e. MultitenantManager instead of AskarProfileMultitenantManager) and that's why self._instances seems to be missing the sub-wallet profile.

@ianco
Copy link
Contributor

ianco commented Nov 25, 2021

@baegjae
Copy link
Contributor Author

baegjae commented Nov 26, 2021

@ianco
Thanks for the comment.
I tested with three cases.

Case 1. indy - basic
--wallet-type indy, --multitenancy-config Omit

Case 2. askar - basic
--wallet-type askar, --multitenancy-config Omit

Case 3. askar - askar-profile
--wallet-type askar, --multitenancy-config {"wallet_type":"askar-profile", "wallet_name":"askar-profile-name"}

Case 1 and 2 use get_wallet_profile of MultitenantManager.
In get_wallet_profile, sub-wallets are added to self._instances.

Case 3 uses get_wallet_profile of AskarProfileMultitenantManager.
In get_wallet_profile, sub-wallets are added to multitenant_wallet.
In here, self._instances contains a single profile with key multitenant_wallet_name.
https://github.com/hyperledger/aries-cloudagent-python/blob/main/aries_cloudagent/multitenant/askar_profile_manager.py#L45

The single profile (multitenant_wallet) is used to store sub-wallets and to get the template of a sub-wallet context.

This PR handles the Case 3.

Thanks!

@baegjae baegjae requested a review from ianco November 26, 2021 04:50
@ianco
Copy link
Contributor

ianco commented Nov 26, 2021

Hi @baegjae thanks for the info!

Since the behaviour of the MultitenantManager and AskarProfileMultitenantManager is different, I suggest to refactor the code to move the del self._instances[wallet_id] operation into the MultitenantManager class. (I don't like base classes having dependencies on their sub-classes).

Maybe define a virtual method in the base class called cleanup_local_wallet_instances() (or something like that) and in the MultitenantManager sub-class it can delete from the local self._instances and in the Askar sub-class it can be a no-op

@baegjae
Copy link
Contributor Author

baegjae commented Nov 29, 2021

Hi @ianco
I agree your comment.
I added a virtual method named remove_wallet_profile.
In MultitenantManager, the method removes the profile from self._instances and removes the profile.
In AskarProfileMultitenantManager, the method only removes the profile.

Also, I updated and added the unit test for this.

Thanks!

@ianco ianco enabled auto-merge December 1, 2021 19:46
@ianco ianco merged commit e19cd6f into openwallet-foundation:main Dec 1, 2021
@baegjae baegjae deleted the fix-remove-wallet branch December 2, 2021 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants