Skip to content

Commit

Permalink
Extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Dec 12, 2023
1 parent 3208238 commit f4e6326
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pallets/dapp-staking-v3/src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ fn stake_fails_due_to_too_many_staked_contracts() {
// Advance to build&earn subperiod so we ensure non-loyal staking
advance_to_next_subperiod();

// Register smart contracts up the the max allowed number
// Register smart contracts up to the max allowed number
for id in 1..=max_number_of_contracts {
let smart_contract = MockSmartContract::Wasm(id.into());
assert_register(2, &MockSmartContract::Wasm(id.into()));
Expand Down Expand Up @@ -2472,3 +2472,37 @@ fn stake_and_unstake_after_reward_claim_is_ok() {
assert_unstake(account, &smart_contract, 1);
})
}

#[test]
fn stake_after_period_ends_with_max_staked_contracts() {
ExtBuilder::build().execute_with(|| {
let max_number_of_contracts: u32 = <Test as Config>::MaxNumberOfStakedContracts::get();

// Lock amount by staker
let account = 1;
assert_lock(account, 100 as Balance * max_number_of_contracts as Balance);

// Register smart contracts up to the max allowed number
for id in 1..=max_number_of_contracts {
let smart_contract = MockSmartContract::Wasm(id.into());
assert_register(2, &smart_contract);
assert_stake(account, &smart_contract, 10);
}

// Advance to the next period, and claim ALL rewards
advance_to_next_period();
for _ in 0..required_number_of_reward_claims(account) {
assert_claim_staker_rewards(account);
}
for id in 1..=max_number_of_contracts {
let smart_contract = MockSmartContract::Wasm(id.into());
assert_claim_bonus_reward(account, &smart_contract);
}

// Make sure it's possible to stake again
for id in 1..=max_number_of_contracts {
let smart_contract = MockSmartContract::Wasm(id.into());
assert_stake(account, &smart_contract, 10);
}
})
}

0 comments on commit f4e6326

Please sign in to comment.