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

test: withdraw fails when there is insuffient reward tokens #22

Open
wants to merge 1 commit into
base: test_invalid_withdraw_time
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions src/tests/bwc_staking_contract/test_bwc_staking_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,34 @@ fn test_invalid_withdraw_time() {
stake_dispatcher.withdraw(5);
}

#[test]
#[should_panic(expected: ('Not enough reward token to send',))]
fn test_insufficient_reward_token() {
let (staking_contract_address, bwc_contract_address, receipt_contract_address, reward_contract_address) =
deploy_contract();
let receipt_dispatcher = IERC20Dispatcher { contract_address: receipt_contract_address };
let stake_dispatcher = IStakeDispatcher { contract_address: staking_contract_address };
let bwc_dispatcher = IERC20Dispatcher { contract_address: bwc_contract_address };
let reward_dispatcher = IERC20Dispatcher { contract_address: reward_contract_address };


start_prank(CheatTarget::One(bwc_contract_address), Account::admin());
bwc_dispatcher.transfer(Account::user1(), 35);
stop_prank(CheatTarget::One(bwc_contract_address));

start_prank(CheatTarget::One(receipt_contract_address), Account::admin());
receipt_dispatcher.transfer(staking_contract_address, 20);
stop_prank(CheatTarget::One(receipt_contract_address));

start_prank(CheatTarget::One(bwc_contract_address), Account::user1());
bwc_dispatcher.approve(staking_contract_address, 10);
stop_prank(CheatTarget::One(bwc_contract_address));

start_prank(CheatTarget::One(staking_contract_address), Account::user1());
stake_dispatcher.stake(6);
start_warp(CheatTarget::One(staking_contract_address), get_block_timestamp() + 240);
stake_dispatcher.withdraw(5);
}



Expand Down