Skip to content

Commit

Permalink
Fix minor storage leak; clean-up BurnedBootstrapperNewbieTickets an…
Browse files Browse the repository at this point in the history
…d `BurnedReputableNewbieTickets` (#285)

* [ceremonies] clean-up `BurnedReputableNewbieTickets` in `purge_community_ceremony`

* [ceremonies] clean-up `BurnedBootstrapperNewbieTickets` in `purge_community`

* [ceremonies] add minor documentation about endorsees
  • Loading branch information
clangenb authored Nov 26, 2022
1 parent 9ee44a4 commit 6f5adcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ceremonies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ pub mod pallet {
ValueQuery,
>;

/// Accounts that have been endorsed by a reputable or a bootstrapper.
///
/// This is not the same as `EndorseeRegistry`, which contains the `Endorsees` who
/// have registered for a meetup.
#[pallet::storage]
#[pallet::getter(fn endorsees)]
pub(super) type Endorsees<T: Config> = StorageDoubleMap<
Expand Down Expand Up @@ -1313,6 +1317,7 @@ impl<T: Config> Pallet<T> {

<MeetupParticipantCountVote<T>>::remove_prefix(cc, None);
<IssuedRewards<T>>::remove_prefix(cc, None);
<BurnedReputableNewbieTickets<T>>::remove_prefix(cc, None);

Self::deposit_event(Event::CommunityCeremonyHistoryPurged(cindex, cid));
}
Expand Down Expand Up @@ -1491,6 +1496,9 @@ impl<T: Config> Pallet<T> {

<InactivityCounters<T>>::remove(cid);

#[allow(deprecated)]
<BurnedBootstrapperNewbieTickets<T>>::remove_prefix(cid, None);

<encointer_communities::Pallet<T>>::remove_community(cid);
}

Expand Down
7 changes: 7 additions & 0 deletions ceremonies/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,8 @@ fn grow_population_and_removing_community_works() {
// only sanity check. Community removal is better tested in the communities pallet.
assert_eq!(EncointerCommunities::community_identifiers().contains(&cid), false);

assert_eq!(BurnedBootstrapperNewbieTickets::<TestRuntime>::iter_prefix(cid).next(), None);

for cindex in current_cindex.saturating_sub(reputation_lifetime)..=current_cindex {
assert_eq!(
BootstrapperRegistry::<TestRuntime>::iter_prefix((cid, cindex)).next(),
Expand Down Expand Up @@ -1824,6 +1826,11 @@ fn grow_population_and_removing_community_works() {

assert_eq!(IssuedRewards::<TestRuntime>::iter_prefix((cid, cindex)).next(), None);

assert_eq!(
BurnedReputableNewbieTickets::<TestRuntime>::iter_prefix((cid, cindex)).next(),
None
);

assert_eq!(InactivityCounters::<TestRuntime>::contains_key(cid), false);
}
});
Expand Down

0 comments on commit 6f5adcd

Please sign in to comment.