mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 17:28:00 +00:00
Allow operational recovery path if on_initialize use fullblock. (#6089)
* note_preimage using operational * Update frame/democracy/src/lib.rs Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -39,13 +39,14 @@ fn missing_preimage_should_fail() {
|
||||
|
||||
#[test]
|
||||
fn preimage_deposit_should_be_required_and_returned() {
|
||||
new_test_ext().execute_with(|| {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
// fee of 100 is too much.
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 100);
|
||||
assert_noop!(
|
||||
Democracy::note_preimage(Origin::signed(6), vec![0; 500]),
|
||||
BalancesError::<Test, _>::InsufficientBalance,
|
||||
);
|
||||
if operational { Democracy::note_preimage_operational(Origin::signed(6), vec![0; 500]) }
|
||||
else { Democracy::note_preimage(Origin::signed(6), vec![0; 500]) },
|
||||
BalancesError::<Test, _>::InsufficientBalance,
|
||||
);
|
||||
// fee of 1 is reasonable.
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
let r = Democracy::inject_referendum(
|
||||
@@ -69,17 +70,20 @@ fn preimage_deposit_should_be_required_and_returned() {
|
||||
|
||||
#[test]
|
||||
fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
new_test_ext().execute_with(|| {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
assert_ok!(Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2)));
|
||||
assert_ok!(
|
||||
if operational { Democracy::note_preimage_operational(Origin::signed(6), set_balance_proposal(2)) }
|
||||
else { Democracy::note_preimage(Origin::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_value()),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::max_value()),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
next_block();
|
||||
assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::max_value()));
|
||||
|
||||
@@ -90,14 +94,17 @@ fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
|
||||
#[test]
|
||||
fn preimage_deposit_should_be_reapable() {
|
||||
new_test_ext().execute_with(|| {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::max_value()),
|
||||
Error::<Test>::PreimageMissing
|
||||
);
|
||||
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
assert_ok!(Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2)));
|
||||
assert_ok!(
|
||||
if operational { Democracy::note_preimage_operational(Origin::signed(6), set_balance_proposal(2)) }
|
||||
else { Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2)) }
|
||||
);
|
||||
assert_eq!(Balances::reserved_balance(6), 12);
|
||||
|
||||
next_block();
|
||||
@@ -118,7 +125,7 @@ fn preimage_deposit_should_be_reapable() {
|
||||
|
||||
#[test]
|
||||
fn noting_imminent_preimage_for_free_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1);
|
||||
|
||||
let r = Democracy::inject_referendum(
|
||||
@@ -130,14 +137,15 @@ fn noting_imminent_preimage_for_free_should_work() {
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
|
||||
assert_noop!(
|
||||
Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2)),
|
||||
Error::<Test>::NotImminent
|
||||
);
|
||||
if operational { Democracy::note_imminent_preimage_operational(Origin::signed(6), set_balance_proposal(2)) }
|
||||
else { Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2)) },
|
||||
Error::<Test>::NotImminent
|
||||
);
|
||||
|
||||
next_block();
|
||||
|
||||
// Now we're in the dispatch queue it's all good.
|
||||
assert_ok!(Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2)));
|
||||
assert_ok!(Democracy::note_imminent_preimage(Origin::signed(6), set_balance_proposal(2)));
|
||||
|
||||
next_block();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user