mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 02: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:
@@ -65,7 +65,7 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -230,9 +230,9 @@ fn tip_hash() -> H256 {
|
||||
fn tip_new_cannot_be_used_twice() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::tip_new(Origin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
assert_noop!(
|
||||
Tips::tip_new(Origin::signed(11), b"awesome.dot".to_vec(), 3, 10),
|
||||
Tips::tip_new(RuntimeOrigin::signed(11), b"awesome.dot".to_vec(), 3, 10),
|
||||
Error::<Test>::AlreadyKnown
|
||||
);
|
||||
});
|
||||
@@ -242,23 +242,23 @@ fn tip_new_cannot_be_used_twice() {
|
||||
fn report_awesome_and_tip_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_ok!(Tips::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_eq!(Balances::reserved_balance(0), 12);
|
||||
assert_eq!(Balances::free_balance(0), 88);
|
||||
|
||||
// other reports don't count.
|
||||
assert_noop!(
|
||||
Tips::report_awesome(Origin::signed(1), b"awesome.dot".to_vec(), 3),
|
||||
Tips::report_awesome(RuntimeOrigin::signed(1), b"awesome.dot".to_vec(), 3),
|
||||
Error::<Test>::AlreadyKnown
|
||||
);
|
||||
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips::tip(Origin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10));
|
||||
assert_noop!(Tips::tip(Origin::signed(9), h, 10), BadOrigin);
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
assert_noop!(Tips::tip(RuntimeOrigin::signed(9), h, 10), BadOrigin);
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Tips::close_tip(Origin::signed(100), h.into()));
|
||||
assert_ok!(Tips::close_tip(RuntimeOrigin::signed(100), h.into()));
|
||||
assert_eq!(Balances::reserved_balance(0), 0);
|
||||
assert_eq!(Balances::free_balance(0), 102);
|
||||
assert_eq!(Balances::free_balance(3), 8);
|
||||
@@ -269,15 +269,15 @@ fn report_awesome_and_tip_works() {
|
||||
fn report_awesome_from_beneficiary_and_tip_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 0));
|
||||
assert_ok!(Tips::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 0));
|
||||
assert_eq!(Balances::reserved_balance(0), 12);
|
||||
assert_eq!(Balances::free_balance(0), 88);
|
||||
let h = BlakeTwo256::hash_of(&(BlakeTwo256::hash(b"awesome.dot"), 0u128));
|
||||
assert_ok!(Tips::tip(Origin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Tips::close_tip(Origin::signed(100), h.into()));
|
||||
assert_ok!(Tips::close_tip(RuntimeOrigin::signed(100), h.into()));
|
||||
assert_eq!(Balances::reserved_balance(0), 0);
|
||||
assert_eq!(Balances::free_balance(0), 110);
|
||||
});
|
||||
@@ -291,30 +291,33 @@ fn close_tip_works() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
assert_ok!(Tips::tip_new(Origin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
|
||||
let h = tip_hash();
|
||||
|
||||
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });
|
||||
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
|
||||
assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::StillOpen);
|
||||
assert_noop!(Tips::close_tip(RuntimeOrigin::signed(0), h.into()), Error::<Test>::StillOpen);
|
||||
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
|
||||
assert_eq!(last_event(), TipEvent::TipClosing { tip_hash: h });
|
||||
|
||||
assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::Premature);
|
||||
assert_noop!(Tips::close_tip(RuntimeOrigin::signed(0), h.into()), Error::<Test>::Premature);
|
||||
|
||||
System::set_block_number(2);
|
||||
assert_noop!(Tips::close_tip(Origin::none(), h.into()), BadOrigin);
|
||||
assert_ok!(Tips::close_tip(Origin::signed(0), h.into()));
|
||||
assert_noop!(Tips::close_tip(RuntimeOrigin::none(), h.into()), BadOrigin);
|
||||
assert_ok!(Tips::close_tip(RuntimeOrigin::signed(0), h.into()));
|
||||
assert_eq!(Balances::free_balance(3), 10);
|
||||
|
||||
assert_eq!(last_event(), TipEvent::TipClosed { tip_hash: h, who: 3, payout: 10 });
|
||||
|
||||
assert_noop!(Tips::close_tip(Origin::signed(100), h.into()), Error::<Test>::UnknownTip);
|
||||
assert_noop!(
|
||||
Tips::close_tip(RuntimeOrigin::signed(100), h.into()),
|
||||
Error::<Test>::UnknownTip
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -328,7 +331,7 @@ fn slash_tip_works() {
|
||||
assert_eq!(Balances::reserved_balance(0), 0);
|
||||
assert_eq!(Balances::free_balance(0), 100);
|
||||
|
||||
assert_ok!(Tips::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_ok!(Tips::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
|
||||
assert_eq!(Balances::reserved_balance(0), 12);
|
||||
assert_eq!(Balances::free_balance(0), 88);
|
||||
@@ -337,10 +340,10 @@ fn slash_tip_works() {
|
||||
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });
|
||||
|
||||
// can't remove from any origin
|
||||
assert_noop!(Tips::slash_tip(Origin::signed(0), h), BadOrigin);
|
||||
assert_noop!(Tips::slash_tip(RuntimeOrigin::signed(0), h), BadOrigin);
|
||||
|
||||
// can remove from root.
|
||||
assert_ok!(Tips::slash_tip(Origin::root(), h));
|
||||
assert_ok!(Tips::slash_tip(RuntimeOrigin::root(), h));
|
||||
assert_eq!(last_event(), TipEvent::TipSlashed { tip_hash: h, finder: 0, deposit: 12 });
|
||||
|
||||
// tipper slashed
|
||||
@@ -354,26 +357,32 @@ fn retract_tip_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// with report awesome
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_ok!(Tips::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips::tip(Origin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10));
|
||||
assert_noop!(Tips::retract_tip(Origin::signed(10), h), Error::<Test>::NotFinder);
|
||||
assert_ok!(Tips::retract_tip(Origin::signed(0), h));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
assert_noop!(Tips::retract_tip(RuntimeOrigin::signed(10), h), Error::<Test>::NotFinder);
|
||||
assert_ok!(Tips::retract_tip(RuntimeOrigin::signed(0), h));
|
||||
System::set_block_number(2);
|
||||
assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::UnknownTip);
|
||||
assert_noop!(
|
||||
Tips::close_tip(RuntimeOrigin::signed(0), h.into()),
|
||||
Error::<Test>::UnknownTip
|
||||
);
|
||||
|
||||
// with tip new
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::tip_new(Origin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 10));
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10));
|
||||
assert_noop!(Tips::retract_tip(Origin::signed(0), h), Error::<Test>::NotFinder);
|
||||
assert_ok!(Tips::retract_tip(Origin::signed(10), h));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
assert_noop!(Tips::retract_tip(RuntimeOrigin::signed(0), h), Error::<Test>::NotFinder);
|
||||
assert_ok!(Tips::retract_tip(RuntimeOrigin::signed(10), h));
|
||||
System::set_block_number(2);
|
||||
assert_noop!(Tips::close_tip(Origin::signed(10), h.into()), Error::<Test>::UnknownTip);
|
||||
assert_noop!(
|
||||
Tips::close_tip(RuntimeOrigin::signed(10), h.into()),
|
||||
Error::<Test>::UnknownTip
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -381,12 +390,12 @@ fn retract_tip_works() {
|
||||
fn tip_median_calculation_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::tip_new(Origin::signed(10), b"awesome.dot".to_vec(), 3, 0));
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 0));
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 1000000));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 1000000));
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Tips::close_tip(Origin::signed(0), h.into()));
|
||||
assert_ok!(Tips::close_tip(RuntimeOrigin::signed(0), h.into()));
|
||||
assert_eq!(Balances::free_balance(3), 10);
|
||||
});
|
||||
}
|
||||
@@ -395,17 +404,17 @@ fn tip_median_calculation_works() {
|
||||
fn tip_changing_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::tip_new(Origin::signed(10), b"awesome.dot".to_vec(), 3, 10000));
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 10000));
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 10000));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 10000));
|
||||
assert_ok!(Tips::tip(Origin::signed(13), h, 0));
|
||||
assert_ok!(Tips::tip(Origin::signed(14), h, 0));
|
||||
assert_ok!(Tips::tip(Origin::signed(12), h, 1000));
|
||||
assert_ok!(Tips::tip(Origin::signed(11), h, 100));
|
||||
assert_ok!(Tips::tip(Origin::signed(10), h, 10));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 10000));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 10000));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(13), h, 0));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(14), h, 0));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(12), h, 1000));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(11), h, 100));
|
||||
assert_ok!(Tips::tip(RuntimeOrigin::signed(10), h, 10));
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Tips::close_tip(Origin::signed(0), h.into()));
|
||||
assert_ok!(Tips::close_tip(RuntimeOrigin::signed(0), h.into()));
|
||||
assert_eq!(Balances::free_balance(3), 10);
|
||||
});
|
||||
}
|
||||
@@ -582,24 +591,24 @@ fn report_awesome_and_tip_works_second_instance() {
|
||||
assert_eq!(Balances::free_balance(&Treasury::account_id()), 101);
|
||||
assert_eq!(Balances::free_balance(&Treasury1::account_id()), 201);
|
||||
|
||||
assert_ok!(Tips1::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_ok!(Tips1::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
// duplicate report in tips1 reports don't count.
|
||||
assert_noop!(
|
||||
Tips1::report_awesome(Origin::signed(1), b"awesome.dot".to_vec(), 3),
|
||||
Tips1::report_awesome(RuntimeOrigin::signed(1), b"awesome.dot".to_vec(), 3),
|
||||
Error::<Test, Instance1>::AlreadyKnown
|
||||
);
|
||||
// but tips is separate
|
||||
assert_ok!(Tips::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
assert_ok!(Tips::report_awesome(RuntimeOrigin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
|
||||
let h = tip_hash();
|
||||
assert_ok!(Tips1::tip(Origin::signed(10), h, 10));
|
||||
assert_ok!(Tips1::tip(Origin::signed(11), h, 10));
|
||||
assert_ok!(Tips1::tip(Origin::signed(12), h, 10));
|
||||
assert_noop!(Tips1::tip(Origin::signed(9), h, 10), BadOrigin);
|
||||
assert_ok!(Tips1::tip(RuntimeOrigin::signed(10), h, 10));
|
||||
assert_ok!(Tips1::tip(RuntimeOrigin::signed(11), h, 10));
|
||||
assert_ok!(Tips1::tip(RuntimeOrigin::signed(12), h, 10));
|
||||
assert_noop!(Tips1::tip(RuntimeOrigin::signed(9), h, 10), BadOrigin);
|
||||
|
||||
System::set_block_number(2);
|
||||
|
||||
assert_ok!(Tips1::close_tip(Origin::signed(100), h.into()));
|
||||
assert_ok!(Tips1::close_tip(RuntimeOrigin::signed(100), h.into()));
|
||||
// Treasury 1 unchanged
|
||||
assert_eq!(Balances::free_balance(&Treasury::account_id()), 101);
|
||||
// Treasury 2 gave the funds
|
||||
|
||||
Reference in New Issue
Block a user