Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add tests for Democracy Pallet weights
  • Loading branch information
HCastano committed May 12, 2020
commit 889d88393db65a44c6f7185fe19e4fda6cb87209
35 changes: 35 additions & 0 deletions runtime/polkadot/tests/weights_and_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use primitives::AccountId;
use polkadot_runtime::{self, Runtime};
use polkadot_runtime::constants::{currency::*, fee::*};
use runtime_common::{MaximumBlockWeight, ExtrinsicBaseWeight};

use democracy::Call as DemocracyCall;
use session::Call as SessionCall;
use staking::Call as StakingCall;
use system::Call as SystemCall;
Expand Down Expand Up @@ -264,3 +266,36 @@ fn weight_of_session_purge_keys_is_correct() {

assert_eq!(weight, expected_weight);
}

#[test]
fn weight_of_democracy_propose_is_correct() {
// #[weight = 5_000_000_000]
let expected_weight = 5_000_000_000;
let weight = DemocracyCall::propose::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;

assert_eq!(weight, expected_weight);
}

#[test]
fn weight_of_democracy_vote_is_correct() {
use democracy::AccountVote;
let vote = AccountVote::Standard {
vote: Default::default(),
balance: Default::default(),
};

// #[weight = 200_000_000]
let expected_weight = 200_000_000;
let weight = DemocracyCall::vote::<Runtime>(Default::default(), vote).get_dispatch_info().weight;

assert_eq!(weight, expected_weight);
}

#[test]
fn weight_of_democracy_enact_proposal_is_correct() {
// #[weight = T::MaximumBlockWeight::get()]
let expected_weight = MaximumBlockWeight::get();
let weight = DemocracyCall::enact_proposal::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;

assert_eq!(weight, expected_weight);
}