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

reveal bug from #276

parent 268da199
No related branches found
No related tags found
1 merge request!305Resolve "smithMembers.expiresOn is only growing"
...@@ -628,6 +628,49 @@ fn certifying_an_online_smith() { ...@@ -628,6 +628,49 @@ fn certifying_an_online_smith() {
}); });
} }
/// Shows that scheduled expiration stay scheduled forever, even in the past
/// This is harmful for storage because we store unnecessary data
#[test]
fn expires_on_keeps_growing() {
new_test_ext(GenesisConfig {
initial_smiths: btreemap![
1 => (true, vec![2, 3]),
2 => (true, vec![1,3]),
3 => (true, vec![1,2]),
],
})
.execute_with(|| {
// Alice goes offline, and is set to expire
Pallet::<Runtime>::on_smith_goes_offline(1);
// The expiration block is present in smith data
assert_eq!(
Smiths::<Runtime>::get(1),
Some(SmithMeta {
status: Smith,
expires_on: Some(5),
issued_certs: vec![2, 3],
received_certs: vec![2, 3]
})
);
// It is also present in ExpiresOn schedule
assert_eq!(ExpiresOn::<Runtime>::get(5), Some(vec![1]));
// Go to expiration session
Pallet::<Runtime>::on_new_session(5);
// Alice is expired
assert_eq!(
Smiths::<Runtime>::get(1),
Some(SmithMeta {
status: Excluded,
expires_on: None,
issued_certs: vec![2, 3],
received_certs: vec![]
})
);
// but ExpiresOn schedule is still there (and will stay forever)
assert_eq!(ExpiresOn::<Runtime>::get(5), Some(vec![1]));
});
}
#[test] #[test]
fn invitation_on_non_wot_member() { fn invitation_on_non_wot_member() {
new_test_ext(GenesisConfig { new_test_ext(GenesisConfig {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment