mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin * more renaming * a bit more renaming * fix * more fixing * fix in frame_support * even more fixes * fix * small fix * ... * update .stderr * docs * update docs * update docs * docs
This commit is contained in:
@@ -119,7 +119,7 @@ pub mod pallet {
|
||||
|
||||
/// A sudo-able call.
|
||||
type RuntimeCall: Parameter
|
||||
+ UnfilteredDispatchable<Origin = Self::Origin>
|
||||
+ UnfilteredDispatchable<RuntimeOrigin = Self::RuntimeOrigin>
|
||||
+ GetDispatchInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
use super::*;
|
||||
use frame_support::{assert_noop, assert_ok, weights::Weight};
|
||||
use mock::{
|
||||
new_test_ext, Logger, LoggerCall, Origin, RuntimeCall, RuntimeEvent as TestEvent, Sudo,
|
||||
new_test_ext, Logger, LoggerCall, RuntimeCall, RuntimeEvent as TestEvent, RuntimeOrigin, Sudo,
|
||||
SudoCall, System, Test,
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ fn sudo_basics() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1_000),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo(Origin::signed(1), call));
|
||||
assert_ok!(Sudo::sudo(RuntimeOrigin::signed(1), call));
|
||||
assert_eq!(Logger::i32_log(), vec![42i32]);
|
||||
|
||||
// A privileged function should not work when `sudo` is passed a non-root `key` as `origin`.
|
||||
@@ -51,7 +51,7 @@ fn sudo_basics() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1_000),
|
||||
}));
|
||||
assert_noop!(Sudo::sudo(Origin::signed(2), call), Error::<Test>::RequireSudo);
|
||||
assert_noop!(Sudo::sudo(RuntimeOrigin::signed(2), call), Error::<Test>::RequireSudo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ fn sudo_emits_events_correctly() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo(Origin::signed(1), call));
|
||||
assert_ok!(Sudo::sudo(RuntimeOrigin::signed(1), call));
|
||||
System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) }));
|
||||
})
|
||||
}
|
||||
@@ -80,7 +80,7 @@ fn sudo_unchecked_weight_basics() {
|
||||
weight: Weight::from_ref_time(1_000),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo_unchecked_weight(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
call,
|
||||
Weight::from_ref_time(1_000)
|
||||
));
|
||||
@@ -92,7 +92,11 @@ fn sudo_unchecked_weight_basics() {
|
||||
weight: Weight::from_ref_time(1_000),
|
||||
}));
|
||||
assert_noop!(
|
||||
Sudo::sudo_unchecked_weight(Origin::signed(2), call, Weight::from_ref_time(1_000)),
|
||||
Sudo::sudo_unchecked_weight(
|
||||
RuntimeOrigin::signed(2),
|
||||
call,
|
||||
Weight::from_ref_time(1_000)
|
||||
),
|
||||
Error::<Test>::RequireSudo,
|
||||
);
|
||||
// `I32Log` is unchanged after unsuccessful call.
|
||||
@@ -122,7 +126,7 @@ fn sudo_unchecked_weight_emits_events_correctly() {
|
||||
weight: Weight::from_ref_time(1),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo_unchecked_weight(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
call,
|
||||
Weight::from_ref_time(1_000)
|
||||
));
|
||||
@@ -134,14 +138,14 @@ fn sudo_unchecked_weight_emits_events_correctly() {
|
||||
fn set_key_basics() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// A root `key` can change the root `key`
|
||||
assert_ok!(Sudo::set_key(Origin::signed(1), 2));
|
||||
assert_ok!(Sudo::set_key(RuntimeOrigin::signed(1), 2));
|
||||
assert_eq!(Sudo::key(), Some(2u64));
|
||||
});
|
||||
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// A non-root `key` will trigger a `RequireSudo` error and a non-root `key` cannot change
|
||||
// the root `key`.
|
||||
assert_noop!(Sudo::set_key(Origin::signed(2), 3), Error::<Test>::RequireSudo);
|
||||
assert_noop!(Sudo::set_key(RuntimeOrigin::signed(2), 3), Error::<Test>::RequireSudo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -152,10 +156,10 @@ fn set_key_emits_events_correctly() {
|
||||
System::set_block_number(1);
|
||||
|
||||
// A root `key` can change the root `key`.
|
||||
assert_ok!(Sudo::set_key(Origin::signed(1), 2));
|
||||
assert_ok!(Sudo::set_key(RuntimeOrigin::signed(1), 2));
|
||||
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(1) }));
|
||||
// Double check.
|
||||
assert_ok!(Sudo::set_key(Origin::signed(2), 4));
|
||||
assert_ok!(Sudo::set_key(RuntimeOrigin::signed(2), 4));
|
||||
System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(2) }));
|
||||
});
|
||||
}
|
||||
@@ -168,7 +172,7 @@ fn sudo_as_basics() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1_000),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call));
|
||||
assert_ok!(Sudo::sudo_as(RuntimeOrigin::signed(1), 2, call));
|
||||
assert!(Logger::i32_log().is_empty());
|
||||
assert!(Logger::account_log().is_empty());
|
||||
|
||||
@@ -177,14 +181,14 @@ fn sudo_as_basics() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1),
|
||||
}));
|
||||
assert_noop!(Sudo::sudo_as(Origin::signed(3), 2, call), Error::<Test>::RequireSudo);
|
||||
assert_noop!(Sudo::sudo_as(RuntimeOrigin::signed(3), 2, call), Error::<Test>::RequireSudo);
|
||||
|
||||
// A non-privileged function will work when passed to `sudo_as` with the root `key`.
|
||||
let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call));
|
||||
assert_ok!(Sudo::sudo_as(RuntimeOrigin::signed(1), 2, call));
|
||||
assert_eq!(Logger::i32_log(), vec![42i32]);
|
||||
// The correct user makes the call within `sudo_as`.
|
||||
assert_eq!(Logger::account_log(), vec![2]);
|
||||
@@ -202,7 +206,7 @@ fn sudo_as_emits_events_correctly() {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1),
|
||||
}));
|
||||
assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call));
|
||||
assert_ok!(Sudo::sudo_as(RuntimeOrigin::signed(1), 2, call));
|
||||
System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) }));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user