Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
optionally read pending configs in migration (#7489)
Browse files Browse the repository at this point in the history
  • Loading branch information
slumber committed Jul 12, 2023
1 parent 00684cb commit e13d10c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions runtime/parachains/src/configuration/migration/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ executor_params : pre.executor_params,
let v7 = translate(v6);
v7::ActiveConfig::<T>::set(Some(v7));

let pending_v6 = v6::PendingConfigs::<T>::get()
.defensive_proof("Could not decode old pending")
.unwrap_or_default();
// Allowed to be empty.
let pending_v6 = v6::PendingConfigs::<T>::get().unwrap_or_default();
let mut pending_v7 = Vec::new();

for (session, v6) in pending_v6.into_iter() {
Expand Down Expand Up @@ -291,4 +290,20 @@ mod tests {
}
});
}

// Test that migration doesn't panic in case there're no pending configurations upgrades in pallet's storage.
#[test]
fn test_migrate_to_v7_no_pending() {
let v6 = V6HostConfiguration::<primitives::BlockNumber>::default();

new_test_ext(Default::default()).execute_with(|| {
// Implant the v6 version in the state.
v6::ActiveConfig::<Test>::set(Some(v6));
// Ensure there're no pending configs.
v6::PendingConfigs::<Test>::set(None);

// Shouldn't fail.
migrate_to_v7::<Test>();
});
}
}

0 comments on commit e13d10c

Please sign in to comment.