From 5cfcee7d5680810e427b51093cc1e70710dbb028 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Tue, 23 Jan 2024 23:14:58 +0100 Subject: [PATCH] fix(#176): expiration should be postponed only for Pending smiths --- pallets/smith-members/src/lib.rs | 16 +++++++++++----- pallets/smith-members/src/tests.rs | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pallets/smith-members/src/lib.rs b/pallets/smith-members/src/lib.rs index 2b32a9861..64c45dd32 100644 --- a/pallets/smith-members/src/lib.rs +++ b/pallets/smith-members/src/lib.rs @@ -447,11 +447,17 @@ impl<T: Config> Pallet<T> { } else { SmithStatus::Pending }; - // expiry postponed - let new_expires_on = - CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get(); - smith_meta.expires_on = Some(new_expires_on); - Self::deposit_event(Event::<T>::SmithCertAdded { receiver, issuer }); + + if smith_meta.status == SmithStatus::Pending { + // - postpone the expiration: a Pending smith cannot do anything but wait + // this postponement is here to ease the process of becoming a smith + let new_expires_on = + CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get(); + smith_meta.expires_on = Some(new_expires_on); + // ExpiresOn::<T>::append(new_expires_on, receiver); + } + + // - if the status is smith but wasn't, notify that smith gained membership if smith_meta.status == SmithStatus::Smith && previous_status != SmithStatus::Smith { Self::deposit_event(Event::<T>::SmithMembershipAdded { diff --git a/pallets/smith-members/src/tests.rs b/pallets/smith-members/src/tests.rs index 826c096a3..a1ba5942a 100644 --- a/pallets/smith-members/src/tests.rs +++ b/pallets/smith-members/src/tests.rs @@ -610,7 +610,6 @@ fn certifying_an_online_smith() { RuntimeOrigin::signed(3), 5 )); - // TODO: this test currently fails because expires_on is not None assert_eq!( Smiths::<Runtime>::get(5), Some(SmithMeta { -- GitLab