fix: test cases (tokenAIsNative related) (#92)

* fix: test cases (tokenAIsNative related)
This commit is contained in:
yugure-orca 2023-03-16 17:44:48 +09:00 committed by GitHub
parent e554b79a75
commit 9a46642433
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { PublicKey, Keypair } from "@solana/web3.js";
import { u64 } from "@solana/spl-token";
import { NATIVE_MINT, u64 } from "@solana/spl-token";
import { InitConfigParams, InitPoolParams, TickUtil, WhirlpoolContext } from "../../src";
import {
FundedPositionInfo,
@ -54,7 +54,7 @@ export class WhirlpoolTestFixture {
tickSpacing,
initialSqrtPrice,
undefined,
tokenAIsNative
tokenAIsNative ? NATIVE_MINT : undefined
);
this.poolInitInfo = poolInitInfo;

View File

@ -39,7 +39,7 @@ export async function setupSwapTest(setup: SwapTestPoolParams, tokenAIsNative =
setup.tickSpacing,
setup.initSqrtPrice,
setup.tokenMintAmount,
NATIVE_MINT
tokenAIsNative ? NATIVE_MINT : undefined
);
const whirlpool = await setup.client.getPool(whirlpoolPda.publicKey, true);

View File

@ -56,9 +56,15 @@ export const generateDefaultConfigParams = (
export const createInOrderMints = async (context: WhirlpoolContext, reuseTokenA?: PublicKey) => {
const provider = context.provider;
const tokenXMintPubKey = reuseTokenA || (await createMint(provider));
const tokenYMintPubKey = await createMint(provider);
return PoolUtil.orderMints(tokenXMintPubKey, tokenYMintPubKey).map(AddressUtil.toPubKey);
const tokenXMintPubKey = reuseTokenA ?? (await createMint(provider));
// ensure reuseTokenA is the first mint if reuseTokenA is provided
let ordered;
do {
const tokenYMintPubKey = await createMint(provider);
ordered = PoolUtil.orderMints(tokenXMintPubKey, tokenYMintPubKey).map(AddressUtil.toPubKey);
} while (!!reuseTokenA && !ordered[0].equals(reuseTokenA));
return ordered;
};
export const generateDefaultInitPoolParams = async (