mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +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:
@@ -78,16 +78,16 @@ pub mod pallet {
|
||||
type MaxPeerIdLength: Get<u32>;
|
||||
|
||||
/// The origin which can add a well known node.
|
||||
type AddOrigin: EnsureOrigin<Self::Origin>;
|
||||
type AddOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin which can remove a well known node.
|
||||
type RemoveOrigin: EnsureOrigin<Self::Origin>;
|
||||
type RemoveOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin which can swap the well known nodes.
|
||||
type SwapOrigin: EnsureOrigin<Self::Origin>;
|
||||
type SwapOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin which can reset the well known nodes.
|
||||
type ResetOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ResetOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
@@ -52,7 +52,7 @@ impl frame_system::Config for Test {
|
||||
type DbWeight = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
|
||||
@@ -26,19 +26,27 @@ use sp_runtime::traits::BadOrigin;
|
||||
fn add_well_known_node_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_well_known_node(Origin::signed(2), test_node(15), 15),
|
||||
NodeAuthorization::add_well_known_node(RuntimeOrigin::signed(2), test_node(15), 15),
|
||||
BadOrigin
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_well_known_node(Origin::signed(1), PeerId(vec![1, 2, 3]), 15),
|
||||
NodeAuthorization::add_well_known_node(
|
||||
RuntimeOrigin::signed(1),
|
||||
PeerId(vec![1, 2, 3]),
|
||||
15
|
||||
),
|
||||
Error::<Test>::PeerIdTooLong
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_well_known_node(Origin::signed(1), test_node(20), 20),
|
||||
NodeAuthorization::add_well_known_node(RuntimeOrigin::signed(1), test_node(20), 20),
|
||||
Error::<Test>::AlreadyJoined
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::add_well_known_node(Origin::signed(1), test_node(15), 15));
|
||||
assert_ok!(NodeAuthorization::add_well_known_node(
|
||||
RuntimeOrigin::signed(1),
|
||||
test_node(15),
|
||||
15
|
||||
));
|
||||
assert_eq!(
|
||||
WellKnownNodes::<Test>::get(),
|
||||
BTreeSet::from_iter(vec![test_node(10), test_node(15), test_node(20), test_node(30)])
|
||||
@@ -49,7 +57,7 @@ fn add_well_known_node_works() {
|
||||
assert_eq!(Owners::<Test>::get(test_node(15)), Some(15));
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_well_known_node(Origin::signed(1), test_node(25), 25),
|
||||
NodeAuthorization::add_well_known_node(RuntimeOrigin::signed(1), test_node(25), 25),
|
||||
Error::<Test>::TooManyNodes
|
||||
);
|
||||
});
|
||||
@@ -59,15 +67,18 @@ fn add_well_known_node_works() {
|
||||
fn remove_well_known_node_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_well_known_node(Origin::signed(3), test_node(20)),
|
||||
NodeAuthorization::remove_well_known_node(RuntimeOrigin::signed(3), test_node(20)),
|
||||
BadOrigin
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_well_known_node(Origin::signed(2), PeerId(vec![1, 2, 3])),
|
||||
NodeAuthorization::remove_well_known_node(
|
||||
RuntimeOrigin::signed(2),
|
||||
PeerId(vec![1, 2, 3])
|
||||
),
|
||||
Error::<Test>::PeerIdTooLong
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_well_known_node(Origin::signed(2), test_node(40)),
|
||||
NodeAuthorization::remove_well_known_node(RuntimeOrigin::signed(2), test_node(40)),
|
||||
Error::<Test>::NotExist
|
||||
);
|
||||
|
||||
@@ -77,7 +88,10 @@ fn remove_well_known_node_works() {
|
||||
);
|
||||
assert!(AdditionalConnections::<Test>::contains_key(test_node(20)));
|
||||
|
||||
assert_ok!(NodeAuthorization::remove_well_known_node(Origin::signed(2), test_node(20)));
|
||||
assert_ok!(NodeAuthorization::remove_well_known_node(
|
||||
RuntimeOrigin::signed(2),
|
||||
test_node(20)
|
||||
));
|
||||
assert_eq!(
|
||||
WellKnownNodes::<Test>::get(),
|
||||
BTreeSet::from_iter(vec![test_node(10), test_node(30)])
|
||||
@@ -91,12 +105,16 @@ fn remove_well_known_node_works() {
|
||||
fn swap_well_known_node_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::swap_well_known_node(Origin::signed(4), test_node(20), test_node(5)),
|
||||
NodeAuthorization::swap_well_known_node(
|
||||
RuntimeOrigin::signed(4),
|
||||
test_node(20),
|
||||
test_node(5)
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::swap_well_known_node(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
PeerId(vec![1, 2, 3]),
|
||||
test_node(20)
|
||||
),
|
||||
@@ -104,7 +122,7 @@ fn swap_well_known_node_works() {
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::swap_well_known_node(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
test_node(20),
|
||||
PeerId(vec![1, 2, 3])
|
||||
),
|
||||
@@ -112,7 +130,7 @@ fn swap_well_known_node_works() {
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::swap_well_known_node(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
test_node(20),
|
||||
test_node(20)
|
||||
));
|
||||
@@ -122,12 +140,16 @@ fn swap_well_known_node_works() {
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::swap_well_known_node(Origin::signed(3), test_node(15), test_node(5)),
|
||||
NodeAuthorization::swap_well_known_node(
|
||||
RuntimeOrigin::signed(3),
|
||||
test_node(15),
|
||||
test_node(5)
|
||||
),
|
||||
Error::<Test>::NotExist
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::swap_well_known_node(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
test_node(20),
|
||||
test_node(30)
|
||||
),
|
||||
@@ -139,7 +161,7 @@ fn swap_well_known_node_works() {
|
||||
BTreeSet::from_iter(vec![test_node(15)]),
|
||||
);
|
||||
assert_ok!(NodeAuthorization::swap_well_known_node(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
test_node(20),
|
||||
test_node(5)
|
||||
));
|
||||
@@ -162,14 +184,14 @@ fn reset_well_known_nodes_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::reset_well_known_nodes(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![(test_node(15), 15), (test_node(5), 5), (test_node(20), 20)]
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::reset_well_known_nodes(
|
||||
Origin::signed(4),
|
||||
RuntimeOrigin::signed(4),
|
||||
vec![
|
||||
(test_node(15), 15),
|
||||
(test_node(5), 5),
|
||||
@@ -181,7 +203,7 @@ fn reset_well_known_nodes_works() {
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::reset_well_known_nodes(
|
||||
Origin::signed(4),
|
||||
RuntimeOrigin::signed(4),
|
||||
vec![(test_node(15), 15), (test_node(5), 5), (test_node(20), 20)]
|
||||
));
|
||||
assert_eq!(
|
||||
@@ -198,15 +220,15 @@ fn reset_well_known_nodes_works() {
|
||||
fn claim_node_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::claim_node(Origin::signed(1), PeerId(vec![1, 2, 3])),
|
||||
NodeAuthorization::claim_node(RuntimeOrigin::signed(1), PeerId(vec![1, 2, 3])),
|
||||
Error::<Test>::PeerIdTooLong
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::claim_node(Origin::signed(1), test_node(20)),
|
||||
NodeAuthorization::claim_node(RuntimeOrigin::signed(1), test_node(20)),
|
||||
Error::<Test>::AlreadyClaimed
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::claim_node(Origin::signed(15), test_node(15)));
|
||||
assert_ok!(NodeAuthorization::claim_node(RuntimeOrigin::signed(15), test_node(15)));
|
||||
assert_eq!(Owners::<Test>::get(test_node(15)), Some(15));
|
||||
});
|
||||
}
|
||||
@@ -215,21 +237,21 @@ fn claim_node_works() {
|
||||
fn remove_claim_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_claim(Origin::signed(15), PeerId(vec![1, 2, 3])),
|
||||
NodeAuthorization::remove_claim(RuntimeOrigin::signed(15), PeerId(vec![1, 2, 3])),
|
||||
Error::<Test>::PeerIdTooLong
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_claim(Origin::signed(15), test_node(15)),
|
||||
NodeAuthorization::remove_claim(RuntimeOrigin::signed(15), test_node(15)),
|
||||
Error::<Test>::NotClaimed
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_claim(Origin::signed(15), test_node(20)),
|
||||
NodeAuthorization::remove_claim(RuntimeOrigin::signed(15), test_node(20)),
|
||||
Error::<Test>::NotOwner
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_claim(Origin::signed(20), test_node(20)),
|
||||
NodeAuthorization::remove_claim(RuntimeOrigin::signed(20), test_node(20)),
|
||||
Error::<Test>::PermissionDenied
|
||||
);
|
||||
|
||||
@@ -238,7 +260,7 @@ fn remove_claim_works() {
|
||||
test_node(15),
|
||||
BTreeSet::from_iter(vec![test_node(20)]),
|
||||
);
|
||||
assert_ok!(NodeAuthorization::remove_claim(Origin::signed(15), test_node(15)));
|
||||
assert_ok!(NodeAuthorization::remove_claim(RuntimeOrigin::signed(15), test_node(15)));
|
||||
assert!(!Owners::<Test>::contains_key(test_node(15)));
|
||||
assert!(!AdditionalConnections::<Test>::contains_key(test_node(15)));
|
||||
});
|
||||
@@ -248,20 +270,20 @@ fn remove_claim_works() {
|
||||
fn transfer_node_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::transfer_node(Origin::signed(15), PeerId(vec![1, 2, 3]), 10),
|
||||
NodeAuthorization::transfer_node(RuntimeOrigin::signed(15), PeerId(vec![1, 2, 3]), 10),
|
||||
Error::<Test>::PeerIdTooLong
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::transfer_node(Origin::signed(15), test_node(15), 10),
|
||||
NodeAuthorization::transfer_node(RuntimeOrigin::signed(15), test_node(15), 10),
|
||||
Error::<Test>::NotClaimed
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::transfer_node(Origin::signed(15), test_node(20), 10),
|
||||
NodeAuthorization::transfer_node(RuntimeOrigin::signed(15), test_node(20), 10),
|
||||
Error::<Test>::NotOwner
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::transfer_node(Origin::signed(20), test_node(20), 15));
|
||||
assert_ok!(NodeAuthorization::transfer_node(RuntimeOrigin::signed(20), test_node(20), 15));
|
||||
assert_eq!(Owners::<Test>::get(test_node(20)), Some(15));
|
||||
});
|
||||
}
|
||||
@@ -271,7 +293,7 @@ fn add_connections_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
PeerId(vec![1, 2, 3]),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -279,7 +301,7 @@ fn add_connections_works() {
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
test_node(15),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -288,7 +310,7 @@ fn add_connections_works() {
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::add_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
test_node(20),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -296,7 +318,7 @@ fn add_connections_works() {
|
||||
);
|
||||
|
||||
assert_ok!(NodeAuthorization::add_connections(
|
||||
Origin::signed(20),
|
||||
RuntimeOrigin::signed(20),
|
||||
test_node(20),
|
||||
vec![test_node(15), test_node(5), test_node(25), test_node(20)]
|
||||
));
|
||||
@@ -312,7 +334,7 @@ fn remove_connections_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
PeerId(vec![1, 2, 3]),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -320,7 +342,7 @@ fn remove_connections_works() {
|
||||
);
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
test_node(15),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -329,7 +351,7 @@ fn remove_connections_works() {
|
||||
|
||||
assert_noop!(
|
||||
NodeAuthorization::remove_connections(
|
||||
Origin::signed(15),
|
||||
RuntimeOrigin::signed(15),
|
||||
test_node(20),
|
||||
vec![test_node(5)]
|
||||
),
|
||||
@@ -341,7 +363,7 @@ fn remove_connections_works() {
|
||||
BTreeSet::from_iter(vec![test_node(5), test_node(15), test_node(25)]),
|
||||
);
|
||||
assert_ok!(NodeAuthorization::remove_connections(
|
||||
Origin::signed(20),
|
||||
RuntimeOrigin::signed(20),
|
||||
test_node(20),
|
||||
vec![test_node(15), test_node(5)]
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user