Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldragonfly committed Jan 8, 2025
1 parent 6c64a13 commit 7a8934d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
24 changes: 16 additions & 8 deletions rust-sdk/whirlpool/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,16 @@ mod tests {
let whirlpool = setup_whirlpool(&ctx, mint_a, mint_b, 64).await?;
let position_pubkey = setup_position(whirlpool).await?;

let te_mint = setup_mint_with_decimals(&ctx, 9).await?;
setup_ata_with_amount(&ctx, te_mint, 1_000_000_000).await?;
let te_position_pubkey = setup_position(whirlpool).await?;

let owner = ctx.signer.pubkey();
let positions = fetch_positions_for_owner(&ctx.rpc, owner).await?;
assert_eq!(
positions.len(),
1,
"Should have one position after setup_position"

assert!(
positions.len() >= 2,
"Did not fetch all positions for the owner (expected two or more)"
);

match &positions[0] {
Expand All @@ -362,14 +366,18 @@ mod tests {
let mint_b = setup_mint_with_decimals(&ctx, 9).await?;
setup_ata_with_amount(&ctx, mint_a, 1_000_000_000).await?;
setup_ata_with_amount(&ctx, mint_b, 1_000_000_000).await?;

let whirlpool = setup_whirlpool(&ctx, mint_a, mint_b, 64).await?;
let _position_pubkey = setup_position(whirlpool).await?;

let te_mint = setup_mint_with_decimals(&ctx, 9).await?;
setup_ata_with_amount(&ctx, te_mint, 1_000_000_000).await?;
let _te_position_pubkey = setup_position(whirlpool).await?;

let positions = fetch_positions_in_whirlpool(&ctx.rpc, whirlpool).await?;
assert_eq!(
positions.len(),
1,
"Should find one position in this whirlpool"
assert!(
positions.len() >= 2,
"Should find multiple positions in this whirlpool, including te_position"
);

Ok(())
Expand Down
10 changes: 3 additions & 7 deletions rust-sdk/whirlpool/src/tests/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,14 @@ pub async fn setup_whirlpool(
pub async fn setup_position(whirlpool: Pubkey) -> Result<Pubkey, Box<dyn Error>> {
let ctx = RpcContext::new().await;

// Use token utility functions
let position_mint = setup_mint_with_decimals(&ctx, 0).await?;
let position_token_account = setup_ata(&ctx, position_mint).await?;

let (position_pubkey, position_bump) = get_position_address(&position_mint)?;
let (position_pubkey, position_bump) = get_position_address(&Pubkey::new_unique())?;

let open_position_ix = OpenPosition {
funder: ctx.signer.pubkey(),
owner: ctx.signer.pubkey(),
position: position_pubkey,
position_mint,
position_token_account,
position_mint: Pubkey::new_unique(),
position_token_account: Pubkey::default(),
whirlpool,
token_program: TOKEN_PROGRAM_ID,
system_program: system_program::id(),
Expand Down

0 comments on commit 7a8934d

Please sign in to comment.