paras: Prune upgrade cooldowns (#7470)

After an upgrade cooldown triggered to remove a signal we also need to
prune it from the list.
This commit is contained in:
Bastian Köcher
2023-07-10 17:08:12 +02:00
committed by GitHub
parent 1abddc2efe
commit e3ee909e9e
2 changed files with 25 additions and 7 deletions
+15 -3
View File
@@ -441,7 +441,7 @@ fn code_upgrade_applied_after_delay() {
run_to_block(2, Some(vec![1]));
assert_eq!(Paras::current_code(&para_id), Some(original_code.clone()));
let expected_at = {
let (expected_at, next_possible_upgrade_at) = {
// this parablock is in the context of block 1.
let expected_at = 1 + validation_upgrade_delay;
let next_possible_upgrade_at = 1 + validation_upgrade_cooldown;
@@ -460,7 +460,7 @@ fn code_upgrade_applied_after_delay() {
check_code_is_stored(&original_code);
check_code_is_stored(&new_code);
expected_at
(expected_at, next_possible_upgrade_at)
};
run_to_block(expected_at, None);
@@ -495,9 +495,21 @@ fn code_upgrade_applied_after_delay() {
assert!(FutureCodeHash::<Test>::get(&para_id).is_none());
assert!(UpgradeGoAheadSignal::<Test>::get(&para_id).is_none());
assert_eq!(Paras::current_code(&para_id), Some(new_code.clone()));
assert_eq!(
UpgradeRestrictionSignal::<Test>::get(&para_id),
Some(UpgradeRestriction::Present),
);
assert_eq!(UpgradeCooldowns::<Test>::get(), vec![(para_id, next_possible_upgrade_at)]);
check_code_is_stored(&original_code);
check_code_is_stored(&new_code);
}
run_to_block(next_possible_upgrade_at + 1, None);
{
assert!(UpgradeRestrictionSignal::<Test>::get(&para_id).is_none());
assert!(UpgradeCooldowns::<Test>::get().is_empty());
}
});
}
@@ -568,7 +580,7 @@ fn code_upgrade_applied_after_delay_even_when_late() {
// the upgrade.
{
// The signal should be set to go-ahead until the new head is actually processed.
assert_eq!(UpgradeGoAheadSignal::<Test>::get(&para_id), Some(UpgradeGoAhead::GoAhead),);
assert_eq!(UpgradeGoAheadSignal::<Test>::get(&para_id), Some(UpgradeGoAhead::GoAhead));
Paras::note_new_head(para_id, Default::default(), expected_at + 4);