mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 10:17: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:
@@ -28,8 +28,8 @@ fn cancel_referendum_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::cancel_referendum(Origin::root(), r.into()));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::cancel_referendum(RuntimeOrigin::root(), r.into()));
|
||||
assert_eq!(Democracy::lowest_unbaked(), 0);
|
||||
|
||||
next_block();
|
||||
@@ -51,14 +51,17 @@ fn cancel_queued_should_work() {
|
||||
// start of 2 => next referendum scheduled.
|
||||
fast_forward_to(2);
|
||||
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 0, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 0, aye(1)));
|
||||
|
||||
fast_forward_to(4);
|
||||
|
||||
assert!(pallet_scheduler::Agenda::<Test>::get(6)[0].is_some());
|
||||
|
||||
assert_noop!(Democracy::cancel_queued(Origin::root(), 1), Error::<Test>::ProposalMissing);
|
||||
assert_ok!(Democracy::cancel_queued(Origin::root(), 0));
|
||||
assert_noop!(
|
||||
Democracy::cancel_queued(RuntimeOrigin::root(), 1),
|
||||
Error::<Test>::ProposalMissing
|
||||
);
|
||||
assert_ok!(Democracy::cancel_queued(RuntimeOrigin::root(), 0));
|
||||
assert!(pallet_scheduler::Agenda::<Test>::get(6)[0].is_none());
|
||||
});
|
||||
}
|
||||
@@ -75,8 +78,8 @@ fn emergency_cancel_should_work() {
|
||||
);
|
||||
assert!(Democracy::referendum_status(r).is_ok());
|
||||
|
||||
assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), BadOrigin);
|
||||
assert_ok!(Democracy::emergency_cancel(Origin::signed(4), r));
|
||||
assert_noop!(Democracy::emergency_cancel(RuntimeOrigin::signed(3), r), BadOrigin);
|
||||
assert_ok!(Democracy::emergency_cancel(RuntimeOrigin::signed(4), r));
|
||||
assert!(Democracy::referendum_info(r).is_none());
|
||||
|
||||
// some time later...
|
||||
@@ -89,7 +92,7 @@ fn emergency_cancel_should_work() {
|
||||
);
|
||||
assert!(Democracy::referendum_status(r).is_ok());
|
||||
assert_noop!(
|
||||
Democracy::emergency_cancel(Origin::signed(4), r),
|
||||
Democracy::emergency_cancel(RuntimeOrigin::signed(4), r),
|
||||
Error::<Test>::AlreadyCanceled,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -29,33 +29,33 @@ fn single_proposal_should_work_with_delegation() {
|
||||
fast_forward_to(2);
|
||||
|
||||
// Delegate first vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 20));
|
||||
let r = 0;
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 0, turnout: 30 });
|
||||
|
||||
// Delegate a second vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(3), 1, Conviction::None, 30));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(3), 1, Conviction::None, 30));
|
||||
assert_eq!(tally(r), Tally { ayes: 6, nays: 0, turnout: 60 });
|
||||
|
||||
// Reduce first vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 10));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 10));
|
||||
assert_eq!(tally(r), Tally { ayes: 5, nays: 0, turnout: 50 });
|
||||
|
||||
// Second vote delegates to first; we don't do tiered delegation, so it doesn't get used.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(3), 2, Conviction::None, 30));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(3), 2, Conviction::None, 30));
|
||||
assert_eq!(tally(r), Tally { ayes: 2, nays: 0, turnout: 20 });
|
||||
|
||||
// Main voter cancels their vote
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(1), r));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(1), r));
|
||||
assert_eq!(tally(r), Tally { ayes: 0, nays: 0, turnout: 0 });
|
||||
|
||||
// First delegator delegates half funds with conviction; nothing changes yet.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::Locked1x, 10));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::Locked1x, 10));
|
||||
assert_eq!(tally(r), Tally { ayes: 0, nays: 0, turnout: 0 });
|
||||
|
||||
// Main voter reinstates their vote
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_eq!(tally(r), Tally { ayes: 11, nays: 0, turnout: 20 });
|
||||
});
|
||||
}
|
||||
@@ -64,7 +64,7 @@ fn single_proposal_should_work_with_delegation() {
|
||||
fn self_delegation_not_allowed() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Democracy::delegate(Origin::signed(1), 1, Conviction::None, 10),
|
||||
Democracy::delegate(RuntimeOrigin::signed(1), 1, Conviction::None, 10),
|
||||
Error::<Test>::Nonsense,
|
||||
);
|
||||
});
|
||||
@@ -80,14 +80,14 @@ fn cyclic_delegation_should_unwind() {
|
||||
fast_forward_to(2);
|
||||
|
||||
// Check behavior with cycle.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::delegate(Origin::signed(3), 2, Conviction::None, 30));
|
||||
assert_ok!(Democracy::delegate(Origin::signed(1), 3, Conviction::None, 10));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(3), 2, Conviction::None, 30));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(1), 3, Conviction::None, 10));
|
||||
let r = 0;
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(3)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, aye(3)));
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(1)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, nay(1)));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(3)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(3), r, aye(3)));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, nay(1)));
|
||||
|
||||
// Delegated vote is counted.
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 3, turnout: 60 });
|
||||
@@ -105,13 +105,13 @@ fn single_proposal_should_work_with_vote_and_delegation() {
|
||||
fast_forward_to(2);
|
||||
|
||||
let r = 0;
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, nay(2)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, nay(2)));
|
||||
assert_eq!(tally(r), Tally { ayes: 1, nays: 2, turnout: 30 });
|
||||
|
||||
// Delegate vote.
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(2), r));
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(2), r));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 20));
|
||||
// Delegated vote replaces the explicit vote.
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 0, turnout: 30 });
|
||||
});
|
||||
@@ -125,12 +125,12 @@ fn single_proposal_should_work_with_undelegation() {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 1));
|
||||
|
||||
// Delegate and undelegate vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(2)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(2)));
|
||||
|
||||
fast_forward_to(2);
|
||||
let r = 0;
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
|
||||
// Delegated vote is not counted.
|
||||
assert_eq!(tally(r), Tally { ayes: 1, nays: 0, turnout: 10 });
|
||||
@@ -143,11 +143,11 @@ fn single_proposal_should_work_with_delegation_and_vote() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
// Delegate, undelegate and vote.
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::None, 20));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::None, 20));
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 0, turnout: 30 });
|
||||
assert_ok!(Democracy::undelegate(Origin::signed(2)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, aye(2)));
|
||||
assert_ok!(Democracy::undelegate(RuntimeOrigin::signed(2)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, aye(2)));
|
||||
// Delegated vote is not counted.
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 0, turnout: 30 });
|
||||
});
|
||||
@@ -159,8 +159,8 @@ fn conviction_should_be_honored_in_delegation() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
// Delegate and vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
// Delegated vote is huge.
|
||||
assert_eq!(tally(r), Tally { ayes: 121, nays: 0, turnout: 30 });
|
||||
});
|
||||
@@ -171,8 +171,12 @@ fn split_vote_delegation_should_be_ignored() {
|
||||
// If transactor voted, delegated vote is overwritten.
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, AccountVote::Split { aye: 10, nay: 0 }));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(
|
||||
RuntimeOrigin::signed(1),
|
||||
r,
|
||||
AccountVote::Split { aye: 10, nay: 0 }
|
||||
));
|
||||
// Delegated vote is huge.
|
||||
assert_eq!(tally(r), Tally { ayes: 1, nays: 0, turnout: 10 });
|
||||
});
|
||||
@@ -184,8 +188,8 @@ fn redelegation_keeps_lock() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
// Delegate and vote.
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 1, Conviction::Locked6x, 20));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
// Delegated vote is huge.
|
||||
assert_eq!(tally(r), Tally { ayes: 121, nays: 0, turnout: 30 });
|
||||
|
||||
@@ -196,14 +200,14 @@ fn redelegation_keeps_lock() {
|
||||
assert_eq!(VotingOf::<Test>::get(2).prior(), &prior_lock);
|
||||
|
||||
// Delegate someone else at a lower conviction and amount
|
||||
assert_ok!(Democracy::delegate(Origin::signed(2), 3, Conviction::None, 10));
|
||||
assert_ok!(Democracy::delegate(RuntimeOrigin::signed(2), 3, Conviction::None, 10));
|
||||
|
||||
// 6x prior should appear w/ locked balance.
|
||||
prior_lock.accumulate(98, 20);
|
||||
assert_eq!(VotingOf::<Test>::get(2).prior(), &prior_lock);
|
||||
assert_eq!(VotingOf::<Test>::get(2).locked_balance(), 20);
|
||||
// Unlock shouldn't work
|
||||
assert_ok!(Democracy::unlock(Origin::signed(2), 2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(2), 2));
|
||||
assert_eq!(VotingOf::<Test>::get(2).prior(), &prior_lock);
|
||||
assert_eq!(VotingOf::<Test>::get(2).locked_balance(), 20);
|
||||
|
||||
@@ -211,7 +215,7 @@ fn redelegation_keeps_lock() {
|
||||
|
||||
// Now unlock can remove the prior lock and reduce the locked amount.
|
||||
assert_eq!(VotingOf::<Test>::get(2).prior(), &prior_lock);
|
||||
assert_ok!(Democracy::unlock(Origin::signed(2), 2));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(2), 2));
|
||||
assert_eq!(VotingOf::<Test>::get(2).prior(), &vote::PriorLock::default());
|
||||
assert_eq!(VotingOf::<Test>::get(2).locked_balance(), 10);
|
||||
});
|
||||
|
||||
@@ -24,53 +24,56 @@ fn veto_external_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert!(<NextExternal<Test>>::exists());
|
||||
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
assert_ok!(Democracy::veto_external(Origin::signed(3), h));
|
||||
assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(3), h));
|
||||
// cancelled.
|
||||
assert!(!<NextExternal<Test>>::exists());
|
||||
// fails - same proposal can't be resubmitted.
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
|
||||
fast_forward_to(1);
|
||||
// fails as we're still in cooloff period.
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
|
||||
fast_forward_to(2);
|
||||
// works; as we're out of the cooloff period.
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert!(<NextExternal<Test>>::exists());
|
||||
|
||||
// 3 can't veto the same thing twice.
|
||||
assert_noop!(Democracy::veto_external(Origin::signed(3), h), Error::<Test>::AlreadyVetoed);
|
||||
assert_noop!(
|
||||
Democracy::veto_external(RuntimeOrigin::signed(3), h),
|
||||
Error::<Test>::AlreadyVetoed
|
||||
);
|
||||
|
||||
// 4 vetoes.
|
||||
assert_ok!(Democracy::veto_external(Origin::signed(4), h));
|
||||
assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(4), h));
|
||||
// cancelled again.
|
||||
assert!(!<NextExternal<Test>>::exists());
|
||||
|
||||
fast_forward_to(3);
|
||||
// same proposal fails as we're still in cooloff
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
// different proposal works fine.
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(3),
|
||||
));
|
||||
});
|
||||
@@ -82,18 +85,21 @@ fn external_blacklisting_should_work() {
|
||||
System::set_block_number(0);
|
||||
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
|
||||
let hash = set_balance_proposal_hash(2);
|
||||
assert_ok!(Democracy::blacklist(Origin::root(), hash, None));
|
||||
assert_ok!(Democracy::blacklist(RuntimeOrigin::root(), hash, None));
|
||||
|
||||
fast_forward_to(2);
|
||||
assert_noop!(Democracy::referendum_status(0), Error::<Test>::ReferendumInvalid);
|
||||
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(2), set_balance_proposal_hash_and_note(2),),
|
||||
Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
),
|
||||
Error::<Test>::ProposalBlacklisted,
|
||||
);
|
||||
});
|
||||
@@ -104,15 +110,15 @@ fn external_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(1), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(1), set_balance_proposal_hash(2),),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert_noop!(
|
||||
Democracy::external_propose(Origin::signed(2), set_balance_proposal_hash(1),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(1),),
|
||||
Error::<Test>::DuplicateProposal
|
||||
);
|
||||
fast_forward_to(2);
|
||||
@@ -134,11 +140,14 @@ fn external_majority_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose_majority(Origin::signed(1), set_balance_proposal_hash(2)),
|
||||
Democracy::external_propose_majority(
|
||||
RuntimeOrigin::signed(1),
|
||||
set_balance_proposal_hash(2)
|
||||
),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_majority(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
));
|
||||
fast_forward_to(2);
|
||||
@@ -160,11 +169,14 @@ fn external_default_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose_default(Origin::signed(3), set_balance_proposal_hash(2)),
|
||||
Democracy::external_propose_default(
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash(2)
|
||||
),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_default(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
));
|
||||
fast_forward_to(2);
|
||||
@@ -186,7 +198,7 @@ fn external_and_public_interleaving_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(1),
|
||||
));
|
||||
assert_ok!(propose_set_balance_and_note(6, 2, 2));
|
||||
@@ -206,7 +218,7 @@ fn external_and_public_interleaving_works() {
|
||||
);
|
||||
// replenish external
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(3),
|
||||
));
|
||||
|
||||
@@ -240,7 +252,7 @@ fn external_and_public_interleaving_works() {
|
||||
);
|
||||
// replenish external
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(5),
|
||||
));
|
||||
|
||||
@@ -259,7 +271,7 @@ fn external_and_public_interleaving_works() {
|
||||
);
|
||||
// replenish both
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(7),
|
||||
));
|
||||
assert_ok!(propose_set_balance_and_note(6, 4, 2));
|
||||
@@ -281,7 +293,7 @@ fn external_and_public_interleaving_works() {
|
||||
assert_ok!(propose_set_balance_and_note(6, 6, 2));
|
||||
// cancel external
|
||||
let h = set_balance_proposal_hash_and_note(7);
|
||||
assert_ok!(Democracy::veto_external(Origin::signed(3), h));
|
||||
assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(3), h));
|
||||
|
||||
fast_forward_to(12);
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ fn fast_track_referendum_works() {
|
||||
System::set_block_number(0);
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
assert_noop!(
|
||||
Democracy::fast_track(Origin::signed(5), h, 3, 2),
|
||||
Democracy::fast_track(RuntimeOrigin::signed(5), h, 3, 2),
|
||||
Error::<Test>::ProposalMissing
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_majority(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
));
|
||||
assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), BadOrigin);
|
||||
assert_ok!(Democracy::fast_track(Origin::signed(5), h, 2, 0));
|
||||
assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin);
|
||||
assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 2, 0));
|
||||
assert_eq!(
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
@@ -53,25 +53,25 @@ fn instant_referendum_works() {
|
||||
System::set_block_number(0);
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
assert_noop!(
|
||||
Democracy::fast_track(Origin::signed(5), h, 3, 2),
|
||||
Democracy::fast_track(RuntimeOrigin::signed(5), h, 3, 2),
|
||||
Error::<Test>::ProposalMissing
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_majority(
|
||||
Origin::signed(3),
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
));
|
||||
assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), BadOrigin);
|
||||
assert_noop!(Democracy::fast_track(Origin::signed(5), h, 1, 0), BadOrigin);
|
||||
assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin);
|
||||
assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 1, 0), BadOrigin);
|
||||
assert_noop!(
|
||||
Democracy::fast_track(Origin::signed(6), h, 1, 0),
|
||||
Democracy::fast_track(RuntimeOrigin::signed(6), h, 1, 0),
|
||||
Error::<Test>::InstantNotAllowed
|
||||
);
|
||||
INSTANT_ALLOWED.with(|v| *v.borrow_mut() = true);
|
||||
assert_noop!(
|
||||
Democracy::fast_track(Origin::signed(6), h, 0, 0),
|
||||
Democracy::fast_track(RuntimeOrigin::signed(6), h, 0, 0),
|
||||
Error::<Test>::VotingPeriodLow
|
||||
);
|
||||
assert_ok!(Democracy::fast_track(Origin::signed(6), h, 1, 0));
|
||||
assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(6), h, 1, 0));
|
||||
assert_eq!(
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
@@ -102,13 +102,13 @@ fn instant_next_block_referendum_backed() {
|
||||
|
||||
// propose with majority origin
|
||||
assert_ok!(Democracy::external_propose_majority(
|
||||
Origin::signed(majority_origin_id),
|
||||
RuntimeOrigin::signed(majority_origin_id),
|
||||
proposal_hash
|
||||
));
|
||||
|
||||
// fast track with instant origin and voting period pointing to the next block
|
||||
assert_ok!(Democracy::fast_track(
|
||||
Origin::signed(instant_origin_id),
|
||||
RuntimeOrigin::signed(instant_origin_id),
|
||||
proposal_hash,
|
||||
voting_period,
|
||||
delay
|
||||
@@ -145,11 +145,11 @@ fn fast_track_referendum_fails_when_no_simple_majority() {
|
||||
System::set_block_number(0);
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
));
|
||||
assert_noop!(
|
||||
Democracy::fast_track(Origin::signed(5), h, 3, 2),
|
||||
Democracy::fast_track(RuntimeOrigin::signed(5), h, 3, 2),
|
||||
Error::<Test>::NotSimpleMajority
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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![]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ fn missing_preimage_should_fail() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
|
||||
next_block();
|
||||
next_block();
|
||||
@@ -44,9 +44,9 @@ fn preimage_deposit_should_be_required_and_returned() {
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 100);
|
||||
assert_noop!(
|
||||
if operational {
|
||||
Democracy::note_preimage_operational(Origin::signed(6), vec![0; 500])
|
||||
Democracy::note_preimage_operational(RuntimeOrigin::signed(6), vec![0; 500])
|
||||
} else {
|
||||
Democracy::note_preimage(Origin::signed(6), vec![0; 500])
|
||||
Democracy::note_preimage(RuntimeOrigin::signed(6), vec![0; 500])
|
||||
},
|
||||
BalancesError::<Test, _>::InsufficientBalance,
|
||||
);
|
||||
@@ -58,7 +58,7 @@ fn preimage_deposit_should_be_required_and_returned() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
|
||||
assert_eq!(Balances::reserved_balance(6), 12);
|
||||
|
||||
@@ -76,21 +76,25 @@ fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
assert_ok!(if operational {
|
||||
Democracy::note_preimage_operational(Origin::signed(6), set_balance_proposal(2))
|
||||
Democracy::note_preimage_operational(RuntimeOrigin::signed(6), set_balance_proposal(2))
|
||||
} else {
|
||||
Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2))
|
||||
Democracy::note_preimage(RuntimeOrigin::signed(6), set_balance_proposal(2))
|
||||
});
|
||||
|
||||
assert_eq!(Balances::reserved_balance(6), 12);
|
||||
|
||||
next_block();
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::MAX),
|
||||
Democracy::reap_preimage(
|
||||
RuntimeOrigin::signed(6),
|
||||
set_balance_proposal_hash(2),
|
||||
u32::MAX
|
||||
),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
next_block();
|
||||
assert_ok!(Democracy::reap_preimage(
|
||||
Origin::signed(6),
|
||||
RuntimeOrigin::signed(6),
|
||||
set_balance_proposal_hash(2),
|
||||
u32::MAX
|
||||
));
|
||||
@@ -104,15 +108,19 @@ fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
fn preimage_deposit_should_be_reapable() {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::MAX),
|
||||
Democracy::reap_preimage(
|
||||
RuntimeOrigin::signed(5),
|
||||
set_balance_proposal_hash(2),
|
||||
u32::MAX
|
||||
),
|
||||
Error::<Test>::PreimageMissing
|
||||
);
|
||||
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
assert_ok!(if operational {
|
||||
Democracy::note_preimage_operational(Origin::signed(6), set_balance_proposal(2))
|
||||
Democracy::note_preimage_operational(RuntimeOrigin::signed(6), set_balance_proposal(2))
|
||||
} else {
|
||||
Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2))
|
||||
Democracy::note_preimage(RuntimeOrigin::signed(6), set_balance_proposal(2))
|
||||
});
|
||||
assert_eq!(Balances::reserved_balance(6), 12);
|
||||
|
||||
@@ -120,13 +128,17 @@ fn preimage_deposit_should_be_reapable() {
|
||||
next_block();
|
||||
next_block();
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::MAX),
|
||||
Democracy::reap_preimage(
|
||||
RuntimeOrigin::signed(5),
|
||||
set_balance_proposal_hash(2),
|
||||
u32::MAX
|
||||
),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
|
||||
next_block();
|
||||
assert_ok!(Democracy::reap_preimage(
|
||||
Origin::signed(5),
|
||||
RuntimeOrigin::signed(5),
|
||||
set_balance_proposal_hash(2),
|
||||
u32::MAX
|
||||
));
|
||||
@@ -147,16 +159,16 @@ fn noting_imminent_preimage_for_free_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
1,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
|
||||
assert_noop!(
|
||||
if operational {
|
||||
Democracy::note_imminent_preimage_operational(
|
||||
Origin::signed(6),
|
||||
RuntimeOrigin::signed(6),
|
||||
set_balance_proposal(2),
|
||||
)
|
||||
} else {
|
||||
Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2))
|
||||
Democracy::note_imminent_preimage(RuntimeOrigin::signed(6), set_balance_proposal(2))
|
||||
},
|
||||
Error::<Test>::NotImminent
|
||||
);
|
||||
@@ -164,7 +176,10 @@ fn noting_imminent_preimage_for_free_should_work() {
|
||||
next_block();
|
||||
|
||||
// Now we're in the dispatch queue it's all good.
|
||||
assert_ok!(Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2)));
|
||||
assert_ok!(Democracy::note_imminent_preimage(
|
||||
RuntimeOrigin::signed(6),
|
||||
set_balance_proposal(2)
|
||||
));
|
||||
|
||||
next_block();
|
||||
|
||||
@@ -177,11 +192,11 @@ fn reaping_imminent_preimage_should_fail() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
let r = Democracy::inject_referendum(3, h, VoteThreshold::SuperMajorityApprove, 1);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
next_block();
|
||||
next_block();
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(6), h, u32::MAX),
|
||||
Democracy::reap_preimage(RuntimeOrigin::signed(6), h, u32::MAX),
|
||||
Error::<Test>::Imminent
|
||||
);
|
||||
});
|
||||
@@ -198,21 +213,24 @@ fn note_imminent_preimage_can_only_be_successful_once() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
1,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
next_block();
|
||||
|
||||
// First time works
|
||||
assert_ok!(Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2)));
|
||||
assert_ok!(Democracy::note_imminent_preimage(
|
||||
RuntimeOrigin::signed(6),
|
||||
set_balance_proposal(2)
|
||||
));
|
||||
|
||||
// Second time fails
|
||||
assert_noop!(
|
||||
Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2)),
|
||||
Democracy::note_imminent_preimage(RuntimeOrigin::signed(6), set_balance_proposal(2)),
|
||||
Error::<Test>::DuplicatePreimage
|
||||
);
|
||||
|
||||
// Fails from any user
|
||||
assert_noop!(
|
||||
Democracy::note_imminent_preimage(Origin::signed(5), set_balance_proposal(2)),
|
||||
Democracy::note_imminent_preimage(RuntimeOrigin::signed(5), set_balance_proposal(2)),
|
||||
Error::<Test>::DuplicatePreimage
|
||||
);
|
||||
});
|
||||
|
||||
@@ -35,10 +35,10 @@ fn backing_for_should_work() {
|
||||
fn deposit_for_proposals_should_be_taken() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
assert_eq!(Balances::free_balance(1), 5);
|
||||
assert_eq!(Balances::free_balance(2), 15);
|
||||
assert_eq!(Balances::free_balance(5), 35);
|
||||
@@ -49,10 +49,10 @@ fn deposit_for_proposals_should_be_taken() {
|
||||
fn deposit_for_proposals_should_be_returned() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(RuntimeOrigin::signed(5), 0, u32::MAX));
|
||||
fast_forward_to(3);
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(2), 20);
|
||||
@@ -79,7 +79,7 @@ fn poor_seconder_should_not_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(2, 2, 11));
|
||||
assert_noop!(
|
||||
Democracy::second(Origin::signed(1), 0, u32::MAX),
|
||||
Democracy::second(RuntimeOrigin::signed(1), 0, u32::MAX),
|
||||
BalancesError::<Test, _>::InsufficientBalance
|
||||
);
|
||||
});
|
||||
@@ -89,7 +89,10 @@ fn poor_seconder_should_not_work() {
|
||||
fn invalid_seconds_upper_bound_should_not_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 5));
|
||||
assert_noop!(Democracy::second(Origin::signed(2), 0, 0), Error::<Test>::WrongUpperBound);
|
||||
assert_noop!(
|
||||
Democracy::second(RuntimeOrigin::signed(2), 0, 0),
|
||||
Error::<Test>::WrongUpperBound
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,8 +101,8 @@ fn cancel_proposal_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 2));
|
||||
assert_ok!(propose_set_balance_and_note(1, 4, 4));
|
||||
assert_noop!(Democracy::cancel_proposal(Origin::signed(1), 0), BadOrigin);
|
||||
assert_ok!(Democracy::cancel_proposal(Origin::root(), 0));
|
||||
assert_noop!(Democracy::cancel_proposal(RuntimeOrigin::signed(1), 0), BadOrigin);
|
||||
assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0));
|
||||
System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into());
|
||||
assert_eq!(Democracy::backing_for(0), None);
|
||||
assert_eq!(Democracy::backing_for(1), Some(4));
|
||||
@@ -115,8 +118,8 @@ fn blacklisting_should_work() {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 2));
|
||||
assert_ok!(propose_set_balance_and_note(1, 4, 4));
|
||||
|
||||
assert_noop!(Democracy::blacklist(Origin::signed(1), hash, None), BadOrigin);
|
||||
assert_ok!(Democracy::blacklist(Origin::root(), hash, None));
|
||||
assert_noop!(Democracy::blacklist(RuntimeOrigin::signed(1), hash, None), BadOrigin);
|
||||
assert_ok!(Democracy::blacklist(RuntimeOrigin::root(), hash, None));
|
||||
|
||||
assert_eq!(Democracy::backing_for(0), None);
|
||||
assert_eq!(Democracy::backing_for(1), Some(4));
|
||||
@@ -127,7 +130,7 @@ fn blacklisting_should_work() {
|
||||
|
||||
let hash = set_balance_proposal_hash(4);
|
||||
assert_ok!(Democracy::referendum_status(0));
|
||||
assert_ok!(Democracy::blacklist(Origin::root(), hash, Some(0)));
|
||||
assert_ok!(Democracy::blacklist(RuntimeOrigin::root(), hash, Some(0)));
|
||||
assert_noop!(Democracy::referendum_status(0), Error::<Test>::ReferendumInvalid);
|
||||
});
|
||||
}
|
||||
@@ -140,10 +143,10 @@ fn runners_up_should_come_after() {
|
||||
assert_ok!(propose_set_balance_and_note(1, 4, 4));
|
||||
assert_ok!(propose_set_balance_and_note(1, 3, 3));
|
||||
fast_forward_to(2);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 0, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 0, aye(1)));
|
||||
fast_forward_to(4);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 1, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 1, aye(1)));
|
||||
fast_forward_to(6);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 2, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 2, aye(1)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ fn simple_passing_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_eq!(tally(r), Tally { ayes: 1, nays: 0, turnout: 10 });
|
||||
assert_eq!(Democracy::lowest_unbaked(), 0);
|
||||
next_block();
|
||||
@@ -47,7 +47,7 @@ fn simple_failing_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, nay(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, nay(1)));
|
||||
assert_eq!(tally(r), Tally { ayes: 0, nays: 1, turnout: 10 });
|
||||
|
||||
next_block();
|
||||
@@ -73,13 +73,13 @@ fn ooo_inject_referendums_should_work() {
|
||||
0,
|
||||
);
|
||||
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r2, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r2, aye(1)));
|
||||
assert_eq!(tally(r2), Tally { ayes: 1, nays: 0, turnout: 10 });
|
||||
|
||||
next_block();
|
||||
assert_eq!(Balances::free_balance(42), 2);
|
||||
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r1, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r1, aye(1)));
|
||||
assert_eq!(tally(r1), Tally { ayes: 1, nays: 0, turnout: 10 });
|
||||
|
||||
next_block();
|
||||
@@ -96,12 +96,12 @@ fn delayed_enactment_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
1,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, aye(2)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, aye(3)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, aye(4)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, aye(5)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, aye(6)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, aye(2)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(3), r, aye(3)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(4), r, aye(4)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, aye(5)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(6), r, aye(6)));
|
||||
|
||||
assert_eq!(tally(r), Tally { ayes: 21, nays: 0, turnout: 210 });
|
||||
|
||||
@@ -134,10 +134,10 @@ fn lowest_unbaked_should_be_sensible() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r1, aye(1)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r2, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r1, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r2, aye(1)));
|
||||
// r3 is canceled
|
||||
assert_ok!(Democracy::cancel_referendum(Origin::root(), r3.into()));
|
||||
assert_ok!(Democracy::cancel_referendum(RuntimeOrigin::root(), r3.into()));
|
||||
assert_eq!(Democracy::lowest_unbaked(), 0);
|
||||
|
||||
next_block();
|
||||
|
||||
@@ -24,7 +24,7 @@ fn overvoting_should_fail() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
assert_noop!(
|
||||
Democracy::vote(Origin::signed(1), r, aye(2)),
|
||||
Democracy::vote(RuntimeOrigin::signed(1), r, aye(2)),
|
||||
Error::<Test>::InsufficientFunds
|
||||
);
|
||||
});
|
||||
@@ -35,9 +35,12 @@ fn split_voting_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
let v = AccountVote::Split { aye: 40, nay: 20 };
|
||||
assert_noop!(Democracy::vote(Origin::signed(5), r, v), Error::<Test>::InsufficientFunds);
|
||||
assert_noop!(
|
||||
Democracy::vote(RuntimeOrigin::signed(5), r, v),
|
||||
Error::<Test>::InsufficientFunds
|
||||
);
|
||||
let v = AccountVote::Split { aye: 30, nay: 20 };
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, v));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, v));
|
||||
|
||||
assert_eq!(tally(r), Tally { ayes: 3, nays: 2, turnout: 50 });
|
||||
});
|
||||
@@ -48,10 +51,10 @@ fn split_vote_cancellation_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = begin_referendum();
|
||||
let v = AccountVote::Split { aye: 30, nay: 20 };
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, v));
|
||||
assert_ok!(Democracy::remove_vote(Origin::signed(5), r));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, v));
|
||||
assert_ok!(Democracy::remove_vote(RuntimeOrigin::signed(5), r));
|
||||
assert_eq!(tally(r), Tally { ayes: 0, nays: 0, turnout: 0 });
|
||||
assert_ok!(Democracy::unlock(Origin::signed(5), 5));
|
||||
assert_ok!(Democracy::unlock(RuntimeOrigin::signed(5), 5));
|
||||
assert_eq!(Balances::locks(5), vec![]);
|
||||
});
|
||||
}
|
||||
@@ -66,7 +69,7 @@ fn single_proposal_should_work() {
|
||||
|
||||
// start of 2 => next referendum scheduled.
|
||||
fast_forward_to(2);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, aye(1)));
|
||||
|
||||
assert_eq!(Democracy::referendum_count(), 1);
|
||||
assert_eq!(
|
||||
@@ -108,12 +111,12 @@ fn controversial_voting_should_work() {
|
||||
0,
|
||||
);
|
||||
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, big_aye(1)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, big_nay(2)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, big_nay(3)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, big_aye(4)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, big_aye(6)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), r, big_aye(1)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(2), r, big_nay(2)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(3), r, big_nay(3)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(4), r, big_aye(4)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(6), r, big_aye(6)));
|
||||
|
||||
assert_eq!(tally(r), Tally { ayes: 110, nays: 100, turnout: 210 });
|
||||
|
||||
@@ -133,8 +136,8 @@ fn controversial_low_turnout_voting_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, big_aye(6)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(6), r, big_aye(6)));
|
||||
|
||||
assert_eq!(tally(r), Tally { ayes: 60, nays: 50, turnout: 110 });
|
||||
|
||||
@@ -157,9 +160,9 @@ fn passing_low_turnout_voting_should_work() {
|
||||
VoteThreshold::SuperMajorityApprove,
|
||||
0,
|
||||
);
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, big_aye(4)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, big_aye(6)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(4), r, big_aye(4)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(5), r, big_nay(5)));
|
||||
assert_ok!(Democracy::vote(RuntimeOrigin::signed(6), r, big_aye(6)));
|
||||
assert_eq!(tally(r), Tally { ayes: 100, nays: 50, turnout: 150 });
|
||||
|
||||
next_block();
|
||||
|
||||
Reference in New Issue
Block a user