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

fix bug from #276

parent 64d97009
No related branches found
No related tags found
1 merge request!305Resolve "smithMembers.expiresOn is only growing"
Pipeline #39513 passed
...@@ -519,7 +519,7 @@ impl<T: Config> Pallet<T> { ...@@ -519,7 +519,7 @@ impl<T: Config> Pallet<T> {
/// Handle the removal of Smiths whose expiration time has been reached at a given session index. /// Handle the removal of Smiths whose expiration time has been reached at a given session index.
fn on_exclude_expired_smiths(at: SessionIndex) { fn on_exclude_expired_smiths(at: SessionIndex) {
if let Some(smiths_to_remove) = ExpiresOn::<T>::get(at) { if let Some(smiths_to_remove) = ExpiresOn::<T>::take(at) {
for smith in smiths_to_remove { for smith in smiths_to_remove {
if let Some(smith_meta) = Smiths::<T>::get(smith) { if let Some(smith_meta) = Smiths::<T>::get(smith) {
if let Some(expires_on) = smith_meta.expires_on { if let Some(expires_on) = smith_meta.expires_on {
......
...@@ -628,10 +628,9 @@ fn certifying_an_online_smith() { ...@@ -628,10 +628,9 @@ fn certifying_an_online_smith() {
}); });
} }
/// Shows that scheduled expiration stay scheduled forever, even in the past /// Test that scheduled expiration is removed after session
/// This is harmful for storage because we store unnecessary data
#[test] #[test]
fn expires_on_keeps_growing() { fn expires_on_cleans_up() {
new_test_ext(GenesisConfig { new_test_ext(GenesisConfig {
initial_smiths: btreemap![ initial_smiths: btreemap![
1 => (true, vec![2, 3]), 1 => (true, vec![2, 3]),
...@@ -666,8 +665,8 @@ fn expires_on_keeps_growing() { ...@@ -666,8 +665,8 @@ fn expires_on_keeps_growing() {
received_certs: vec![] received_certs: vec![]
}) })
); );
// but ExpiresOn schedule is still there (and will stay forever) // ExpiresOn is clean
assert_eq!(ExpiresOn::<Runtime>::get(5), Some(vec![1])); assert_eq!(ExpiresOn::<Runtime>::get(5), None);
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment