Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • parity/mirrors/polkadot-sdk
1 result
Show changes
Commits on Source (2)
...@@ -2549,11 +2549,11 @@ pub mod pallet { ...@@ -2549,11 +2549,11 @@ pub mod pallet {
Ok(()) Ok(())
} }
/// Migrates permissionlessly a stash from locks to holds. /// Removes the legacy Staking locks if they exist.
/// ///
/// This removes the old lock on the stake and creates a hold on it atomically. If all /// This removes the legacy lock on the stake with [`T::OldCurrency`] and creates a hold on
/// stake cannot be held, the best effort is made to hold as much as possible. The remaining /// it if needed. If all stake cannot be held, the best effort is made to hold as much as
/// stake is removed from the ledger. /// possible. The remaining stake is forced withdrawn from the ledger.
/// ///
/// The fee is waived if the migration is successful. /// The fee is waived if the migration is successful.
#[pallet::call_index(30)] #[pallet::call_index(30)]
......
...@@ -8821,8 +8821,8 @@ mod getters { ...@@ -8821,8 +8821,8 @@ mod getters {
} }
mod hold_migration { mod hold_migration {
use frame_support::traits::fungible::Mutate;
use super::*; use super::*;
use frame_support::traits::fungible::Mutate;
use sp_staking::{Stake, StakingInterface}; use sp_staking::{Stake, StakingInterface};
#[test] #[test]
...@@ -9165,8 +9165,16 @@ mod hold_migration { ...@@ -9165,8 +9165,16 @@ mod hold_migration {
mock::start_active_era(1); mock::start_active_era(1);
let init_stake = 1000; let init_stake = 1000;
assert_ok!(Staking::bond(RuntimeOrigin::signed(alice), init_stake, RewardDestination::Staked)); assert_ok!(Staking::bond(
assert_ok!(Staking::bond(RuntimeOrigin::signed(bob), init_stake, RewardDestination::Staked)); RuntimeOrigin::signed(alice),
init_stake,
RewardDestination::Staked
));
assert_ok!(Staking::bond(
RuntimeOrigin::signed(bob),
init_stake,
RewardDestination::Staked
));
// convert hold to lock. // convert hold to lock.
testing_utils::migrate_to_old_currency::<Test>(alice); testing_utils::migrate_to_old_currency::<Test>(alice);
...@@ -9219,10 +9227,7 @@ mod hold_migration { ...@@ -9219,10 +9227,7 @@ mod hold_migration {
// ensure events are emitted. // ensure events are emitted.
assert_eq!( assert_eq!(
staking_events_since_last_call(), staking_events_since_last_call(),
vec![Event::CurrencyMigrated { vec![Event::CurrencyMigrated { stash: alice, force_withdraw: 0 }]
stash: alice,
force_withdraw: 0
}]
); );
// ensure cannot migrate again. // ensure cannot migrate again.
...@@ -9240,16 +9245,27 @@ mod hold_migration { ...@@ -9240,16 +9245,27 @@ mod hold_migration {
// assert lock still exists but there is no stake. // assert lock still exists but there is no stake.
assert_eq!(Balances::balance_locked(STAKING_ID, &bob), init_stake); assert_eq!(Balances::balance_locked(STAKING_ID, &bob), init_stake);
assert_eq!(asset::staked::<Test>(&bob), 0); assert_eq!(asset::staked::<Test>(&bob), 0);
assert_eq!(<Staking as StakingInterface>::stake(&bob).unwrap_err(), Error::<Test>::NotStash.into()); assert_eq!(
<Staking as StakingInterface>::stake(&bob).unwrap_err(),
Error::<Test>::NotStash.into()
);
// clear events // clear events
System::reset_events(); System::reset_events();
// AND Bob wants to remove the old lock. // AND Bob wants to remove the old lock.
assert_ok!(Staking::migrate_currency(RuntimeOrigin::signed(1), bob)); assert_ok!(Staking::migrate_currency(RuntimeOrigin::signed(1), bob));
// THEN ensure no lock
assert_eq!(Balances::balance_locked(STAKING_ID, &bob), 0);
// And they cannot migrate again.
assert_noop!(
Staking::migrate_currency(RuntimeOrigin::signed(1), bob),
Error::<Test>::AlreadyMigrated
);
}); });
} }
} }
mod paged_slashing { mod paged_slashing {
......