mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
Root origin use no filter by default. Scheduler and Democracy dispatch without asserting BaseCallFilter (#6408)
* make system root origin build runtime origin with no filter * additional doc
This commit is contained in:
committed by
GitHub
parent
2645659ab2
commit
780f8e09d7
@@ -22,7 +22,8 @@ use std::cell::RefCell;
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types,
|
||||
impl_outer_event, ord_parameter_types, traits::{Contains, OnInitialize}, weights::Weight,
|
||||
impl_outer_event, ord_parameter_types, traits::{Contains, OnInitialize, Filter},
|
||||
weights::Weight,
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
@@ -74,6 +75,14 @@ impl_outer_event! {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that a fitlered call can be dispatched.
|
||||
pub struct BaseFilter;
|
||||
impl Filter<Call> for BaseFilter {
|
||||
fn filter(call: &Call) -> bool {
|
||||
!matches!(call, &Call::Balances(pallet_balances::Call::set_balance(..)))
|
||||
}
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||
pub struct Test;
|
||||
@@ -84,7 +93,7 @@ parameter_types! {
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
}
|
||||
impl frame_system::Trait for Test {
|
||||
type BaseCallFilter = ();
|
||||
type BaseCallFilter = BaseFilter;
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -225,6 +234,14 @@ fn set_balance_proposal(value: u64) -> Vec<u8> {
|
||||
Call::Balances(pallet_balances::Call::set_balance(42, value, 0)).encode()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_balance_proposal_is_correctly_filtered_out() {
|
||||
for i in 0..10 {
|
||||
let call = Call::decode(&mut &set_balance_proposal(i)[..]).unwrap();
|
||||
assert!(!<Test as frame_system::Trait>::BaseCallFilter::filter(&call));
|
||||
}
|
||||
}
|
||||
|
||||
fn set_balance_proposal_hash(value: u64) -> H256 {
|
||||
BlakeTwo256::hash(&set_balance_proposal(value)[..])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user