mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Filter calls in utility (#6131)
* Filter calls. * Remove old proxy code * Docs and repot * Update frame/utility/src/tests.rs Co-authored-by: Marcio Diaz <marcio.diaz@gmail.com> * fix test * Grumble * Bump runtime version * fix * Attempt general fix Co-authored-by: Marcio Diaz <marcio.diaz@gmail.com> Co-authored-by: NikVolf <nikvolf@gmail.com>
This commit is contained in:
@@ -99,6 +99,16 @@ parameter_types! {
|
||||
pub const MultisigDepositFactor: u64 = 1;
|
||||
pub const MaxSignatories: u16 = 3;
|
||||
}
|
||||
|
||||
pub struct TestIsCallable;
|
||||
impl Filter<Call> for TestIsCallable {
|
||||
fn filter(c: &Call) -> bool {
|
||||
match *c {
|
||||
Call::Balances(pallet_balances::Call::transfer(..)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Trait for Test {
|
||||
type Event = TestEvent;
|
||||
type Call = Call;
|
||||
@@ -106,6 +116,7 @@ impl Trait for Test {
|
||||
type MultisigDepositBase = MultisigDepositBase;
|
||||
type MultisigDepositFactor = MultisigDepositFactor;
|
||||
type MaxSignatories = MaxSignatories;
|
||||
type IsCallable = TestIsCallable;
|
||||
}
|
||||
type System = frame_system::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
@@ -379,6 +390,17 @@ fn multisig_1_of_3_works() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multisig_filters() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(Call::System(frame_system::Call::remark(vec![])));
|
||||
assert_noop!(
|
||||
Utility::as_multi(Origin::signed(1), 1, vec![], None, call.clone()),
|
||||
Error::<Test>::Uncallable,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn as_sub_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
@@ -399,6 +421,17 @@ fn as_sub_works() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn as_sub_filters() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(Utility::as_sub(
|
||||
Origin::signed(1),
|
||||
1,
|
||||
Box::new(Call::System(frame_system::Call::remark(vec![]))),
|
||||
), Error::<Test>::Uncallable);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_with_root_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
@@ -429,6 +462,18 @@ fn batch_with_signed_works() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_with_signed_filters() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(
|
||||
Utility::batch(Origin::signed(1), vec![
|
||||
Call::System(frame_system::Call::remark(vec![]))
|
||||
]),
|
||||
);
|
||||
expect_event(RawEvent::Uncallable(0));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_early_exit_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user