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

Timestamp: set_timestamp sets DidUpdate #11960

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub fn generate_equivocation_proof(
System::reset_events();
System::initialize(&current_block, &parent_hash, &pre_digest);
System::set_block_number(current_block);
Timestamp::set_timestamp(current_block);
Timestamp::set_timestamp(*current_slot * Babe::slot_duration());
System::finalize()
};

Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ fn report_equivocation_invalid_equivocation_proof() {
equivocation_proof.second_header = equivocation_proof.first_header.clone();
assert_invalid_equivocation(equivocation_proof);

// missing preruntime digest from one header
// missing pre-runtime digest from one header
let mut equivocation_proof = generate_equivocation_proof(
offending_validator_index as u32,
&offending_authority_pair,
Expand Down
2 changes: 2 additions & 0 deletions frame/timestamp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
bkchr marked this conversation as resolved.
Show resolved Hide resolved
<T::OnTimestampSet as OnTimestampSet<_>>::on_timestamp_set(now);
}
}

Expand Down
5 changes: 2 additions & 3 deletions frame/timestamp/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
});
}

Expand All @@ -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);
});
}