Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix democracy benchmarks #404

Merged
merged 2 commits into from
Sep 17, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading