Skip to content

Commit

Permalink
cumulus: fix test runtimes panic (paritytech#2039)
Browse files Browse the repository at this point in the history
the min slot duration should be 0 only if the `experimental` feature is
enabled. otherwise, the runtime will panic on a division by 0.
  • Loading branch information
alindima authored Oct 26, 2023
1 parent cde5c8c commit f328ff7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions substrate/frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
let timestamp_slot = moment / slot_duration;
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());

assert!(
CurrentSlot::<T>::get() == timestamp_slot,
assert_eq!(
CurrentSlot::<T>::get(),
timestamp_slot,
"Timestamp slot must match `CurrentSlot`"
);
}
Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,9 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
let timestamp_slot = moment / slot_duration;
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());

assert!(
CurrentSlot::<T>::get() == timestamp_slot,
assert_eq!(
CurrentSlot::<T>::get(),
timestamp_slot,
"Timestamp slot must match `CurrentSlot`"
);
}
Expand Down

0 comments on commit f328ff7

Please sign in to comment.