Skip to content

Commit 3acd038

Browse files
authored
Merge pull request #31 from LiteSVM/port-to-litesvm
port to litesvm
2 parents a2f0ba0 + 41dfe2c commit 3acd038

File tree

7 files changed

+174
-187
lines changed

7 files changed

+174
-187
lines changed

CHANGELOG.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
11
# Changelog
22

3-
## [0.5.0] - 2024-10-18
4-
5-
- Re-export `startAnchor` from `solana-bankrun`
6-
- Require `solana/web3.js` >1.92.0 and fix SendTransactionError construction
7-
8-
## [0.4.1] - 2024-09-12
9-
10-
- Restrict solana/web3.js to <1.92 to avoid breaking change they introduced
11-
12-
## [0.4.0] - 2024-06-29
13-
14-
- BREAKING: Update to Anchor v0.30 [(#15)](https://github.com/kevinheavey/anchor-bankrun/pull/15)
15-
16-
## [0.3.0] - 2023-12-02
17-
18-
- Make `@solana/web3.js` a peer dependency [(#5)](https://github.com/kevinheavey/anchor-bankrun/pull/5)
19-
- Correctly handle missing transaction logs [(#10)](https://github.com/kevinheavey/anchor-bankrun/pull/10)
20-
21-
## [0.2.0] - 2023-09-08
22-
23-
- Add better support for Anchor-like errors [(#6)](https://github.com/kevinheavey/anchor-bankrun/pull/6)
24-
- Expose publicKey and add wallet to provider constructor [(#3)](https://github.com/kevinheavey/anchor-bankrun/pull/3)
25-
26-
## [0.1.0] - 2023-08-13
27-
28-
First release 🚀
3+
Unreleased

README.md

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
1-
# anchor-bankrun
1+
# anchor-litesvm
22

3-
`anchor-bankrun` is a small but powerful extension to [solana-bankrun](https://github.com/kevinheavey/solana-bankrun)
4-
that enables using both Anchor and Bankrun with only a one-line code change. It does this by exporting a `BankrunProvider` class that can be used as a drop-in replacement for `AnchorProvider` during testing.
3+
`anchor-litesvm` is a small extension to [LiteSVM](https://github.com/LiteSVM/litesvm)
4+
that enables using both Anchor and LiteSVM with minimal code changes. It does this by exporting a `LitesvmProvider` class that can be used as a replacement for `AnchorProvider` during testing.
55

6-
## Anchor version note
6+
## Async note
77

8-
Recent versions of `anchor-bankrun` use the Anchor v0.30 IDL, which is not backwards compatible with older Anchor IDLs.
9-
If you have an older IDL, use `anchor-bankrun` v0.3.0.
8+
`litesvm` is synchronous because it is entirely compute-bound. However, `anchor-litesvm` uses async because
9+
it implements interfaces that require async. If you would like to avoid async tests, you can simply
10+
use regular `litesvm` without `anchor-litesvm`.
1011

1112
## Usage
1213

13-
Here's an example using `BankrunProvider` to test an Anchor program:
14+
Here's an example using `LitesvmProvider` to test an Anchor program:
1415

1516
```typescript
16-
import { BankrunProvider, startAnchor } from "anchor-bankrun";
17+
import { fromWorkspace, LiteSVMProvider } from "anchor-litesvm";
1718
import { Keypair, PublicKey } from "@solana/web3.js";
18-
import { BN, Program } from "@coral-xyz/anchor";
19+
import { BN, Program, Wallet } from "@coral-xyz/anchor";
1920
import { Puppet } from "./anchor-example/puppet";
2021
const IDL = require("./anchor-example/puppet.json");
2122

2223
test("anchor", async () => {
23-
const context = await startAnchor("tests/anchor-example", [], []);
24-
25-
const provider = new BankrunProvider(context);
26-
27-
const puppetProgram = new Program<Puppet>(
28-
IDL,
29-
provider,
30-
);
31-
24+
const client = fromWorkspace("tests/anchor-example");
25+
const provider = new LiteSVMProvider(client);
26+
const puppetProgram = new Program<Puppet>(IDL, provider);
3227
const puppetKeypair = Keypair.generate();
3328
await puppetProgram.methods
3429
.initialize()
@@ -56,9 +51,5 @@ test("anchor", async () => {
5651
## Installation
5752

5853
```
59-
yarn add anchor-bankrun
54+
yarn add anchor-litesvm
6055
```
61-
62-
## Why is this a separate package?
63-
64-
I want to keep the Bankrun dependencies light.

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
2-
"name": "anchor-bankrun",
3-
"version": "0.5.0",
2+
"name": "anchor-litesvm",
3+
"version": "0.0.1",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
6-
"files": [
7-
"dist/"
8-
],
6+
"files": ["dist/"],
97
"license": "MIT",
108
"devDependencies": {
119
"@coral-xyz/anchor": "^0.30.0",
1210
"@solana/web3.js": ">1.92.0",
1311
"@types/bn.js": "^5.1.1",
1412
"@types/bs58": "^4.0.1",
1513
"@types/jest": "^29.5.3",
14+
"@types/node": "^22.10.7",
1615
"@types/node-fetch": "^2.6.4",
1716
"bs58": "^4.0.1",
1817
"jest": "^29.6.1",
18+
"litesvm": "0.0.2",
1919
"rome": "^12.0.0",
20-
"solana-bankrun": ">=0.2.0 <0.5.0",
2120
"ts-jest": "^29.1.1",
2221
"ts-node": "^10.9.1",
2322
"typescript": "^5.0.4"
@@ -28,7 +27,7 @@
2827
"scripts": {
2928
"fmt": "rome format --write src/index.ts tests/ jest.config.ts tsconfig.json package.json",
3029
"lint": "rome check src/index.ts tests/ jest.config.ts tsconfig.json package.json && tsc",
31-
"test": "RUST_LOG= jest --runInBand",
30+
"test": "jest",
3231
"tsc": "tsc",
3332
"bumpPatch": "yarn version --no-git-tag-version --patch",
3433
"bumpMinor": "yarn version --no-git-tag-version --minor",
@@ -38,6 +37,9 @@
3837
"peerDependencies": {
3938
"@coral-xyz/anchor": "^0.30.0",
4039
"@solana/web3.js": ">1.92.0",
41-
"solana-bankrun": ">=0.2.0 <0.5.0"
40+
"litesvm": "0.0.2"
41+
},
42+
"dependencies": {
43+
"@iarna/toml": "^2.2.5"
4244
}
4345
}

0 commit comments

Comments
 (0)