Skip to content

Commit acd102a

Browse files
authored
Use LiteSVM for JS client tests (#76)
1 parent 392d7a0 commit acd102a

10 files changed

Lines changed: 115 additions & 73 deletions

File tree

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ jobs:
8080
uses: ./.github/actions/setup
8181
with:
8282
pnpm: true
83-
solana: true
8483

8584
- name: Test Client JS
8685
run: make test-js

.github/workflows/publish-js-client.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
uses: ./.github/actions/setup
4040
with:
4141
pnpm: true
42-
solana: true
4342

4443
- name: Format
4544
run: make format-js

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,4 @@ lint-js:
3636
cd ./clients/js && pnpm install && pnpm lint
3737

3838
test-js:
39-
./scripts/restart-test-validator.sh
4039
cd ./clients/js && pnpm install && pnpm build && pnpm test
41-
./scripts/stop-test-validator.sh

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,3 @@ The following clients are available for the System program. You may use the foll
2929

3030
- [JS client](./clients/js)
3131
- [Rust client](./clients/rust)
32-
33-
## Starting and stopping the local validator
34-
35-
The following script is available to start or restart your local validator.
36-
37-
```sh
38-
./scripts/restart-test-validator.sh
39-
```
40-
41-
Finally, you may stop the local validator using the following command.
42-
43-
```sh
44-
./scripts/stop-test-validator.sh
45-
```

clients/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"devDependencies": {
5050
"@solana/eslint-config-solana": "^6.0.0",
51-
"@solana/kit-plugin-rpc": "^0.10.0",
51+
"@solana/kit-plugin-litesvm": "^0.10.0",
5252
"@solana/kit-plugin-signer": "^0.10.0",
5353
"@solana/kit": "^6.4.0",
5454
"@types/node": "^24",

clients/js/pnpm-lock.yaml

Lines changed: 106 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/test/_setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
lamports,
88
sequentialInstructionPlan,
99
} from '@solana/kit';
10-
import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
10+
import { litesvm } from '@solana/kit-plugin-litesvm';
1111
import { airdropSigner, generatedSigner } from '@solana/kit-plugin-signer';
1212
import {
1313
SYSTEM_PROGRAM_ADDRESS,
@@ -20,7 +20,7 @@ import {
2020
export const createTestClient = () => {
2121
return createClient()
2222
.use(generatedSigner())
23-
.use(solanaLocalRpc())
23+
.use(litesvm())
2424
.use(systemProgram())
2525
.use(airdropSigner(lamports(1_000_000_000n)));
2626
};

clients/js/test/advanceNonceAccount.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ it('advances the nonce account', async () => {
1212
await client.sendTransaction(await getCreateNonceInstructionPlan(client, nonce, authority));
1313
const originalNonceAccount = await client.system.accounts.nonce.fetch(nonce.address);
1414

15+
// Expire the blockhash so the nonce's stored blockhash is no longer in the
16+
// RecentBlockhashes sysvar. On a live cluster this happens naturally between
17+
// blocks; under LiteSVM we have to trigger it explicitly, otherwise the
18+
// System Program returns NonceBlockhashNotExpired (error 7).
19+
client.svm.expireBlockhash();
20+
1521
// When the authority advances the nonce account.
1622
await client.system.instructions
1723
.advanceNonceAccount({ nonceAccount: nonce.address, nonceAuthority: authority })

scripts/restart-test-validator.sh

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

scripts/stop-test-validator.sh

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

0 commit comments

Comments
 (0)