mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 10:55:42 +00:00
cumulus: fix test runtimes panic (#2039)
the min slot duration should be 0 only if the `experimental` feature is enabled. otherwise, the runtime will panic on a division by 0.
This commit is contained in:
@@ -224,7 +224,10 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
impl pallet_timestamp::Config for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
|
#[cfg(feature = "experimental")]
|
||||||
type MinimumPeriod = ConstU64<0>;
|
type MinimumPeriod = ConstU64<0>;
|
||||||
|
#[cfg(not(feature = "experimental"))]
|
||||||
|
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +358,7 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||||
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
|
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
|
|||||||
@@ -216,7 +216,10 @@ impl pallet_aura::Config for Runtime {
|
|||||||
impl pallet_timestamp::Config for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
|
#[cfg(feature = "experimental")]
|
||||||
type MinimumPeriod = ConstU64<0>;
|
type MinimumPeriod = ConstU64<0>;
|
||||||
|
#[cfg(not(feature = "experimental"))]
|
||||||
|
type MinimumPeriod = ConstU64<{ parachains_common::SLOT_DURATION / 2 }>;
|
||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,10 @@ impl pallet_aura::Config for Runtime {
|
|||||||
impl pallet_timestamp::Config for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
|
#[cfg(feature = "experimental")]
|
||||||
type MinimumPeriod = ConstU64<0>;
|
type MinimumPeriod = ConstU64<0>;
|
||||||
|
#[cfg(not(feature = "experimental"))]
|
||||||
|
type MinimumPeriod = ConstU64<{ parachains_common::SLOT_DURATION / 2 }>;
|
||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -408,8 +408,9 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
|
|||||||
let timestamp_slot = moment / slot_duration;
|
let timestamp_slot = moment / slot_duration;
|
||||||
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());
|
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());
|
||||||
|
|
||||||
assert!(
|
assert_eq!(
|
||||||
CurrentSlot::<T>::get() == timestamp_slot,
|
CurrentSlot::<T>::get(),
|
||||||
|
timestamp_slot,
|
||||||
"Timestamp slot must match `CurrentSlot`"
|
"Timestamp slot must match `CurrentSlot`"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -900,8 +900,9 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
|
|||||||
let timestamp_slot = moment / slot_duration;
|
let timestamp_slot = moment / slot_duration;
|
||||||
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());
|
let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());
|
||||||
|
|
||||||
assert!(
|
assert_eq!(
|
||||||
CurrentSlot::<T>::get() == timestamp_slot,
|
CurrentSlot::<T>::get(),
|
||||||
|
timestamp_slot,
|
||||||
"Timestamp slot must match `CurrentSlot`"
|
"Timestamp slot must match `CurrentSlot`"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user