Skip to content

Commit d80a987

Browse files
gui1117kianenigma
andauthored
Introduce in-origin filtering (#6318)
* impl filter in origin * remove IsCallable usage. Breaking: utility::batch(root, calls) no longer bypass BasicCallFilter * rename BasicCallFilter -> BaseCallFilter * refactor code * Apply suggestions from code review Co-authored-by: Kian Paimani <[email protected]> * remove forgotten temporar comment * better add suggestion in another PR * refactor: use Clone instead of mem::replace * fix tests * fix tests * fix tests * fix benchmarks * Make root bypass filter in utility::batch * fix unused imports Co-authored-by: Kian Paimani <[email protected]>
1 parent b35ecd0 commit d80a987

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,11 @@ mod tests {
10151015
pub const MaxProposals: u32 = 100;
10161016
}
10171017
impl frame_system::Trait for Test {
1018+
type BaseCallFilter = ();
10181019
type Origin = Origin;
10191020
type Index = u64;
10201021
type BlockNumber = u64;
1021-
type Call = ();
1022+
type Call = Call;
10221023
type Hash = H256;
10231024
type Hashing = BlakeTwo256;
10241025
type AccountId = u64;
@@ -1167,7 +1168,7 @@ mod tests {
11671168
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
11681169
let proposal_weight = proposal.get_dispatch_info().weight;
11691170
let hash = BlakeTwo256::hash_of(&proposal);
1170-
assert_ok!(Collective::set_members(Origin::ROOT, vec![1, 2, 3], Some(3), MAX_MEMBERS));
1171+
assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(3), MAX_MEMBERS));
11711172

11721173
assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len));
11731174
assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true));
@@ -1192,7 +1193,7 @@ mod tests {
11921193
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
11931194
let proposal_weight = proposal.get_dispatch_info().weight;
11941195
let hash = BlakeTwo256::hash_of(&proposal);
1195-
assert_ok!(Collective::set_members(Origin::ROOT, vec![1, 2, 3], Some(1), MAX_MEMBERS));
1196+
assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(1), MAX_MEMBERS));
11961197

11971198
assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len));
11981199
assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true));
@@ -1260,7 +1261,7 @@ mod tests {
12601261
Collective::voting(&hash),
12611262
Some(Votes { index: 0, threshold: 3, ayes: vec![1, 2], nays: vec![], end })
12621263
);
1263-
assert_ok!(Collective::set_members(Origin::ROOT, vec![2, 3, 4], None, MAX_MEMBERS));
1264+
assert_ok!(Collective::set_members(Origin::root(), vec![2, 3, 4], None, MAX_MEMBERS));
12641265
assert_eq!(
12651266
Collective::voting(&hash),
12661267
Some(Votes { index: 0, threshold: 3, ayes: vec![2], nays: vec![], end })
@@ -1275,7 +1276,7 @@ mod tests {
12751276
Collective::voting(&hash),
12761277
Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![3], end })
12771278
);
1278-
assert_ok!(Collective::set_members(Origin::ROOT, vec![2, 4], None, MAX_MEMBERS));
1279+
assert_ok!(Collective::set_members(Origin::root(), vec![2, 4], None, MAX_MEMBERS));
12791280
assert_eq!(
12801281
Collective::voting(&hash),
12811282
Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![], end })
@@ -1618,7 +1619,7 @@ mod tests {
16181619
// Proposal would normally succeed
16191620
assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true));
16201621
// But Root can disapprove and remove it anyway
1621-
assert_ok!(Collective::disapprove_proposal(Origin::ROOT, hash.clone()));
1622+
assert_ok!(Collective::disapprove_proposal(Origin::root(), hash.clone()));
16221623
let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] };
16231624
assert_eq!(System::events(), vec![
16241625
record(Event::collective_Instance1(RawEvent::Proposed(1, 0, hash.clone(), 2))),

0 commit comments

Comments
 (0)