Skip to content

Commit 3a7a612

Browse files
committed
Add orca-so_whirlpools third-party test
1 parent c6bda66 commit 3a7a612

File tree

6 files changed

+331
-2
lines changed

6 files changed

+331
-2
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
fail-fast: ${{ github.event_name == 'merge_group' }}
5555
matrix:
5656
environment: [ubuntu-latest, macos-latest, windows-latest]
57-
test: [third_party_0, third_party_1, trycmd, other]
57+
test: [third_party_0, third_party_1, third_party_2, trycmd, other]
5858
include:
5959
- environment: ubuntu-latest
6060
test: ci

Diff for: necessist/tests/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| go_src_text_template_parse | go1.23.0 | go | X | X | X | X | 1 |
1717
| minio | RELEASE.2025-03-12T18-04-18Z | | | X | X | X | 1 |
1818
| operator-filter-registry | v1.4.2 | | | X | X | X | 0 |
19+
| orca-so_whirlpools | | anchor | X | X | | | 2 |
1920
| proptest_https | b71253807372932f72a71b1af7975371a41e7c88 | | X | X | X | X | 0 |
2021
| pyth | rust-pyth-lazer-protocol-v0.7.0 | anchor | | X | X | | 0 |
2122
| seaport_foundry | 1.6 | foundry | X | X | X | X | 1 |

Diff for: necessist/tests/third_party_2.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mod third_party_common;
2+
3+
const PATH: &str = "tests/third_party_tests/2";
4+
5+
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
6+
#[test]
7+
fn all_tests() {
8+
third_party_common::all_tests_in(PATH);
9+
}
10+
11+
#[test]
12+
fn stdout_files_are_sanitary() {
13+
third_party_common::stdout_files_are_sanitary_in(PATH);
14+
}
15+
16+
#[test]
17+
fn stdout_subsequence() {
18+
third_party_common::stdout_subsequence_in(PATH);
19+
}

Diff for: necessist/tests/third_party_common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use string_or_vec::StringOrVec;
2828
mod tempfile_util;
2929
use tempfile_util::{TempDir, tempdir};
3030

31-
const N_PARTITIONS: usize = 2;
31+
const N_PARTITIONS: usize = 3;
3232

3333
// smoelius: `ERROR_EXIT_CODE` is from:
3434
// https://github.com/rust-lang/rust/blob/12397e9dd5a97460d76c884d449ca1c2d26da8ed/src/libtest/lib.rs#L94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
url = "https://github.com/orca-so/whirlpools"
2+
3+
# smoelius: The use of sed is a hack to avoid running all of the `legacy-sdk` tests and to avoid
4+
# building the entire npm workspace.
5+
init = """
6+
set -e
7+
ln -s legacy-sdk/whirlpool/tests
8+
sed -i 's,--globals legacy-sdk,--globals tests/sdk/whirlpools/whirlpool-impl.test.ts,' Anchor.toml
9+
sed -i '\\,"rust-sdk/\\*",d' package.json
10+
sed -i '\\,"ts-sdk/\\*",d' package.json
11+
sed -i 's,"legacy-sdk/\\*".,"legacy-sdk/*",' package.json
12+
sed -i '\\,"examples/ts-sdk/\\*",d' package.json
13+
sed -i '\\,"examples/rust-sdk/\\*",d' package.json
14+
sed -i '\\,"docs/\\*",d' package.json
15+
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
16+
yarn build
17+
"""
18+
19+
target_os = "linux"
20+
21+
framework = "anchor"
22+
23+
source_files = ["tests/sdk/whirlpools/whirlpool-impl.test.ts"]
24+
25+
config_mandatory = true
26+
27+
[config]
28+
# smoelius: One `prependInstruction` removal passes locally but fails in CI. I haven't figured out
29+
# why.
30+
ignored_methods = ["prependInstruction"]
31+
# smoelius: Ignore all tests besides "open and add liquidity to a position, trade against it,
32+
# transfer position to another wallet, then close the tokens to another wallet".
33+
ignored_tests = [
34+
"open and add liquidity to a position, then close [TokenAmount Slippage]",
35+
"open and add liquidity to a position, transfer position to another wallet, then close the tokens to another wallet [TokenAmount Slippage]",
36+
"open and add liquidity to a position, then close [Price Slippage]",
37+
"open and add liquidity to a position, transfer position to another wallet, then close the tokens to another wallet [Price Slippage]",
38+
"open and add liquidity to a position with SOL as token A, trade against it, transfer position to another wallet, then close the tokens to another wallet",
39+
"swap with idempotent",
40+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
42 candidates in 1 test in 1 source file
2+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: dry running
3+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: mutilating
4+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `await toTx(
5+
ctx,
6+
WhirlpoolIx.swapV2Ix(ctx.program, {
7+
amount: new BN(200_000),
8+
otherAmountThreshold: ZERO_BN,
9+
sqrtPriceLimit: MathUtil.toX64(new Decimal(4)),
10+
amountSpecifiedIsInput: true,
11+
aToB: true,
12+
whirlpool: whirlpoolPda.publicKey,
13+
tokenAuthority: ctx.wallet.publicKey,
14+
tokenOwnerAccountA: tokenAccountA,
15+
tokenVaultA: tokenVaultAKeypair.publicKey,
16+
tokenOwnerAccountB: tokenAccountB,
17+
tokenVaultB: tokenVaultBKeypair.publicKey,
18+
tickArray0: tickArrayPda.publicKey,
19+
tickArray1: tickArrayPda.publicKey,
20+
tickArray2: tickArrayPda.publicKey,
21+
oracle: oraclePda.publicKey,
22+
tokenMintA: tokenExtensionCtx.tokenMintWithProgramA.address,
23+
tokenMintB: tokenExtensionCtx.tokenMintWithProgramB.address,
24+
tokenProgramA: tokenExtensionCtx.tokenMintWithProgramA.tokenProgram,
25+
tokenProgramB: tokenExtensionCtx.tokenMintWithProgramB.tokenProgram,
26+
...(await TokenExtensionUtil.getExtraAccountMetasForTransferHookForPool(
27+
ctx.connection,
28+
tokenExtensionCtx,
29+
tokenAccountA,
30+
tokenVaultAKeypair.publicKey,
31+
ctx.wallet.publicKey,
32+
tokenVaultBKeypair.publicKey,
33+
tokenAccountB,
34+
whirlpoolPda.publicKey,
35+
)),
36+
}),
37+
)
38+
.prependInstruction(useMaxCU()) // TransferHook require much CU
39+
.buildAndExecute();` passed
40+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `await toTx(
41+
ctx,
42+
WhirlpoolIx.swapV2Ix(ctx.program, {
43+
amount: new BN(200_000),
44+
otherAmountThreshold: ZERO_BN,
45+
sqrtPriceLimit: MathUtil.toX64(new Decimal(5)),
46+
amountSpecifiedIsInput: true,
47+
aToB: false,
48+
whirlpool: whirlpoolPda.publicKey,
49+
tokenAuthority: ctx.wallet.publicKey,
50+
tokenOwnerAccountA: tokenAccountA,
51+
tokenVaultA: tokenVaultAKeypair.publicKey,
52+
tokenOwnerAccountB: tokenAccountB,
53+
tokenVaultB: tokenVaultBKeypair.publicKey,
54+
tickArray0: tickArrayPda.publicKey,
55+
tickArray1: tickArrayPda.publicKey,
56+
tickArray2: tickArrayPda.publicKey,
57+
oracle: oraclePda.publicKey,
58+
tokenMintA: tokenExtensionCtx.tokenMintWithProgramA.address,
59+
tokenMintB: tokenExtensionCtx.tokenMintWithProgramB.address,
60+
tokenProgramA: tokenExtensionCtx.tokenMintWithProgramA.tokenProgram,
61+
tokenProgramB: tokenExtensionCtx.tokenMintWithProgramB.tokenProgram,
62+
...(await TokenExtensionUtil.getExtraAccountMetasForTransferHookForPool(
63+
ctx.connection,
64+
tokenExtensionCtx,
65+
tokenVaultAKeypair.publicKey,
66+
tokenAccountA,
67+
whirlpoolPda.publicKey,
68+
tokenAccountB,
69+
tokenVaultBKeypair.publicKey,
70+
ctx.wallet.publicKey,
71+
)),
72+
}),
73+
)
74+
.prependInstruction(useMaxCU()) // TransferHook require much CU
75+
.buildAndExecute();` passed
76+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `await sleep(1200);` failed
77+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `await transferToken(
78+
provider,
79+
walletPositionTokenAccount,
80+
newOwnerPositionTokenAccount,
81+
1,
82+
);` failed
83+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `signatures.push(await tx.addSigner(otherWallet).buildAndExecute());` failed
84+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.init({
85+
tokenTraitA: tokenTraits.tokenTraitA,
86+
tokenTraitB: tokenTraits.tokenTraitB,
87+
tickSpacing,
88+
positions: [
89+
{
90+
tickLowerIndex,
91+
tickUpperIndex,
92+
liquidityAmount: new anchor.BN(10_000_000),
93+
}, // In range position
94+
{
95+
tickLowerIndex: 0,
96+
tickUpperIndex: 128,
97+
liquidityAmount: new anchor.BN(1_000_000),
98+
}, // Out of range position
99+
],
100+
rewards: [
101+
{
102+
rewardTokenTrait: { isToken2022: false },
103+
emissionsPerSecondX64: MathUtil.toX64(new Decimal(10)),
104+
vaultAmount: new BN(vaultStartBalance),
105+
},
106+
{
107+
rewardTokenTrait: { isToken2022: false },
108+
emissionsPerSecondX64: MathUtil.toX64(new Decimal(5)),
109+
vaultAmount: new BN(vaultStartBalance),
110+
},
111+
{
112+
rewardTokenTrait: { isToken2022: false },
113+
emissionsPerSecondX64: MathUtil.toX64(new Decimal(10)),
114+
vaultAmount: new BN(vaultStartBalance),
115+
},
116+
],
117+
})` nonbuildable
118+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.toX64(new Decimal(10))` nonbuildable
119+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.toX64(new Decimal(5))` nonbuildable
120+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.toX64(new Decimal(10))` nonbuildable
121+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getInfos()` passed
122+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getTickArray(
123+
ctx.program.programId,
124+
whirlpoolPda.publicKey,
125+
22528,
126+
)` nonbuildable
127+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getOracle(
128+
ctx.program.programId,
129+
whirlpoolPda.publicKey,
130+
)` nonbuildable
131+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.buildTokenExtensionContext(
132+
ctx.fetcher,
133+
(
134+
await client.getPool(whirlpoolPda.publicKey, IGNORE_CACHE)
135+
).getData(),
136+
IGNORE_CACHE,
137+
)` nonbuildable
138+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getPool(whirlpoolPda.publicKey, IGNORE_CACHE)` nonbuildable
139+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getData()` nonbuildable
140+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.swapV2Ix(ctx.program, {
141+
amount: new BN(200_000),
142+
otherAmountThreshold: ZERO_BN,
143+
sqrtPriceLimit: MathUtil.toX64(new Decimal(4)),
144+
amountSpecifiedIsInput: true,
145+
aToB: true,
146+
whirlpool: whirlpoolPda.publicKey,
147+
tokenAuthority: ctx.wallet.publicKey,
148+
tokenOwnerAccountA: tokenAccountA,
149+
tokenVaultA: tokenVaultAKeypair.publicKey,
150+
tokenOwnerAccountB: tokenAccountB,
151+
tokenVaultB: tokenVaultBKeypair.publicKey,
152+
tickArray0: tickArrayPda.publicKey,
153+
tickArray1: tickArrayPda.publicKey,
154+
tickArray2: tickArrayPda.publicKey,
155+
oracle: oraclePda.publicKey,
156+
tokenMintA: tokenExtensionCtx.tokenMintWithProgramA.address,
157+
tokenMintB: tokenExtensionCtx.tokenMintWithProgramB.address,
158+
tokenProgramA: tokenExtensionCtx.tokenMintWithProgramA.tokenProgram,
159+
tokenProgramB: tokenExtensionCtx.tokenMintWithProgramB.tokenProgram,
160+
...(await TokenExtensionUtil.getExtraAccountMetasForTransferHookForPool(
161+
ctx.connection,
162+
tokenExtensionCtx,
163+
tokenAccountA,
164+
tokenVaultAKeypair.publicKey,
165+
ctx.wallet.publicKey,
166+
tokenVaultBKeypair.publicKey,
167+
tokenAccountB,
168+
whirlpoolPda.publicKey,
169+
)),
170+
})` nonbuildable
171+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.toX64(new Decimal(4))` nonbuildable
172+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getExtraAccountMetasForTransferHookForPool(
173+
ctx.connection,
174+
tokenExtensionCtx,
175+
tokenAccountA,
176+
tokenVaultAKeypair.publicKey,
177+
ctx.wallet.publicKey,
178+
tokenVaultBKeypair.publicKey,
179+
tokenAccountB,
180+
whirlpoolPda.publicKey,
181+
)` nonbuildable
182+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `// TransferHook require much CU
183+
.buildAndExecute()` passed
184+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.swapV2Ix(ctx.program, {
185+
amount: new BN(200_000),
186+
otherAmountThreshold: ZERO_BN,
187+
sqrtPriceLimit: MathUtil.toX64(new Decimal(5)),
188+
amountSpecifiedIsInput: true,
189+
aToB: false,
190+
whirlpool: whirlpoolPda.publicKey,
191+
tokenAuthority: ctx.wallet.publicKey,
192+
tokenOwnerAccountA: tokenAccountA,
193+
tokenVaultA: tokenVaultAKeypair.publicKey,
194+
tokenOwnerAccountB: tokenAccountB,
195+
tokenVaultB: tokenVaultBKeypair.publicKey,
196+
tickArray0: tickArrayPda.publicKey,
197+
tickArray1: tickArrayPda.publicKey,
198+
tickArray2: tickArrayPda.publicKey,
199+
oracle: oraclePda.publicKey,
200+
tokenMintA: tokenExtensionCtx.tokenMintWithProgramA.address,
201+
tokenMintB: tokenExtensionCtx.tokenMintWithProgramB.address,
202+
tokenProgramA: tokenExtensionCtx.tokenMintWithProgramA.tokenProgram,
203+
tokenProgramB: tokenExtensionCtx.tokenMintWithProgramB.tokenProgram,
204+
...(await TokenExtensionUtil.getExtraAccountMetasForTransferHookForPool(
205+
ctx.connection,
206+
tokenExtensionCtx,
207+
tokenVaultAKeypair.publicKey,
208+
tokenAccountA,
209+
whirlpoolPda.publicKey,
210+
tokenAccountB,
211+
tokenVaultBKeypair.publicKey,
212+
ctx.wallet.publicKey,
213+
)),
214+
})` nonbuildable
215+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.toX64(new Decimal(5))` nonbuildable
216+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getExtraAccountMetasForTransferHookForPool(
217+
ctx.connection,
218+
tokenExtensionCtx,
219+
tokenVaultAKeypair.publicKey,
220+
tokenAccountA,
221+
whirlpoolPda.publicKey,
222+
tokenAccountB,
223+
tokenVaultBKeypair.publicKey,
224+
ctx.wallet.publicKey,
225+
)` nonbuildable
226+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `// TransferHook require much CU
227+
.buildAndExecute()` passed
228+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.web3.Keypair.generate()` nonbuildable
229+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getPool(whirlpoolPda.publicKey, IGNORE_CACHE)` nonbuildable
230+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getPosition(
231+
positionWithFees.publicKey,
232+
IGNORE_CACHE,
233+
)` nonbuildable
234+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getData()` nonbuildable
235+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getData()` nonbuildable
236+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.closePosition(
237+
positionWithFees.publicKey,
238+
new Percentage(new BN(10), new BN(100)),
239+
otherWallet.publicKey,
240+
otherWallet.publicKey,
241+
ctx.wallet.publicKey,
242+
)` nonbuildable
243+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getData()` nonbuildable
244+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.fromDecimal(new Decimal(0))` nonbuildable
245+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.buildTokenExtensionContext(
246+
fetcher,
247+
poolData,
248+
IGNORE_CACHE,
249+
)` nonbuildable
250+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getLowerTickData()` nonbuildable
251+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getUpperTickData()` nonbuildable
252+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.buildTokenExtensionContext(
253+
fetcher,
254+
poolData,
255+
IGNORE_CACHE,
256+
)` nonbuildable
257+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.push(await tx.addSigner(otherWallet).buildAndExecute())` nonbuildable
258+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.addSigner(otherWallet)` nonbuildable
259+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.buildAndExecute()` nonbuildable
260+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.provider.connection.getTransaction(signatures[0], {
261+
maxSupportedTransactionVersion: 0,
262+
})` nonbuildable
263+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getLowerTickData()` nonbuildable
264+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.getUpperTickData()` nonbuildable
265+
$DIR/legacy-sdk/whirlpool/tests/sdk/whirlpools/whirlpool-impl.test.ts: `.buildTokenExtensionContext(
266+
fetcher,
267+
poolData,
268+
IGNORE_CACHE,
269+
)` nonbuildable

0 commit comments

Comments
 (0)