mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 02:51:02 +00:00
Add force remove vesting (#1982)
This PR exposes a `force_remove_vesting` through a ROOT call. See linked [issue](https://github.com/paritytech/polkadot-sdk/issues/269) --------- Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by: Dónal Murray <donal.murray@parity.io>
This commit is contained in:
committed by
GitHub
parent
fb2dc6df8d
commit
318e5969c7
@@ -1155,3 +1155,39 @@ fn vested_transfer_less_than_existential_deposit_fails() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_vesting_schedule() {
|
||||
ExtBuilder::default().existential_deposit(ED).build().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(&3), 256 * 30);
|
||||
assert_eq!(Balances::free_balance(&4), 256 * 40);
|
||||
// Account 4 should not have any vesting yet.
|
||||
assert_eq!(Vesting::vesting(&4), None);
|
||||
// Make the schedule for the new transfer.
|
||||
let new_vesting_schedule = VestingInfo::new(
|
||||
ED * 5,
|
||||
(ED * 5) / 20, // Vesting over 20 blocks
|
||||
10,
|
||||
);
|
||||
assert_ok!(Vesting::vested_transfer(Some(3).into(), 4, new_vesting_schedule));
|
||||
// Now account 4 should have vesting.
|
||||
assert_eq!(Vesting::vesting(&4).unwrap(), vec![new_vesting_schedule]);
|
||||
// Account 4 has 5 * 256 locked.
|
||||
assert_eq!(Vesting::vesting_balance(&4), Some(256 * 5));
|
||||
// Verify only root can call.
|
||||
assert_noop!(Vesting::force_remove_vesting_schedule(Some(4).into(), 4, 0), BadOrigin);
|
||||
// Verify that root can remove the schedule.
|
||||
assert_ok!(Vesting::force_remove_vesting_schedule(RawOrigin::Root.into(), 4, 0));
|
||||
// Verify that last event is VestingCompleted.
|
||||
System::assert_last_event(Event::VestingCompleted { account: 4 }.into());
|
||||
// Appropriate storage is cleaned up.
|
||||
assert!(!<VestingStorage<Test>>::contains_key(4));
|
||||
// Check the vesting balance is zero.
|
||||
assert_eq!(Vesting::vesting(&4), None);
|
||||
// Verifies that trying to remove a schedule when it doesnt exist throws error.
|
||||
assert_noop!(
|
||||
Vesting::force_remove_vesting_schedule(RawOrigin::Root.into(), 4, 0),
|
||||
Error::<Test>::InvalidScheduleParams
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user