mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +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:
@@ -56,7 +56,7 @@ impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
@@ -148,41 +148,44 @@ fn editing_subaccounts_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data = |x| Data::Raw(vec![x; 1].try_into().unwrap());
|
||||
|
||||
assert_noop!(Identity::add_sub(Origin::signed(10), 20, data(1)), Error::<Test>::NoIdentity);
|
||||
assert_noop!(
|
||||
Identity::add_sub(RuntimeOrigin::signed(10), 20, data(1)),
|
||||
Error::<Test>::NoIdentity
|
||||
);
|
||||
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
|
||||
// first sub account
|
||||
assert_ok!(Identity::add_sub(Origin::signed(10), 1, data(1)));
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 1, data(1)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(1))));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
|
||||
// second sub account
|
||||
assert_ok!(Identity::add_sub(Origin::signed(10), 2, data(2)));
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 2, data(2)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(1))));
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
|
||||
// third sub account is too many
|
||||
assert_noop!(
|
||||
Identity::add_sub(Origin::signed(10), 3, data(3)),
|
||||
Identity::add_sub(RuntimeOrigin::signed(10), 3, data(3)),
|
||||
Error::<Test>::TooManySubAccounts
|
||||
);
|
||||
|
||||
// rename first sub account
|
||||
assert_ok!(Identity::rename_sub(Origin::signed(10), 1, data(11)));
|
||||
assert_ok!(Identity::rename_sub(RuntimeOrigin::signed(10), 1, data(11)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), Some((10, data(11))));
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
|
||||
// remove first sub account
|
||||
assert_ok!(Identity::remove_sub(Origin::signed(10), 1));
|
||||
assert_ok!(Identity::remove_sub(RuntimeOrigin::signed(10), 1));
|
||||
assert_eq!(SuperOf::<Test>::get(1), None);
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
|
||||
// add third sub account
|
||||
assert_ok!(Identity::add_sub(Origin::signed(10), 3, data(3)));
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 3, data(3)));
|
||||
assert_eq!(SuperOf::<Test>::get(1), None);
|
||||
assert_eq!(SuperOf::<Test>::get(2), Some((10, data(2))));
|
||||
assert_eq!(SuperOf::<Test>::get(3), Some((10, data(3))));
|
||||
@@ -195,27 +198,27 @@ fn resolving_subaccount_ownership_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data = |x| Data::Raw(vec![x; 1].try_into().unwrap());
|
||||
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(20), Box::new(twenty())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(20), Box::new(twenty())));
|
||||
|
||||
// 10 claims 1 as a subaccount
|
||||
assert_ok!(Identity::add_sub(Origin::signed(10), 1, data(1)));
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(10), 1, data(1)));
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::reserved_balance(10), 20);
|
||||
// 20 cannot claim 1 now
|
||||
assert_noop!(
|
||||
Identity::add_sub(Origin::signed(20), 1, data(1)),
|
||||
Identity::add_sub(RuntimeOrigin::signed(20), 1, data(1)),
|
||||
Error::<Test>::AlreadyClaimed
|
||||
);
|
||||
// 1 wants to be with 20 so it quits from 10
|
||||
assert_ok!(Identity::quit_sub(Origin::signed(1)));
|
||||
assert_ok!(Identity::quit_sub(RuntimeOrigin::signed(1)));
|
||||
// 1 gets the 10 that 10 paid.
|
||||
assert_eq!(Balances::free_balance(1), 20);
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Balances::reserved_balance(10), 10);
|
||||
// 20 can claim 1 now
|
||||
assert_ok!(Identity::add_sub(Origin::signed(20), 1, data(1)));
|
||||
assert_ok!(Identity::add_sub(RuntimeOrigin::signed(20), 1, data(1)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -232,10 +235,10 @@ fn trailing_zeros_decodes_into_default_data() {
|
||||
#[test]
|
||||
fn adding_registrar_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
let fields = IdentityFields(IdentityField::Display | IdentityField::Legal);
|
||||
assert_ok!(Identity::set_fields(Origin::signed(3), 0, fields));
|
||||
assert_ok!(Identity::set_fields(RuntimeOrigin::signed(3), 0, fields));
|
||||
assert_eq!(
|
||||
Identity::registrars(),
|
||||
vec![Some(RegistrarInfo { account: 3, fee: 10, fields })]
|
||||
@@ -247,11 +250,11 @@ fn adding_registrar_should_work() {
|
||||
fn amount_of_registrars_is_limited() {
|
||||
new_test_ext().execute_with(|| {
|
||||
for i in 1..MaxRegistrars::get() + 1 {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), i as u64));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), i as u64));
|
||||
}
|
||||
let last_registrar = MaxRegistrars::get() as u64 + 1;
|
||||
assert_noop!(
|
||||
Identity::add_registrar(Origin::signed(1), last_registrar),
|
||||
Identity::add_registrar(RuntimeOrigin::signed(1), last_registrar),
|
||||
Error::<Test>::TooManyRegistrars
|
||||
);
|
||||
});
|
||||
@@ -260,18 +263,18 @@ fn amount_of_registrars_is_limited() {
|
||||
#[test]
|
||||
fn registration_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
let mut three_fields = ten();
|
||||
three_fields.additional.try_push(Default::default()).unwrap();
|
||||
three_fields.additional.try_push(Default::default()).unwrap();
|
||||
assert_eq!(three_fields.additional.try_push(Default::default()), Err(()));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_eq!(Identity::identity(10).unwrap().info, ten());
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_ok!(Identity::clear_identity(Origin::signed(10)));
|
||||
assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(10)));
|
||||
assert_eq!(Balances::free_balance(10), 100);
|
||||
assert_noop!(Identity::clear_identity(Origin::signed(10)), Error::<Test>::NotNamed);
|
||||
assert_noop!(Identity::clear_identity(RuntimeOrigin::signed(10)), Error::<Test>::NotNamed);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -280,7 +283,7 @@ fn uninvited_judgement_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
@@ -289,10 +292,10 @@ fn uninvited_judgement_should_work() {
|
||||
Error::<Test>::InvalidIndex
|
||||
);
|
||||
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_noop!(
|
||||
Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
@@ -301,10 +304,10 @@ fn uninvited_judgement_should_work() {
|
||||
Error::<Test>::InvalidTarget
|
||||
);
|
||||
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_noop!(
|
||||
Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
@@ -317,7 +320,7 @@ fn uninvited_judgement_should_work() {
|
||||
|
||||
assert_noop!(
|
||||
Identity::provide_judgement(
|
||||
Origin::signed(10),
|
||||
RuntimeOrigin::signed(10),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
@@ -327,7 +330,7 @@ fn uninvited_judgement_should_work() {
|
||||
);
|
||||
assert_noop!(
|
||||
Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::FeePaid(1),
|
||||
@@ -337,7 +340,7 @@ fn uninvited_judgement_should_work() {
|
||||
);
|
||||
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
@@ -350,16 +353,16 @@ fn uninvited_judgement_should_work() {
|
||||
#[test]
|
||||
fn clearing_judgement_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
));
|
||||
assert_ok!(Identity::clear_identity(Origin::signed(10)));
|
||||
assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(10)));
|
||||
assert_eq!(Identity::identity(10), None);
|
||||
});
|
||||
}
|
||||
@@ -367,12 +370,15 @@ fn clearing_judgement_should_work() {
|
||||
#[test]
|
||||
fn killing_slashing_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_noop!(Identity::kill_identity(Origin::signed(1), 10), BadOrigin);
|
||||
assert_ok!(Identity::kill_identity(Origin::signed(2), 10));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_noop!(Identity::kill_identity(RuntimeOrigin::signed(1), 10), BadOrigin);
|
||||
assert_ok!(Identity::kill_identity(RuntimeOrigin::signed(2), 10));
|
||||
assert_eq!(Identity::identity(10), None);
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_noop!(Identity::kill_identity(Origin::signed(2), 10), Error::<Test>::NotNamed);
|
||||
assert_noop!(
|
||||
Identity::kill_identity(RuntimeOrigin::signed(2), 10),
|
||||
Error::<Test>::NotNamed
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -380,17 +386,20 @@ fn killing_slashing_should_work() {
|
||||
fn setting_subaccounts_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let mut subs = vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))];
|
||||
assert_noop!(Identity::set_subs(Origin::signed(10), subs.clone()), Error::<Test>::NotFound);
|
||||
assert_noop!(
|
||||
Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()),
|
||||
Error::<Test>::NotFound
|
||||
);
|
||||
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Identity::subs_of(10), (10, vec![20].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1].try_into().unwrap()))));
|
||||
|
||||
// push another item and re-set it.
|
||||
subs.push((30, Data::Raw(vec![50; 1].try_into().unwrap())));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![20, 30].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1].try_into().unwrap()))));
|
||||
@@ -398,7 +407,7 @@ fn setting_subaccounts_should_work() {
|
||||
|
||||
// switch out one of the items and re-set.
|
||||
subs[0] = (40, Data::Raw(vec![60; 1].try_into().unwrap()));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70); // no change in the balance
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![40, 30].try_into().unwrap()));
|
||||
assert_eq!(Identity::super_of(20), None);
|
||||
@@ -406,7 +415,7 @@ fn setting_subaccounts_should_work() {
|
||||
assert_eq!(Identity::super_of(40), Some((10, Data::Raw(vec![60; 1].try_into().unwrap()))));
|
||||
|
||||
// clear
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), vec![]));
|
||||
assert_ok!(Identity::set_subs(RuntimeOrigin::signed(10), vec![]));
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_eq!(Identity::subs_of(10), (0, BoundedVec::default()));
|
||||
assert_eq!(Identity::super_of(30), None);
|
||||
@@ -414,7 +423,7 @@ fn setting_subaccounts_should_work() {
|
||||
|
||||
subs.push((20, Data::Raw(vec![40; 1].try_into().unwrap())));
|
||||
assert_noop!(
|
||||
Identity::set_subs(Origin::signed(10), subs.clone()),
|
||||
Identity::set_subs(RuntimeOrigin::signed(10), subs.clone()),
|
||||
Error::<Test>::TooManySubAccounts
|
||||
);
|
||||
});
|
||||
@@ -423,12 +432,12 @@ fn setting_subaccounts_should_work() {
|
||||
#[test]
|
||||
fn clearing_account_should_remove_subaccounts_and_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_subs(
|
||||
Origin::signed(10),
|
||||
RuntimeOrigin::signed(10),
|
||||
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
|
||||
));
|
||||
assert_ok!(Identity::clear_identity(Origin::signed(10)));
|
||||
assert_ok!(Identity::clear_identity(RuntimeOrigin::signed(10)));
|
||||
assert_eq!(Balances::free_balance(10), 100);
|
||||
assert!(Identity::super_of(20).is_none());
|
||||
});
|
||||
@@ -437,12 +446,12 @@ fn clearing_account_should_remove_subaccounts_and_refund() {
|
||||
#[test]
|
||||
fn killing_account_should_remove_subaccounts_and_not_refund() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_subs(
|
||||
Origin::signed(10),
|
||||
RuntimeOrigin::signed(10),
|
||||
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
|
||||
));
|
||||
assert_ok!(Identity::kill_identity(Origin::signed(2), 10));
|
||||
assert_ok!(Identity::kill_identity(RuntimeOrigin::signed(2), 10));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert!(Identity::super_of(20).is_none());
|
||||
});
|
||||
@@ -451,24 +460,30 @@ fn killing_account_should_remove_subaccounts_and_not_refund() {
|
||||
#[test]
|
||||
fn cancelling_requested_judgement_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
|
||||
assert_noop!(Identity::cancel_request(Origin::signed(10), 0), Error::<Test>::NoIdentity);
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10));
|
||||
assert_ok!(Identity::cancel_request(Origin::signed(10), 0));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_noop!(
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
Error::<Test>::NoIdentity
|
||||
);
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
assert_ok!(Identity::cancel_request(RuntimeOrigin::signed(10), 0));
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_noop!(Identity::cancel_request(Origin::signed(10), 0), Error::<Test>::NotFound);
|
||||
assert_noop!(
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
Error::<Test>::NotFound
|
||||
);
|
||||
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Reasonable,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
));
|
||||
assert_noop!(
|
||||
Identity::cancel_request(Origin::signed(10), 0),
|
||||
Identity::cancel_request(RuntimeOrigin::signed(10), 0),
|
||||
Error::<Test>::JudgementGiven
|
||||
);
|
||||
});
|
||||
@@ -477,24 +492,24 @@ fn cancelling_requested_judgement_should_work() {
|
||||
#[test]
|
||||
fn requesting_judgement_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert_noop!(
|
||||
Identity::request_judgement(Origin::signed(10), 0, 9),
|
||||
Identity::request_judgement(RuntimeOrigin::signed(10), 0, 9),
|
||||
Error::<Test>::FeeChanged
|
||||
);
|
||||
assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
// 10 for the judgement request, 10 for the identity.
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
|
||||
// Re-requesting won't work as we already paid.
|
||||
assert_noop!(
|
||||
Identity::request_judgement(Origin::signed(10), 0, 10),
|
||||
Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10),
|
||||
Error::<Test>::StickyJudgement
|
||||
);
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::Erroneous,
|
||||
@@ -505,33 +520,33 @@ fn requesting_judgement_should_work() {
|
||||
|
||||
// Re-requesting still won't work as it's erroneous.
|
||||
assert_noop!(
|
||||
Identity::request_judgement(Origin::signed(10), 0, 10),
|
||||
Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10),
|
||||
Error::<Test>::StickyJudgement
|
||||
);
|
||||
|
||||
// Requesting from a second registrar still works.
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 4));
|
||||
assert_ok!(Identity::request_judgement(Origin::signed(10), 1, 10));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 4));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 1, 10));
|
||||
|
||||
// Re-requesting after the judgement has been reduced works.
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
0,
|
||||
10,
|
||||
Judgement::OutOfDate,
|
||||
BlakeTwo256::hash_of(&ten())
|
||||
));
|
||||
assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10));
|
||||
assert_ok!(Identity::request_judgement(RuntimeOrigin::signed(10), 0, 10));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn field_deposit_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
assert_ok!(Identity::set_fee(RuntimeOrigin::signed(3), 0, 10));
|
||||
assert_ok!(Identity::set_identity(
|
||||
Origin::signed(10),
|
||||
RuntimeOrigin::signed(10),
|
||||
Box::new(IdentityInfo {
|
||||
additional: vec![
|
||||
(
|
||||
@@ -555,23 +570,23 @@ fn field_deposit_should_work() {
|
||||
#[test]
|
||||
fn setting_account_id_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 3));
|
||||
// account 4 cannot change the first registrar's identity since it's owned by 3.
|
||||
assert_noop!(
|
||||
Identity::set_account_id(Origin::signed(4), 0, 3),
|
||||
Identity::set_account_id(RuntimeOrigin::signed(4), 0, 3),
|
||||
Error::<Test>::InvalidIndex
|
||||
);
|
||||
// account 3 can, because that's the registrar's current account.
|
||||
assert_ok!(Identity::set_account_id(Origin::signed(3), 0, 4));
|
||||
assert_ok!(Identity::set_account_id(RuntimeOrigin::signed(3), 0, 4));
|
||||
// account 4 can now, because that's their new ID.
|
||||
assert_ok!(Identity::set_account_id(Origin::signed(4), 0, 3));
|
||||
assert_ok!(Identity::set_account_id(RuntimeOrigin::signed(4), 0, 3));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_has_identity() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), Box::new(ten())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(10), Box::new(ten())));
|
||||
assert!(Identity::has_identity(&10, IdentityField::Display as u64));
|
||||
assert!(Identity::has_identity(&10, IdentityField::Legal as u64));
|
||||
assert!(Identity::has_identity(
|
||||
|
||||
Reference in New Issue
Block a user