Skip to content
Snippets Groups Projects
Commit c8247b06 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

fix #243

parent 2aa18ec5
No related branches found
No related tags found
1 merge request!303Resolve "OutgoingAuthorities event is triggered too many times."
Pipeline #39481 passed
......@@ -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);
......
......@@ -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![],
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment