diff --git a/pallets/smith-members/src/lib.rs b/pallets/smith-members/src/lib.rs index 35918f55a00283378fd80f27686c8ecf7c6e0845..1ed34c47bf4fc9e8bfe788aa05bee4f19cff9490 100644 --- a/pallets/smith-members/src/lib.rs +++ b/pallets/smith-members/src/lib.rs @@ -582,7 +582,7 @@ impl<T: Config> Pallet<T> { if let Some(smith_meta) = maybe_smith_meta { // As long as the smith is online, it cannot expire smith_meta.expires_on = None; - // FIXME: unschedule old expiry + // FIXME: unschedule old expiry (#182) } }); } @@ -592,10 +592,12 @@ impl<T: Config> Pallet<T> { /// Handle the event when a Smith goes offline. pub fn on_smith_goes_offline(idty_index: T::IdtyIndex) { if let Some(smith_meta) = Smiths::<T>::get(idty_index) { - if smith_meta.expires_on.is_none() { + // Smith can go offline after main membership expiry + // in this case, there is no scheduled expiry since it is already excluded + if smith_meta.status != SmithStatus::Excluded { Smiths::<T>::mutate(idty_index, |maybe_smith_meta| { if let Some(smith_meta) = maybe_smith_meta { - // As long as the smith is online, it cannot expire + // schedule expiry let new_expires_on = CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get(); smith_meta.expires_on = Some(new_expires_on); diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index af4094518b7dc25133fcefdcaebe38172230691c..a8b3cb47bb304485811570f2a50c14685ab7b5f5 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -1023,7 +1023,7 @@ fn test_smith_process() { // reveal bug from #243 #[test] -fn test_expired_smith_with_null_expires_on() { +fn test_expired_smith_has_null_expires_on() { // initial_authorities_len = 2 → Alice and Bob are online // initial_smiths_len = 3 → Charlie is offline Smith // initial_identities_len = 4 → Dave is member but not smith @@ -1093,14 +1093,12 @@ fn test_expired_smith_with_null_expires_on() { pallet_authority_members::Event::OutgoingAuthorities { members: vec![2] }, )); - // show that expires_on is non null - // this is issue #243 - // Bob is not Smith anymore + // control state is still ok assert_eq!( SmithMembers::smiths(2), Some(pallet_smith_members::SmithMeta { status: SmithStatus::Excluded, // still excluded - expires_on: Some(48), // should be still None !! + expires_on: None, // should be still None issued_certs: vec![1, 3], received_certs: vec![], })