Skip to content

Commit 5879b71

Browse files
committed
test for withdrawing before migrating delegation
1 parent 4bd35fe commit 5879b71

File tree

2 files changed

+8
-2
lines changed
  • substrate/frame/nomination-pools

2 files changed

+8
-2
lines changed

substrate/frame/nomination-pools/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,12 +2300,13 @@ pub mod pallet {
23002300
// order to ensure members can leave the pool and it can be destroyed.
23012301
.min(T::StakeAdapter::transferable_balance(&bonded_pool.bonded_account()));
23022302

2303+
// this can fail if the pool uses `DelegateStake` strategy and the member delegation
2304+
// is not claimed yet. See `Call::claim_delegation()`.
23032305
T::StakeAdapter::member_withdraw(
23042306
&member_account,
23052307
&bonded_pool.bonded_account(),
23062308
balance_to_unbond,
2307-
)
2308-
.defensive()?;
2309+
)?;
23092310

23102311
Self::deposit_event(Event::<T>::Withdrawn {
23112312
member: member_account.clone(),

substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use pallet_staking::{
2929
CurrentEra, Error as StakingError, Event as StakingEvent, Payee, RewardDestination,
3030
};
3131

32+
use pallet_delegated_staking::Error as DelegatedStakingError;
33+
3234
use sp_runtime::{bounded_btree_map, traits::Zero};
3335

3436
#[test]
@@ -882,6 +884,9 @@ fn pool_migration_e2e() {
882884
// progress to a future era where funds are unlocked
883885
CurrentEra::<Runtime>::set(Some(10));
884886

887+
// withdraw fails before claiming delegation
888+
assert_noop!(Pools::withdraw_unbonded(RuntimeOrigin::signed(20), 20, 10), DelegatedStakingError::<Runtime>::NotDelegator);
889+
885890
let pre_claim_balance_20 = Balances::total_balance(&20);
886891
assert_eq!(Balances::total_balance_on_hold(&20), 0);
887892

0 commit comments

Comments
 (0)