Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

token-swap: Add fuzzer for swap / withdraw / deposit #875

Merged
merged 24 commits into from
Nov 30, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Fix fuzz withdraw logic to avoid ZeroTradingTokens error
  • Loading branch information
joncinque committed Nov 23, 2020
commit 2a3635eb3ff00ee4b7246f3197ad30b3951a8928
8 changes: 7 additions & 1 deletion token-swap/program/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,14 @@ impl TokenSwapAccountInfo {
pool_account: &mut AccountData,
token_a_account: &mut AccountData,
token_b_account: &mut AccountData,
instruction: Withdraw,
mut instruction: Withdraw,
) -> ProgramResult {
let pool_token_amount = get_token_balance(&pool_account);
// special logic to avoid withdrawing down to 1 pool token, which
// eventually causes an error on withdrawing all
if pool_token_amount.saturating_sub(instruction.pool_token_amount) == 1 {
instruction.pool_token_amount = pool_token_amount;
}
do_process_instruction(
approve(
&self.token_program_account.key,
Expand Down