mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
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 <5588131+kianenigma@users.noreply.github.com> * 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 <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
97cac4ce8b
commit
c2ad27271b
@@ -1070,10 +1070,11 @@ mod tests {
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Test {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = ();
|
||||
type Call = Call;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
@@ -1376,11 +1377,8 @@ mod tests {
|
||||
// historical note: helper function was created in a period of time in which the API of vote
|
||||
// call was changing. Currently it is a wrapper for the original call and does not do much.
|
||||
// Nonetheless, totally harmless.
|
||||
if let Origin::system(frame_system::RawOrigin::Signed(_account)) = origin {
|
||||
Elections::vote(origin, votes, stake)
|
||||
} else {
|
||||
panic!("vote origin must be signed");
|
||||
}
|
||||
ensure_signed(origin.clone()).expect("vote origin must be signed");
|
||||
Elections::vote(origin, votes, stake)
|
||||
}
|
||||
|
||||
fn votes_of(who: &u64) -> Vec<u64> {
|
||||
@@ -2358,7 +2356,7 @@ mod tests {
|
||||
assert_ok!(submit_candidacy(Origin::signed(3)));
|
||||
assert_ok!(vote(Origin::signed(3), vec![3], 30));
|
||||
|
||||
assert_ok!(Elections::remove_member(Origin::ROOT, 4, false));
|
||||
assert_ok!(Elections::remove_member(Origin::root(), 4, false));
|
||||
|
||||
assert_eq!(balances(&4), (35, 2)); // slashed
|
||||
assert_eq!(Elections::election_rounds(), 2); // new election round
|
||||
@@ -2381,7 +2379,7 @@ mod tests {
|
||||
|
||||
// no replacement yet.
|
||||
assert_err_with_weight!(
|
||||
Elections::remove_member(Origin::ROOT, 4, true),
|
||||
Elections::remove_member(Origin::root(), 4, true),
|
||||
Error::<Test>::InvalidReplacement,
|
||||
Some(6000000),
|
||||
);
|
||||
@@ -2403,7 +2401,7 @@ mod tests {
|
||||
|
||||
// there is a replacement! and this one needs a weight refund.
|
||||
assert_err_with_weight!(
|
||||
Elections::remove_member(Origin::ROOT, 4, false),
|
||||
Elections::remove_member(Origin::root(), 4, false),
|
||||
Error::<Test>::InvalidReplacement,
|
||||
Some(6000000) // only thing that matters for now is that it is NOT the full block.
|
||||
);
|
||||
@@ -2562,7 +2560,7 @@ mod tests {
|
||||
Elections::end_block(System::block_number());
|
||||
|
||||
assert_eq!(Elections::members_ids(), vec![2, 4]);
|
||||
assert_ok!(Elections::remove_member(Origin::ROOT, 2, true));
|
||||
assert_ok!(Elections::remove_member(Origin::root(), 2, true));
|
||||
assert_eq!(Elections::members_ids(), vec![4, 5]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user