Skip to content

Commit 94174ad

Browse files
authored
Test migration (#1115)
* [Test Migration][1] Add litesvm configuration files * [Test Migration][2] Migrate adaptive-fee tests * [Test Migration][3] Migrate migration tests * [Test Migration][4] Migrate multi-ix tests * [Test Migration][5] Migrate token-badge tests * [Test Migration][6] Migrate token-extensions tests * [Test Migration][7] Migrate v1-ix tests * [Test Migration][8] Migrate v2-ix tests * [Test Migration][9] Migrate client-impl tests * [Test Migration][10] Migrate swap tests * [Test Migration][11] Migrate sdk utils * [Test Migration][12] Remove anchor integration tests and update script * [Test Migration][13] Update changeset * [Test Migration][14] Temporarily disable test script
1 parent 3c0f9a2 commit 94174ad

File tree

132 files changed

+5492
-2724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+5492
-2724
lines changed

.changeset/breezy-symbols-warn.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
---
3+
4+
Migrate integration tests from Anchor test validator to LiteSVM for improved test performance and reliability. This change includes:
5+
6+
- Updated test infrastructure to support versioned transactions in LiteSVM
7+
- Added polling mechanisms for state synchronization in LiteSVM environment
8+
- Fixed type safety issues in test setup and helpers
9+
- Simplified Anchor.toml configuration now that tests use LiteSVM
10+
11+
This is an internal infrastructure change that does not affect public APIs or functionality.

.github/workflows/checks.yml

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,75 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
1312
build:
1413
runs-on: ubuntu-latest
1514
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v5
18-
- name: Setup Anchor
19-
uses: ./.github/actions/anchor
20-
- name: Install dependencies
21-
run: yarn install
22-
- name: Build packages
23-
run: yarn build --output-style static
15+
- name: Checkout repository
16+
uses: actions/checkout@v5
17+
- name: Setup Anchor
18+
uses: ./.github/actions/anchor
19+
- name: Install dependencies
20+
run: yarn install
21+
- name: Build packages
22+
run: yarn build --output-style static
2423

2524
test:
25+
if: false # temporarily disable test script
2626
runs-on: ubuntu-latest
2727
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v5
30-
- name: Remove Unnecessary Files
31-
uses: ./.github/actions/cleanup
32-
- name: Setup Anchor
33-
uses: ./.github/actions/anchor
34-
- name: Install dependencies
35-
run: yarn install
36-
- name: Run tests
37-
run: yarn test --exclude legacy-sdk/integration --exclude rust-sdk/integration --output-style static
28+
- name: Checkout repository
29+
uses: actions/checkout@v5
30+
- name: Add swap to increase memory
31+
run: |
32+
sudo fallocate -l 16G /swapfile
33+
sudo chmod 600 /swapfile
34+
sudo mkswap /swapfile
35+
sudo swapon /swapfile
36+
free -h
37+
- name: Remove Unnecessary Files
38+
uses: ./.github/actions/cleanup
39+
- name: Setup Anchor
40+
uses: ./.github/actions/anchor
41+
- name: Install dependencies
42+
run: yarn install
43+
- name: Build common SDK
44+
run: yarn workspace @orca-so/common-sdk build
45+
- name: Build Whirlpool program (IDL)
46+
run: yarn workspace @orca-so/whirlpools-program build
47+
- name: Build legacy SDK only
48+
env:
49+
NODE_OPTIONS: --max-old-space-size=8192
50+
run: yarn workspace @orca-so/whirlpools-sdk build
51+
- name: Run LiteSVM-safe tests
52+
env:
53+
NODE_OPTIONS: --max-old-space-size=8192
54+
VITEST_SEGFAULT_RETRY: "2"
55+
run: |
56+
yarn vitest run legacy-sdk/whirlpool \
57+
--config legacy-sdk/whirlpool/vitest.config.mts \
58+
--reporter verbose
59+
- name: Run remaining Nx tests
60+
run: |
61+
yarn nx run-many \
62+
--target=test \
63+
--all \
64+
--exclude=whirlpools-sdk \
65+
--exclude=legacy-sdk/integration \
66+
--exclude=rust-sdk/integration
3867
3968
lint:
4069
runs-on: ubuntu-latest
4170
steps:
42-
- name: Checkout repository
43-
uses: actions/checkout@v5
44-
- name: Remove Unnecessary Files
45-
uses: ./.github/actions/cleanup
46-
- name: Setup Anchor
47-
uses: ./.github/actions/anchor
48-
- name: Install dependencies
49-
run: yarn install
50-
- name: Run Lint
51-
run: yarn lint --output-style static
71+
- name: Checkout repository
72+
uses: actions/checkout@v5
73+
- name: Remove Unnecessary Files
74+
uses: ./.github/actions/cleanup
75+
- name: Setup Anchor
76+
uses: ./.github/actions/anchor
77+
- name: Install dependencies
78+
run: yarn install
79+
- name: Run Lint
80+
run: yarn lint --output-style static
5281

5382
verify-generated:
5483
runs-on: ubuntu-latest
@@ -71,13 +100,11 @@ jobs:
71100
runs-on: ubuntu-latest
72101
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
73102
steps:
74-
- name: Checkout repository
75-
uses: actions/checkout@v5
76-
with:
77-
fetch-depth: 0
78-
- name: Install dependencies
79-
run: yarn install
80-
- name: Check changesets
81-
run: yarn changeset status --since origin/main
82-
83-
103+
- name: Checkout repository
104+
uses: actions/checkout@v5
105+
with:
106+
fetch-depth: 0
107+
- name: Install dependencies
108+
run: yarn install
109+
- name: Check changesets
110+
run: yarn changeset status --since origin/main

Anchor.toml

Lines changed: 4 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Anchor configuration for Whirlpool program
2+
# Note: Tests now use LiteSVM instead of Anchor's test validator.
3+
# External programs and preloaded accounts are configured in litesvm.ts.
4+
15
[programs.localnet]
26
whirlpool = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
37

@@ -7,104 +11,3 @@ url = "https://anchor.projectserum.com"
711
[provider]
812
cluster = "localnet"
913
wallet = "~/.config/solana/id.json"
10-
11-
[scripts]
12-
# When you run "anchor test" command, it searches for Test.toml files under the anchor_tests directory and executes them in order.
13-
# These tests are large and require several hours to complete.
14-
#
15-
# If you want to run only specific test cases, specify the directory where Test.toml resides using --run option.
16-
#
17-
# Example 1) Run all tests
18-
#
19-
# anchor test
20-
#
21-
# Example 2) Run only the tests for integration/token-badge
22-
#
23-
# anchor test --run anchor_tests/int/token-badge
24-
#
25-
# Example 3) Run only the tests for integration/token-badge and sdk/whirlpools/utils
26-
#
27-
# anchor test --run anchor_tests/int/token-badge --run anchor_tests/sdk/utils
28-
29-
[test.validator]
30-
# If we use slot_per_epoch = "33", rent for Position account (216 byte) was not 0.00239424 but 0.002394239
31-
slots_per_epoch = "32"
32-
ticks_per_slot = 7
33-
url = "https://api.mainnet-beta.solana.com"
34-
35-
# In v0.29.0, this doesn't work because ProgramData account is cloned with executable = false (anchor bug ?)
36-
# So we need to use test.genesis config.
37-
# [[test.validator.clone]]
38-
# address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
39-
40-
[[test.genesis]]
41-
address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
42-
program = "legacy-sdk/whirlpool/tests/external_program/mpl_token_metadata.20240214.so"
43-
44-
[[test.genesis]]
45-
address = "EBZDYx7599krFc4m2govwBdZcicr4GgepqC78m71nsHS"
46-
program = "legacy-sdk/whirlpool/tests/external_program/transfer_hook_counter.so"
47-
48-
# Newer Token-2022
49-
[[test.genesis]]
50-
address = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
51-
program = "legacy-sdk/whirlpool/tests/external_program/token_2022.20250510.so"
52-
53-
# For reset_position_range test
54-
# Now, it is impossible to initialize position account without additional rent for ticks.
55-
# So we need to load test old position account without the additional rent.
56-
[[test.validator.account]]
57-
address = "4GQ4VQZKPt4fLxGCusfdBZia2ge5hUZpfwwr3pqxUrmf"
58-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/owner_wallet.json"
59-
[[test.validator.account]]
60-
address = "Jd4M8bfJG3sAkd82RsGWyEXoaBXQP7njFzBwEaCTuDa"
61-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/token_a.json"
62-
[[test.validator.account]]
63-
address = "BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k"
64-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/token_b.json"
65-
[[test.validator.account]]
66-
address = "EgxU92G34jw6QDG9RuTX9StFg1PmHuDqkRKAE5kVEiZ4"
67-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/whirlpool.json"
68-
[[test.validator.account]]
69-
address = "GedZgiHw8dJpR6Fyt1PNgSwYznEyh18qgZvobuxYxMQ3"
70-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/vault_a.json"
71-
[[test.validator.account]]
72-
address = "4KDudC7XagDiZZbd9Xzabcy5yZMC8bvz7c8q7Bb9vXTa"
73-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/vault_b.json"
74-
[[test.validator.account]]
75-
address = "AihMywzP74pU2riq1ihFW2YSVcc1itT3yiP7minvkxDs"
76-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/fixed_tick_array_lower.json"
77-
[[test.validator.account]]
78-
address = "F4h3qr6uBgdLDJyTms4YiebiaiuCEvC5C9LJE8scA1LV"
79-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/fixed_tick_array_upper.json"
80-
[[test.validator.account]]
81-
address = "CzKujYEJWNCvFHhjCBcv5gKnnTdvXrQ3b9ecxyZQV6sg"
82-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/position_mint.json"
83-
[[test.validator.account]]
84-
address = "J6DFYFKUsoMYgxkbeAqVnpSb8fniA9tHR44ZQu8KBgMS"
85-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/position.json"
86-
[[test.validator.account]]
87-
address = "6wGj2VeDPPP1ni6TJA1KuwExFXCWKsvXLyJZvfBsfgWY"
88-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/position_ata.json"
89-
[[test.validator.account]]
90-
address = "oH6UWXaG2uvePMcqR9bih8E2Gt9eS4jhYx5VyAEC4k1"
91-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/token_a_ata.json"
92-
[[test.validator.account]]
93-
address = "7kshCxjaA7uY2C77X733ZZjM1EE31FhceM9dm4QXrxqZ"
94-
filename = "legacy-sdk/whirlpool/tests/preload_account/reset_position_range/token_b_ata.json"
95-
96-
# For migrate_repurpose_reward_authority_space test
97-
# Now, it is impossible to initialize whirlpool with 3 reward authorities (not migrated layout)
98-
# So we need to load test old Whirlpool account.
99-
[[test.validator.account]]
100-
address = "7vWRTPPBq3aNaJZsrfterTz1BSjht4YSHBXJwnbuV6SC"
101-
filename = "legacy-sdk/whirlpool/tests/preload_account/migrate_repurpose_reward_authority_space/whirlpool.json"
102-
103-
# For open_position_with_token_extensions test
104-
# Now, it is impossible to initialize whirlpool with 3 reward authorities (not migrated layout)
105-
# So we need to load test old Whirlpool account.
106-
# This account has not been migrated, and unless that is recognized, the bit array may be misinterpreted as control_flags,
107-
# potentially resulting in the creation of a non-transferable position.
108-
[[test.validator.account]]
109-
address = "Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE"
110-
filename = "legacy-sdk/whirlpool/tests/preload_account/open_position_with_token_extensions/whirlpool.json"

anchor_tests/int/adaptive-fee/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/migration/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/multi-ix/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/token-badge/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/token-extensions/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/v1-ix/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

anchor_tests/int/v2-ix/collect/Test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)