Skip to content

Commit

Permalink
rename and move claim rewards after global farm update test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfridrich committed Sep 18, 2024
1 parent 84a86bb commit d890ed5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
33 changes: 33 additions & 0 deletions pallets/liquidity-mining/src/tests/claim_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,3 +1263,36 @@ fn claim_rewards_should_claim_correct_amount_when_yield_was_resumed_multiple_tim
});
});
}

#[test]
fn claim_rewards_should_work_when_global_farm_was_updated() {
predefined_test_ext_with_deposits().execute_with(|| {
let _ = with_transaction(|| {
//Arrange
let planned_yielding_periods: BlockNumber = 1_000u64;
let yield_per_period = Perquintill::from_percent(20);
let min_deposit = 20_000;

set_block_number(100_000);

//Act
assert_ok!(LiquidityMining::update_global_farm(
GC_FARM,
planned_yielding_periods,
yield_per_period,
min_deposit,
));

set_block_number(1_000_000);

//Assert
assert_eq!(
LiquidityMining::claim_rewards(ALICE, PREDEFINED_DEPOSIT_IDS[0], GC_BSX_TKN1_YIELD_FARM_ID, false)
.unwrap(),
(GC_FARM, BSX, 28495477087879389002, 142022912120610998)
);

TransactionOutcome::Commit(DispatchResult::Ok(()))
});
});
}
33 changes: 0 additions & 33 deletions pallets/liquidity-mining/src/tests/update_global_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,36 +304,3 @@ fn update_global_farm_should_fail_when_yield_period_is_zero() {
});
});
}

#[test]
fn claim_rewards_should_work_after_claiming_rewards() {
predefined_test_ext_with_deposits().execute_with(|| {
let _ = with_transaction(|| {
//Arrange
let planned_yielding_periods: BlockNumber = 1_000u64;
let yield_per_period = Perquintill::from_percent(20);
let min_deposit = 20_000;

set_block_number(100_000);

//Act
assert_ok!(LiquidityMining::update_global_farm(
GC_FARM,
planned_yielding_periods,
yield_per_period,
min_deposit,
));

set_block_number(1_000_000);

//Assert
assert_eq!(
LiquidityMining::claim_rewards(ALICE, PREDEFINED_DEPOSIT_IDS[0], GC_BSX_TKN1_YIELD_FARM_ID, false)
.unwrap(),
(GC_FARM, BSX, 28495477087879389002, 142022912120610998)
);

TransactionOutcome::Commit(DispatchResult::Ok(()))
});
});
}

0 comments on commit d890ed5

Please sign in to comment.