mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 01:45:41 +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:
@@ -47,11 +47,11 @@ fn lock_voting_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, nay(5, 10)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, aye(4, 20)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, aye(3, 30)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, aye(2, 40)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, nay(1, 50)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, nay(5, 10)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, aye(4, 20)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(3), r, aye(3, 30)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(4), r, aye(2, 40)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, nay(1, 50)));
|
||||
assert_eq!(tally(r), Tally { ayes: 250, nays: 100, turnout: 150 });
|
||||
|
||||
// All balances are currently locked.
|
||||
@@ -62,20 +62,20 @@ fn lock_voting_should_work() {
|
||||
fast_forward_to(2);
|
||||
|
||||
// Referendum passed; 1 and 5 didn't get their way and can now reap and unlock.
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(1), r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 1));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(1), r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 1));
|
||||
// Anyone can reap and unlock anyone else's in this context.
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(2), 5, r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(2), 5));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(2), 5, r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(2), 5));
|
||||
|
||||
// 2, 3, 4 got their way with the vote, so they cannot be reaped by others.
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 2, r),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 2, r),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
// However, they can be unvoted by the owner, though it will make no difference to the lock.
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(2), r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(2), 2));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(2), r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(2), 2));
|
||||
|
||||
assert_eq!(Balances::locks(1), vec![]);
|
||||
assert_eq!(Balances::locks(2), vec![the_lock(20)]);
|
||||
@@ -87,35 +87,35 @@ fn lock_voting_should_work() {
|
||||
fast_forward_to(7);
|
||||
// No change yet...
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 4, r),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 4, r),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 4));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 4));
|
||||
assert_eq!(Balances::locks(4), vec![the_lock(40)]);
|
||||
fast_forward_to(8);
|
||||
// 4 should now be able to reap and unlock
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(1), 4, r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 4));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(1), 4, r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 4));
|
||||
assert_eq!(Balances::locks(4), vec![]);
|
||||
|
||||
fast_forward_to(13);
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 3, r),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 3, r),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 3));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 3));
|
||||
assert_eq!(Balances::locks(3), vec![the_lock(30)]);
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(1), 3, r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 3));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(1), 3, r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 3));
|
||||
assert_eq!(Balances::locks(3), vec![]);
|
||||
|
||||
// 2 doesn't need to reap_vote here because it was already done before.
|
||||
fast_forward_to(25);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 2));
|
||||
assert_eq!(Balances::locks(2), vec![the_lock(20)]);
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(1), 2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(1), 2));
|
||||
assert_eq!(Balances::locks(2), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -130,13 +130,13 @@ fn no_locks_without_conviction_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(0, 10)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(0, 10)));
|
||||
|
||||
fast_forward_to(2);
|
||||
|
||||
assert_eq!(Balances::free_balance(42), 2);
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(2), 1, r));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(2), 1));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(2), 1, r));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(2), 1));
|
||||
assert_eq!(Balances::locks(1), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -150,11 +150,11 @@ fn lock_voting_should_work_with_delegation() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, nay(5, 10)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, aye(4, 20)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, aye(3, 30)));
|
||||
assert_ok!(Democracy::delegate(Origin::signed(4), 2, Conviction::Locked2x, 40));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, nay(1, 50)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, nay(5, 10)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, aye(4, 20)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(3), r, aye(3, 30)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(4), 2, Conviction::Locked2x, 40));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, nay(1, 50)));
|
||||
|
||||
assert_eq!(tally(r), Tally { ayes: 250, nays: 100, turnout: 150 });
|
||||
|
||||
@@ -173,7 +173,7 @@ fn setup_three_referenda() -> (u32, u32, u32) {
|
||||
VoteThreshold::SimpleMajority,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r1, aye(4, 10)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r1, aye(4, 10)));
|
||||
|
||||
let r2 = Democracy::inject_referendum(
|
||||
2,
|
||||
@@ -181,7 +181,7 @@ fn setup_three_referenda() -> (u32, u32, u32) {
|
||||
VoteThreshold::SimpleMajority,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r2, aye(3, 20)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r2, aye(3, 20)));
|
||||
|
||||
let r3 = Democracy::inject_referendum(
|
||||
2,
|
||||
@@ -189,7 +189,7 @@ fn setup_three_referenda() -> (u32, u32, u32) {
|
||||
VoteThreshold::SimpleMajority,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r3, aye(2, 50)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r3, aye(2, 50)));
|
||||
|
||||
fast_forward_to(2);
|
||||
|
||||
@@ -206,36 +206,36 @@ fn prior_lockvotes_should_be_enforced() {
|
||||
|
||||
fast_forward_to(7);
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 5, r.2),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.2),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(50)]);
|
||||
fast_forward_to(8);
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(1), 5, r.2));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(20)]);
|
||||
fast_forward_to(13);
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 5, r.1),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.1),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(20)]);
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(1), 5, r.1));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.1));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(10)]);
|
||||
fast_forward_to(25);
|
||||
assert_noop!(
|
||||
Democracy::remove_other_vote(Origin::signed(1), 5, r.0),
|
||||
Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.0),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(10)]);
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::remove_other_vote(Origin::signed(1), 5, r.0));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_other_vote(RuntimeOrigin::signed(1), 5, r.0));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -249,27 +249,27 @@ fn single_consolidation_of_lockvotes_should_work_as_before() {
|
||||
// r.2 locked 50 until 2 + 2 * 3 = #8
|
||||
|
||||
fast_forward_to(7);
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.2));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(50)]);
|
||||
fast_forward_to(8);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(20)]);
|
||||
|
||||
fast_forward_to(13);
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.1));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.1));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(20)]);
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(10)]);
|
||||
|
||||
fast_forward_to(25);
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.0));
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.0));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![the_lock(10)]);
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -282,20 +282,20 @@ fn multi_consolidation_of_lockvotes_should_be_conservative() {
|
||||
// r.1 locked 20 until 2 + 4 * 3 = #14
|
||||
// r.2 locked 50 until 2 + 2 * 3 = #8
|
||||
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.2));
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.1));
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.0));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.2));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.1));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.0));
|
||||
|
||||
fast_forward_to(8);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 20);
|
||||
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 10);
|
||||
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -310,32 +310,32 @@ fn locks_should_persist_from_voting_to_delegation() {
|
||||
VoteThreshold::SimpleMajority,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, aye(4, 10)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, aye(4, 10)));
|
||||
fast_forward_to(2);
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r));
|
||||
// locked 10 until #26.
|
||||
|
||||
assert_ok!(Democracy::delegate(Origin::signed(5), 1, Conviction::Locked3x, 20));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(5), 1, Conviction::Locked3x, 20));
|
||||
// locked 20.
|
||||
assert!(Balances::locks(5)[0].amount == 20);
|
||||
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(5)));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(5)));
|
||||
// locked 20 until #14
|
||||
|
||||
fast_forward_to(13);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount == 20);
|
||||
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 10);
|
||||
|
||||
fast_forward_to(25);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 10);
|
||||
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -344,8 +344,8 @@ fn locks_should_persist_from_voting_to_delegation() {
|
||||
fn locks_should_persist_from_delegation_to_voting() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_ok!(Democracy::delegate(Origin::signed(5), 1, Conviction::Locked5x, 5));
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(5)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(5), 1, Conviction::Locked5x, 5));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(5)));
|
||||
// locked 5 until 16 * 3 = #48
|
||||
|
||||
let r = setup_three_referenda();
|
||||
@@ -353,24 +353,24 @@ fn locks_should_persist_from_delegation_to_voting() {
|
||||
// r.1 locked 20 until 2 + 4 * 3 = #14
|
||||
// r.2 locked 50 until 2 + 2 * 3 = #8
|
||||
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.2));
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.1));
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r.0));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.2));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.1));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r.0));
|
||||
|
||||
fast_forward_to(8);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 20);
|
||||
|
||||
fast_forward_to(14);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 10);
|
||||
|
||||
fast_forward_to(26);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert!(Balances::locks(5)[0].amount >= 5);
|
||||
|
||||
fast_forward_to(48);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user