Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update stored_map_works test, triggers potential bug. #9548

Closed

Conversation

Mr-Leshiy
Copy link
Contributor

I have updated 'stored_map_works' test case with the usage of the 'try_mutate_exist' function to trigger behavior described in this discussion #9463.
Here is the description of the test case:

  1. Set up the AccountData into the '55'.
  2. check that 'providers' and 'consumers' has been unchanged, 'data' is equal to '55'.
  3. change data to the 'default' value '0'.
  4. check that 'providers' and 'consumers' has been unchanged, 'data' is equal to '0'.
  5. change data to the '55' again.
  6. check that 'providers' and 'consumers' has been unchanged, 'data' is equal to '55'.

But the existing behavior is different that I am expecting to this test case, so after changing the value from the 'default' the 'providers' counter has been incremented.

@gui1117
Copy link
Contributor

gui1117 commented Aug 20, 2021

I think it is the expected behavior no ?

in frame-system it is specified.

/// Implement StoredMap for a simple single-item, provide-when-not-default system. This works fine
/// for storing a single item which allows the account to continue existing as long as it's not
/// empty/default.
///
/// Anything more complex will need more sophisticated logic.
impl<T: Config> StoredMap<T::AccountId, T::AccountData> for Pallet<T> {

The idea is that the storage map is considered providing when it has a value different that default

@Mr-Leshiy
Copy link
Contributor Author

@thiolliere , I see. I will close this PR

@bkchr bkchr closed this Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants