From a631aa4796eeaab35d4f331f384fb1d66ccd2f78 Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Sat, 29 Nov 2025 02:42:02 +0530 Subject: [PATCH 1/6] feat: add litesvm dependency to anchor package.json --- basics/account-data/anchor/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/basics/account-data/anchor/package.json b/basics/account-data/anchor/package.json index 1f32b9565..fc97ba3fc 100644 --- a/basics/account-data/anchor/package.json +++ b/basics/account-data/anchor/package.json @@ -9,6 +9,7 @@ "@types/mocha": "^9.0.0", "anchor-bankrun": "^0.4.0", "chai": "^4.3.4", + "litesvm": "^0.3.3", "mocha": "^9.0.3", "solana-bankrun": "^0.3.0", "ts-mocha": "^10.0.0", From d0aa2c033fa3c29d37d58972730a28361fb6c1d4 Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Sat, 29 Nov 2025 02:47:17 +0530 Subject: [PATCH 2/6] feat: update Anchor.toml with litesvm test scripts and add litesvm --- basics/account-data/anchor/Anchor.toml | 5 +- basics/account-data/anchor/pnpm-lock.yaml | 160 ++++++++++++++++++++++ 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/basics/account-data/anchor/Anchor.toml b/basics/account-data/anchor/Anchor.toml index cf39e320f..31b67f0d3 100644 --- a/basics/account-data/anchor/Anchor.toml +++ b/basics/account-data/anchor/Anchor.toml @@ -13,4 +13,7 @@ cluster = "Localnet" wallet = "~/.config/solana/id.json" [scripts] -test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" +test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" #For all test +#test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/test.ts" #For specific anchor test +bankrun-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/bankrun.test.ts" #For bankrun test +litesvm-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/litesvm.test.ts" #For litesvm test diff --git a/basics/account-data/anchor/pnpm-lock.yaml b/basics/account-data/anchor/pnpm-lock.yaml index aae81ea51..da02d0d75 100644 --- a/basics/account-data/anchor/pnpm-lock.yaml +++ b/basics/account-data/anchor/pnpm-lock.yaml @@ -30,6 +30,9 @@ importers: chai: specifier: ^4.3.4 version: 4.4.1 + litesvm: + specifier: ^0.3.3 + version: 0.3.3(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10) mocha: specifier: ^9.0.3 version: 9.2.2 @@ -78,9 +81,31 @@ packages: resolution: {integrity: sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==} engines: {node: '>=5.10'} + '@solana/codecs-core@2.3.0': + resolution: {integrity: sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw==} + engines: {node: '>=20.18.0'} + peerDependencies: + typescript: '>=5.3.3' + + '@solana/codecs-numbers@2.3.0': + resolution: {integrity: sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg==} + engines: {node: '>=20.18.0'} + peerDependencies: + typescript: '>=5.3.3' + + '@solana/errors@2.3.0': + resolution: {integrity: sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ==} + engines: {node: '>=20.18.0'} + hasBin: true + peerDependencies: + typescript: '>=5.3.3' + '@solana/web3.js@1.95.2': resolution: {integrity: sha512-SjlHp0G4qhuhkQQc+YXdGkI8EerCqwxvgytMgBpzMUQTafrkNant3e7pgilBGgjy/iM40ICvWBLgASTPMrQU7w==} + '@solana/web3.js@1.98.4': + resolution: {integrity: sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw==} + '@swc/helpers@0.5.12': resolution: {integrity: sha512-KMZNXiGibsW9kvZAO1Pam2JPTDBm+KSHMMHWdsyI/1DbIZjT2A6Gy3hblVXUMEDvUAKq+e0vL0X0o54owWji7g==} @@ -165,6 +190,9 @@ packages: base-x@3.0.9: resolution: {integrity: sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==} + base-x@5.0.1: + resolution: {integrity: sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -201,6 +229,9 @@ packages: bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} + bs58@6.0.0: + resolution: {integrity: sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==} + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -227,6 +258,10 @@ packages: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} + chalk@5.6.2: + resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + check-error@1.0.3: resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} @@ -244,6 +279,10 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + commander@14.0.2: + resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} + engines: {node: '>=20'} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -312,6 +351,9 @@ packages: fast-stable-stringify@1.0.0: resolution: {integrity: sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==} + fastestsmallesttextencoderdecoder@1.0.22: + resolution: {integrity: sha512-Pb8d48e+oIuY4MaM64Cd7OW1gt4nxCHs7/ddPPZ/Ic3sg8yVGM7O9wDvZ7us6ScaUupzM+pfBolwtYhN1IxBIw==} + file-uri-to-path@1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} @@ -429,6 +471,40 @@ packages: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} + litesvm-darwin-arm64@0.3.3: + resolution: {integrity: sha512-81YimsV3ezWjWLgoKixsXfVznaaecbURE3RtECgNb6Din6Za03pKGKGEN4gkyecHkv8uoPaEZv5cl6ARsgeN1Q==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [darwin] + + litesvm-darwin-x64@0.3.3: + resolution: {integrity: sha512-pYietuU165Bl+2eDnVp2Eidiedfjt+pljyyBAfJPbYriaFyG577mU364NiNcsfQ8ZZWbe+ygIEAVq4Ol247+1g==} + engines: {node: '>= 20'} + cpu: [x64] + os: [darwin] + + litesvm-linux-arm64-musl@0.3.3: + resolution: {integrity: sha512-mkI15rWtNbaJxVFUfh+qnolqnDCZEqhwSZo/XZ48TZNsQ69vAqY00KhyFhTVJ+jeaYCAZTSNamuFIiRBxqVmNg==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [linux] + + litesvm-linux-x64-gnu@0.3.3: + resolution: {integrity: sha512-Qai2/E8Eq03w8VKnJDREyiWxwavjykW/H6onE179ayMnBjVVmkj5fN7XF50VV4z73kasx5bpDzBNK8fcaxMdzA==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + + litesvm-linux-x64-musl@0.3.3: + resolution: {integrity: sha512-bpWZ2f506hbfu1y6bkmuZf+qqtnLDxggpOMTQbibjd+q6faEO3sETWwKGlIgHB99P8wyU+aXKwLSGQX2sJEw6Q==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + + litesvm@0.3.3: + resolution: {integrity: sha512-QHXjAIXzvG0uAMOza6aJcYl19yTKz3guwq/z0Zml4KnQxyQvPhjaBpUFc5sf2ey/NxMVdqFhoXmL02CXOOomjw==} + engines: {node: '>= 20'} + locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -782,6 +858,23 @@ snapshots: dependencies: buffer: 6.0.3 + '@solana/codecs-core@2.3.0(typescript@4.9.5)': + dependencies: + '@solana/errors': 2.3.0(typescript@4.9.5) + typescript: 4.9.5 + + '@solana/codecs-numbers@2.3.0(typescript@4.9.5)': + dependencies: + '@solana/codecs-core': 2.3.0(typescript@4.9.5) + '@solana/errors': 2.3.0(typescript@4.9.5) + typescript: 4.9.5 + + '@solana/errors@2.3.0(typescript@4.9.5)': + dependencies: + chalk: 5.6.2 + commander: 14.0.2 + typescript: 4.9.5 + '@solana/web3.js@1.95.2(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@babel/runtime': 7.25.0 @@ -804,6 +897,29 @@ snapshots: - encoding - utf-8-validate + '@solana/web3.js@1.98.4(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10)': + dependencies: + '@babel/runtime': 7.25.0 + '@noble/curves': 1.4.2 + '@noble/hashes': 1.8.0 + '@solana/buffer-layout': 4.0.1 + '@solana/codecs-numbers': 2.3.0(typescript@4.9.5) + agentkeepalive: 4.5.0 + bn.js: 5.2.2 + borsh: 0.7.0 + bs58: 4.0.1 + buffer: 6.0.3 + fast-stable-stringify: 1.0.0 + jayson: 4.1.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + node-fetch: 2.7.0 + rpc-websockets: 9.0.2 + superstruct: 2.0.2 + transitivePeerDependencies: + - bufferutil + - encoding + - typescript + - utf-8-validate + '@swc/helpers@0.5.12': dependencies: tslib: 2.6.2 @@ -881,6 +997,8 @@ snapshots: dependencies: safe-buffer: 5.2.1 + base-x@5.0.1: {} + base64-js@1.5.1: {} bigint-buffer@1.1.5: @@ -918,6 +1036,10 @@ snapshots: dependencies: base-x: 3.0.9 + bs58@6.0.0: + dependencies: + base-x: 5.0.1 + buffer-from@1.1.2: {} buffer-layout@1.2.2: {} @@ -949,6 +1071,8 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 + chalk@5.6.2: {} + check-error@1.0.3: dependencies: get-func-name: 2.0.2 @@ -977,6 +1101,8 @@ snapshots: color-name@1.1.4: {} + commander@14.0.2: {} + commander@2.20.3: {} concat-map@0.0.1: {} @@ -1025,6 +1151,8 @@ snapshots: fast-stable-stringify@1.0.0: {} + fastestsmallesttextencoderdecoder@1.0.22: {} + file-uri-to-path@1.0.0: {} fill-range@7.0.1: @@ -1134,6 +1262,38 @@ snapshots: jsonparse@1.3.1: {} + litesvm-darwin-arm64@0.3.3: + optional: true + + litesvm-darwin-x64@0.3.3: + optional: true + + litesvm-linux-arm64-musl@0.3.3: + optional: true + + litesvm-linux-x64-gnu@0.3.3: + optional: true + + litesvm-linux-x64-musl@0.3.3: + optional: true + + litesvm@0.3.3(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10): + dependencies: + '@solana/web3.js': 1.98.4(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10) + bs58: 6.0.0 + fastestsmallesttextencoderdecoder: 1.0.22 + optionalDependencies: + litesvm-darwin-arm64: 0.3.3 + litesvm-darwin-x64: 0.3.3 + litesvm-linux-arm64-musl: 0.3.3 + litesvm-linux-x64-gnu: 0.3.3 + litesvm-linux-x64-musl: 0.3.3 + transitivePeerDependencies: + - bufferutil + - encoding + - typescript + - utf-8-validate + locate-path@6.0.0: dependencies: p-locate: 5.0.0 From a1ecdc7305ca77f29fef5c7369ffcd793e610cbc Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Sat, 29 Nov 2025 02:54:22 +0530 Subject: [PATCH 3/6] feat: add LiteSVM test for account data operations for anchor program --- .../account-data/anchor/tests/litesvm.test.ts | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 basics/account-data/anchor/tests/litesvm.test.ts diff --git a/basics/account-data/anchor/tests/litesvm.test.ts b/basics/account-data/anchor/tests/litesvm.test.ts new file mode 100644 index 000000000..504cf4d06 --- /dev/null +++ b/basics/account-data/anchor/tests/litesvm.test.ts @@ -0,0 +1,112 @@ +import { BorshCoder } from "@coral-xyz/anchor"; +import { + Keypair, + PublicKey, + SystemProgram, + Transaction, + TransactionInstruction, +} from "@solana/web3.js"; +import { LiteSVM } from "litesvm"; + +import IDL from "../target/idl/account_data_anchor_program.json" with { + type: "json", +}; + +describe("Account Data!", () => { + let litesvm: LiteSVM; + let programId: PublicKey; + let payer: Keypair; + let addressInfoAccount: Keypair; + const coder = new BorshCoder(IDL); + + before(() => { + litesvm = new LiteSVM(); + programId = new PublicKey(IDL.address); + payer = Keypair.generate(); + addressInfoAccount = Keypair.generate(); + + const programPath = new URL( + "../target/deploy/account_data_anchor_program.so", + // @ts-ignore + import.meta.url, + ).pathname; + litesvm.addProgramFromFile(programId, programPath); + + litesvm.airdrop(payer.publicKey, BigInt(100000000000)); + }); + + it("Create the address info account", () => { + console.log(`Payer Address : ${payer.publicKey}`); + console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`); + + // Instruction Ix data + const addressInfoIns = { + name: "Joe C", + house_number: 136, + street: "Mile High Dr.", + city: "Solana Beach", + }; + + /** + * Convert into buffer and encode of instruction and arguments + */ + const data = coder.instruction.encode( + "create_address_info", + addressInfoIns, + ); + + /** + * Create Transactions + */ + + const ix = new TransactionInstruction({ + keys: [ + { + pubkey: payer.publicKey, + isSigner: true, + isWritable: true, + }, + { + pubkey: addressInfoAccount.publicKey, + isSigner: true, + isWritable: true, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + ], + programId, + data, + }); + + const tx = new Transaction().add(ix); + tx.feePayer = payer.publicKey; + tx.recentBlockhash = litesvm.latestBlockhash(); + tx.sign(payer, addressInfoAccount); + const res = litesvm.sendTransaction(tx); + // console.log(res.toString()); + }); + it("Read the new account's data", () => { + const accountInfoAcc = litesvm.getAccount(addressInfoAccount.publicKey); + if (!accountInfoAcc) { + throw new Error("Failed to fetch account info"); + } + + // console.log(accountInfoAcc) + + /** + * Decode the accounts' data + */ + const addressInfo = coder.accounts.decode( + "AddressInfo", + Buffer.from(accountInfoAcc.data), + ); + + console.log(`Name : ${addressInfo.name}`); + console.log(`House Num: ${addressInfo.house_number}`); + console.log(`Street : ${addressInfo.street}`); + console.log(`City : ${addressInfo.city}`); + }); +}); From fd8e92e1ecf5be4595b19d7145ec672bb79fe67b Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Sat, 29 Nov 2025 13:44:53 +0530 Subject: [PATCH 4/6] refactor: clean up Anchor.toml and litesvm test by removing commented code --- basics/account-data/anchor/Anchor.toml | 1 - basics/account-data/anchor/tests/litesvm.test.ts | 2 -- 2 files changed, 3 deletions(-) diff --git a/basics/account-data/anchor/Anchor.toml b/basics/account-data/anchor/Anchor.toml index 31b67f0d3..e8a7c0510 100644 --- a/basics/account-data/anchor/Anchor.toml +++ b/basics/account-data/anchor/Anchor.toml @@ -14,6 +14,5 @@ wallet = "~/.config/solana/id.json" [scripts] test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" #For all test -#test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/test.ts" #For specific anchor test bankrun-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/bankrun.test.ts" #For bankrun test litesvm-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/litesvm.test.ts" #For litesvm test diff --git a/basics/account-data/anchor/tests/litesvm.test.ts b/basics/account-data/anchor/tests/litesvm.test.ts index 504cf4d06..ce8e546d8 100644 --- a/basics/account-data/anchor/tests/litesvm.test.ts +++ b/basics/account-data/anchor/tests/litesvm.test.ts @@ -94,8 +94,6 @@ describe("Account Data!", () => { throw new Error("Failed to fetch account info"); } - // console.log(accountInfoAcc) - /** * Decode the accounts' data */ From fde6bd8dd5dbe3d5ff9b4d3ad1a21595bf8e5e3f Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Sat, 29 Nov 2025 14:17:12 +0530 Subject: [PATCH 5/6] chore: remove bankrun test, script and dependencies from Anchor.toml and package.json --- basics/account-data/anchor/Anchor.toml | 1 - basics/account-data/anchor/package.json | 2 - basics/account-data/anchor/pnpm-lock.yaml | 83 ------------------- .../account-data/anchor/tests/bankrun.test.ts | 63 -------------- 4 files changed, 149 deletions(-) delete mode 100644 basics/account-data/anchor/tests/bankrun.test.ts diff --git a/basics/account-data/anchor/Anchor.toml b/basics/account-data/anchor/Anchor.toml index e8a7c0510..84b12bbec 100644 --- a/basics/account-data/anchor/Anchor.toml +++ b/basics/account-data/anchor/Anchor.toml @@ -14,5 +14,4 @@ wallet = "~/.config/solana/id.json" [scripts] test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" #For all test -bankrun-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/bankrun.test.ts" #For bankrun test litesvm-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/litesvm.test.ts" #For litesvm test diff --git a/basics/account-data/anchor/package.json b/basics/account-data/anchor/package.json index fc97ba3fc..0c7cae69e 100644 --- a/basics/account-data/anchor/package.json +++ b/basics/account-data/anchor/package.json @@ -7,11 +7,9 @@ "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", - "anchor-bankrun": "^0.4.0", "chai": "^4.3.4", "litesvm": "^0.3.3", "mocha": "^9.0.3", - "solana-bankrun": "^0.3.0", "ts-mocha": "^10.0.0", "typescript": "^4.3.5" }, diff --git a/basics/account-data/anchor/pnpm-lock.yaml b/basics/account-data/anchor/pnpm-lock.yaml index da02d0d75..d5ab0a603 100644 --- a/basics/account-data/anchor/pnpm-lock.yaml +++ b/basics/account-data/anchor/pnpm-lock.yaml @@ -24,9 +24,6 @@ importers: '@types/mocha': specifier: ^9.0.0 version: 9.1.1 - anchor-bankrun: - specifier: ^0.4.0 - version: 0.4.0(@coral-xyz/anchor@0.32.1(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@solana/web3.js@1.95.2(bufferutil@4.0.8)(utf-8-validate@5.0.10))(solana-bankrun@0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) chai: specifier: ^4.3.4 version: 4.4.1 @@ -36,9 +33,6 @@ importers: mocha: specifier: ^9.0.3 version: 9.2.2 - solana-bankrun: - specifier: ^0.3.0 - version: 0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) ts-mocha: specifier: ^10.0.0 version: 10.0.0(mocha@9.2.2) @@ -150,14 +144,6 @@ packages: resolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==} engines: {node: '>= 8.0.0'} - anchor-bankrun@0.4.0: - resolution: {integrity: sha512-s+K7E0IGAlmkhuo8nbiqVsQf2yJ+3l9GjNQJSmkRDe25dQj4Yef9rJh77FH6EQ5H6yQYfzuhgm/5GD6JMjdTZg==} - engines: {node: '>= 10'} - peerDependencies: - '@coral-xyz/anchor': ^0.30.0 - '@solana/web3.js': ^1.78.4 - solana-bankrun: ^0.2.0 - ansi-colors@4.1.1: resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} engines: {node: '>=6'} @@ -618,39 +604,6 @@ packages: serialize-javascript@6.0.0: resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} - solana-bankrun-darwin-arm64@0.3.0: - resolution: {integrity: sha512-+NbDncf0U6l3knuacRBiqpjZ2DSp+5lZaAU518gH7/x6qubbui/d000STaIBK+uNTPBS/AL/bCN+7PkXqmA3lA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - - solana-bankrun-darwin-universal@0.3.0: - resolution: {integrity: sha512-1/F0xdMa4qvc5o6z16FCCbZ5jbdvKvxpx5kyPcMWRiRPwyvi+zltMxciPAYMlg3wslQqGz88uFhrBEzq2eTumQ==} - engines: {node: '>= 10'} - os: [darwin] - - solana-bankrun-darwin-x64@0.3.0: - resolution: {integrity: sha512-U6CANjkmMl+lgNA7UH0GKs5V7LtVIUDzJBZefGGqLfqUNv3EjA/PrrToM0hAOWJgkxSwdz6zW+p5sw5FmnbXtg==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - - solana-bankrun-linux-x64-gnu@0.3.0: - resolution: {integrity: sha512-qJSkCFs0k2n4XtTnyxGMiZsuqO2TiqTYgWjQ+3mZhGNUAMys/Vq8bd7/SyBm6RR7EfVuRXRxZvh+F8oKZ77V4w==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - solana-bankrun-linux-x64-musl@0.3.0: - resolution: {integrity: sha512-xsS2CS2xb1Sw4ivNXM0gPz/qpW9BX0neSvt/pnok5L330Nu9xlTnKAY8FhzzqOP9P9sJlGRM787Y6d0yYwt6xQ==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - solana-bankrun@0.3.0: - resolution: {integrity: sha512-YkH7sa8TB/AoRPzG17CXJtYsRIQHEkEqGLz1Vwc13taXhDBkjO7z6NI5JYw7n0ybRymDHwMYTc7sd+5J40TyVQ==} - engines: {node: '>= 10'} - source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} @@ -966,12 +919,6 @@ snapshots: dependencies: humanize-ms: 1.2.1 - anchor-bankrun@0.4.0(@coral-xyz/anchor@0.32.1(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@solana/web3.js@1.95.2(bufferutil@4.0.8)(utf-8-validate@5.0.10))(solana-bankrun@0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)): - dependencies: - '@coral-xyz/anchor': 0.32.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/web3.js': 1.95.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) - solana-bankrun: 0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) - ansi-colors@4.1.1: {} ansi-regex@5.0.1: {} @@ -1418,36 +1365,6 @@ snapshots: dependencies: randombytes: 2.1.0 - solana-bankrun-darwin-arm64@0.3.0: - optional: true - - solana-bankrun-darwin-universal@0.3.0: - optional: true - - solana-bankrun-darwin-x64@0.3.0: - optional: true - - solana-bankrun-linux-x64-gnu@0.3.0: - optional: true - - solana-bankrun-linux-x64-musl@0.3.0: - optional: true - - solana-bankrun@0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): - dependencies: - '@solana/web3.js': 1.95.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) - bs58: 4.0.1 - optionalDependencies: - solana-bankrun-darwin-arm64: 0.3.0 - solana-bankrun-darwin-universal: 0.3.0 - solana-bankrun-darwin-x64: 0.3.0 - solana-bankrun-linux-x64-gnu: 0.3.0 - solana-bankrun-linux-x64-musl: 0.3.0 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 diff --git a/basics/account-data/anchor/tests/bankrun.test.ts b/basics/account-data/anchor/tests/bankrun.test.ts deleted file mode 100644 index 07d287a79..000000000 --- a/basics/account-data/anchor/tests/bankrun.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { describe, it } from "node:test"; -import * as anchor from "@coral-xyz/anchor"; -import { Keypair, PublicKey } from "@solana/web3.js"; -import { BankrunProvider } from "anchor-bankrun"; -import { startAnchor } from "solana-bankrun"; -import type { AccountDataAnchorProgram } from "../target/types/account_data_anchor_program"; - -import IDL from "../target/idl/account_data_anchor_program.json" with { - type: "json", -}; -const PROGRAM_ID = new PublicKey(IDL.address); - -describe("Account Data!", async () => { - const context = await startAnchor( - "", - [{ name: "account_data_anchor_program", programId: PROGRAM_ID }], - [], - ); - const provider = new BankrunProvider(context); - - const payer = provider.wallet as anchor.Wallet; - const program = new anchor.Program(IDL, provider); - - // Generate a new keypair for the addressInfo account - const addressInfoAccount = new Keypair(); - - it("Create the address info account", async () => { - console.log(`Payer Address : ${payer.publicKey}`); - console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`); - - // Instruction Ix data - const addressInfo = { - name: "Joe C", - houseNumber: 136, - street: "Mile High Dr.", - city: "Solana Beach", - }; - - await program.methods - .createAddressInfo( - addressInfo.name, - addressInfo.houseNumber, - addressInfo.street, - addressInfo.city, - ) - .accounts({ - addressInfo: addressInfoAccount.publicKey, - payer: payer.publicKey, - }) - .signers([addressInfoAccount]) - .rpc(); - }); - - it("Read the new account's data", async () => { - const addressInfo = await program.account.addressInfo.fetch( - addressInfoAccount.publicKey, - ); - console.log(`Name : ${addressInfo.name}`); - console.log(`House Num: ${addressInfo.houseNumber}`); - console.log(`Street : ${addressInfo.street}`); - console.log(`City : ${addressInfo.city}`); - }); -}); From 5d63dc4751e0833082a25346305b3782cfe0551a Mon Sep 17 00:00:00 2001 From: solwarrior <118261237+sol-warrior@users.noreply.github.com> Date: Tue, 2 Dec 2025 11:12:56 +0530 Subject: [PATCH 6/6] chore: update test script formatting in Anchor.toml --- basics/account-data/anchor/Anchor.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basics/account-data/anchor/Anchor.toml b/basics/account-data/anchor/Anchor.toml index 84b12bbec..0d651e522 100644 --- a/basics/account-data/anchor/Anchor.toml +++ b/basics/account-data/anchor/Anchor.toml @@ -13,5 +13,5 @@ cluster = "Localnet" wallet = "~/.config/solana/id.json" [scripts] -test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" #For all test +test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" litesvm-test = "pnpm ts-mocha -p ./tsconfig.json -t 1000000 tests/litesvm.test.ts" #For litesvm test