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: that receipt token was transfered to staker after staking #19

Open
wants to merge 1 commit into
base: test_transfer_stake_token
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
30 changes: 30 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 @@ -196,6 +196,36 @@ fn test_transfer_stake_token(){
}


#[test]
fn test_transfer_receipt_token(){
let (staking_contract_address, bwc_contract_address, receipt_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 prev_stake_contract_receipt_token_balance: u256 = receipt_dispatcher.balance_of(staking_contract_address);
let prev_staker_receipt_token_balance: u256 = receipt_dispatcher.balance_of(Account::user1());


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);
assert(receipt_dispatcher.balance_of(Account::user1()) == prev_staker_receipt_token_balance + 6 , Errors::INVALID_BALANCE);
stop_prank(CheatTarget::One(staking_contract_address));
}





Expand Down