Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dApp Staking v3 - Unbond During Decommission #1135

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pallets/dapps-staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ pub mod pallet {
#[pallet::compact] value: Balance,
) -> DispatchResultWithPostInfo {
Self::ensure_pallet_enabled()?;
Self::ensure_not_in_decommission()?;
let staker = ensure_signed(origin)?;

ensure!(value > Zero::zero(), Error::<T>::UnstakingWithNoValue);
Expand Down Expand Up @@ -630,7 +629,6 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::withdraw_unbonded())]
pub fn withdraw_unbonded(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
Self::ensure_pallet_enabled()?;
Self::ensure_not_in_decommission()?;
let staker = ensure_signed(origin)?;

let mut ledger = Self::ledger(&staker);
Expand Down
25 changes: 16 additions & 9 deletions pallets/dapps-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2146,10 +2146,6 @@ fn decommision_is_ok() {
DappsStaking::bond_and_stake(RuntimeOrigin::signed(account), contract_id, 100),
Error::<TestRuntime>::DecommissionInProgress
);
assert_noop!(
DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(account), contract_id, 100),
Error::<TestRuntime>::DecommissionInProgress
);
assert_noop!(
DappsStaking::nomination_transfer(
RuntimeOrigin::signed(account),
Expand All @@ -2159,10 +2155,6 @@ fn decommision_is_ok() {
),
Error::<TestRuntime>::DecommissionInProgress
);
assert_noop!(
DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(account)),
Error::<TestRuntime>::DecommissionInProgress
);

// Ensure that expected calls still work (or at least don't fail with `DecommissionInProgress` error)
assert_noop!(
Expand All @@ -2173,11 +2165,26 @@ fn decommision_is_ok() {
DappsStaking::claim_dapp(RuntimeOrigin::signed(account), contract_id, 1,),
Error::<TestRuntime>::NotOperatedContract
);
assert_noop!(
DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(account), contract_id, 100),
Error::<TestRuntime>::NotOperatedContract
);
assert_noop!(
DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(account)),
Error::<TestRuntime>::NothingToWithdraw
);
assert_noop!(
DappsStaking::set_reward_destination(
RuntimeOrigin::signed(account),
RewardDestination::StakeBalance
),
Error::<TestRuntime>::NotActiveStaker
);
})
}

#[test]
fn no_era_change_during_decommision() {
fn no_era_change_during_decommission() {
ExternalityBuilder::build().execute_with(|| {
initialize_first_block();

Expand Down
Loading