Skip to content

Commit

Permalink
fix democracy benchmarks (#404)
Browse files Browse the repository at this point in the history
* fix democracy benchmarks

* fmt
  • Loading branch information
brenzi authored Sep 17, 2024
1 parent 895052d commit 43e099d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion democracy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-encointer-democracy"
version = "13.3.1"
version = "13.3.2"
authors = ["Encointer Association <info@encointer.org>"]
edition = "2021"
description = "Democracy pallet for the Encointer blockchain runtime"
Expand Down
10 changes: 4 additions & 6 deletions democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ use parity_scale_codec::Encode;
#[cfg(not(feature = "std"))]
use sp_std::vec;

fn advance_timestamp_equivalent_to_n_blocks<T: Config>(n: u64) {
let offset: T::Moment = (n * 6000u64)
.try_into()
.unwrap_or_else(|_| panic!("Something went horribly wrong!"));
let new_time: T::Moment = pallet_timestamp::Pallet::<T>::get() + offset;
fn advance_timestamp_by<T: Config>(dt: T::Moment) {
let new_time: T::Moment = pallet_timestamp::Pallet::<T>::get() + dt;
let _ = pallet_timestamp::Pallet::<T>::set(T::RuntimeOrigin::none(), new_time);
pallet_timestamp::Pallet::<T>::on_finalize(frame_system::Pallet::<T>::block_number());
}
Expand Down Expand Up @@ -98,7 +95,8 @@ benchmarks! {
assert_eq!(EncointerDemocracy::<T>::proposals(1).unwrap().state, ProposalState::Ongoing);
EncointerDemocracy::<T>::update_proposal_state(RawOrigin::Signed(zoran.clone()).into(), 1).ok();
assert!(<EnactmentQueue<T>>::iter().next().is_none());
advance_timestamp_equivalent_to_n_blocks::<T>(21);
let confirmation_time = <T as Config>::ConfirmationPeriod::get();
advance_timestamp_by::<T>(confirmation_time + 1u32.into());

}: _(RawOrigin::Signed(zoran), 1)
verify {
Expand Down

0 comments on commit 43e099d

Please sign in to comment.