fix: test cases (tokenAIsNative related) (#92)
* fix: test cases (tokenAIsNative related)
This commit is contained in:
parent
e554b79a75
commit
9a46642433
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue