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

Improve the ts-sdk testing setup #448

Merged
merged 4 commits into from
Nov 5, 2024
Merged

Improve the ts-sdk testing setup #448

merged 4 commits into from
Nov 5, 2024

Conversation

wjthieme
Copy link
Member

@wjthieme wjthieme commented Nov 1, 2024

  • Add tests for fetching positions
  • Use actual instructions for initializing pools/positions/tokens/etc. instead of trying to write the data ourselves
  • Bankrun does not support gpa yet so some functions cannot be tested through bankrun

@wjthieme wjthieme self-assigned this Nov 1, 2024
const mint1 = await setupMint({ decimals: 9 });
const mint2 = await setupMint({ decimals: 6 });
[mintA, mintB] =
Buffer.from(mint1) < Buffer.from(mint2) ? [mint1, mint2] : [mint2, mint1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: orderMints

const mint1 = await setupMint();
const mint2 = await setupMint();
[mintA, mintB] =
Buffer.from(mint1) < Buffer.from(mint2) ? [mint1, mint2] : [mint2, mint1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: orderMints

const mint1 = await setupMint();
const mint2 = await setupMint();
[mintA, mintB] =
Buffer.from(mint1) < Buffer.from(mint2) ? [mint1, mint2] : [mint2, mint1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: orderMints

[TOKEN_MINT_1]: 100n,
[TOKEN_MINT_2]: 100n,
[mintA]: 100n,
[mintB]: 100n,
[NATIVE_MINT]: 100n,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, in this case (strategy is none), the balance of ATA for native mint should be zero even if 100n is specified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. This is how it is currently explained in the docs:

 * - **None**:
 *   Uses or creates the ATA without performing any SOL wrapping or unwrapping.

It might make sense to throw if the balance is insufficient (also for the non-SOL mints). Basically this can be used to say: "I need x amount in this token account" and is currently only doing something for SOL (if wrapping strategy is not none). What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!
It makes sense🙂 (memo: the instruction requires X SOL, but my ATA already has > X SOL, so no need to wrap)

# Conflicts:
#	ts-sdk/whirlpool/src/pool.ts
#	ts-sdk/whirlpool/tests/token.test.ts
Copy link
Collaborator

@yugure-orca yugure-orca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@wjthieme wjthieme merged commit bdbd6ad into main Nov 5, 2024
5 checks passed
@wjthieme wjthieme deleted the wjthieme/ts-sdk-tests branch November 5, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants