mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Timestamp: set_timestamp sets DidUpdate (#11960)
* Timestamp: `set_timestamp` sets `DidUpdate` There exists the `set_timestamp` in the Timestamp pallet for setting the current timestamp. The problem is that it doesn't set `DidUpdate`. This results in `on_finalize` panicking. There is no real reason why the function doesn't also set `DidUpdate`. * Update frame/timestamp/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix Babe tests Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -282,6 +282,8 @@ impl<T: Config> Pallet<T> {
|
||||
#[cfg(any(feature = "runtime-benchmarks", feature = "std"))]
|
||||
pub fn set_timestamp(now: T::Moment) {
|
||||
Now::<T>::put(now);
|
||||
DidUpdate::<T>::put(true);
|
||||
<T::OnTimestampSet as OnTimestampSet<_>>::on_timestamp_set(now);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ use frame_support::assert_ok;
|
||||
#[test]
|
||||
fn timestamp_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Timestamp::set_timestamp(42);
|
||||
crate::Now::<Test>::put(46);
|
||||
assert_ok!(Timestamp::set(Origin::none(), 69));
|
||||
assert_eq!(Timestamp::now(), 69);
|
||||
assert_eq!(Some(69), get_captured_moment());
|
||||
@@ -36,7 +36,6 @@ fn double_timestamp_should_fail() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Timestamp::set_timestamp(42);
|
||||
assert_ok!(Timestamp::set(Origin::none(), 69));
|
||||
let _ = Timestamp::set(Origin::none(), 70);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ fn double_timestamp_should_fail() {
|
||||
)]
|
||||
fn block_period_minimum_enforced() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Timestamp::set_timestamp(42);
|
||||
crate::Now::<Test>::put(44);
|
||||
let _ = Timestamp::set(Origin::none(), 46);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user