1- import assert from " node:assert" ;
2- import { describe , it } from " node:test" ;
3- import * as anchor from " @coral-xyz/anchor" ;
4- import { PublicKey } from " @solana/web3.js" ;
5- import { BankrunProvider } from " anchor-bankrun" ;
6- import { startAnchor } from " solana-bankrun" ;
7- import type { CloseAccountProgram } from " ../target/types/close_account_program" ;
1+ import assert from ' node:assert' ;
2+ import { describe , it } from ' node:test' ;
3+ import * as anchor from ' @coral-xyz/anchor' ;
4+ import { PublicKey } from ' @solana/web3.js' ;
5+ import { BankrunProvider } from ' anchor-bankrun' ;
6+ import { startAnchor } from ' solana-bankrun' ;
7+ import type { CloseAccountProgram } from ' ../target/types/close_account_program' ;
88
9- const IDL = require ( " ../target/idl/close_account_program.json" ) ;
9+ const IDL = require ( ' ../target/idl/close_account_program.json' ) ;
1010const PROGRAM_ID = new PublicKey ( IDL . address ) ;
1111
12- describe ( " close-account" , async ( ) => {
12+ describe ( ' close-account' , async ( ) => {
1313 // Configure the client to use the local cluster.
14- const context = await startAnchor (
15- "" ,
16- [ { name : "close_account_program" , programId : PROGRAM_ID } ] ,
17- [ ]
18- ) ;
14+ const context = await startAnchor ( '' , [ { name : 'close_account_program' , programId : PROGRAM_ID } ] , [ ] ) ;
1915 const provider = new BankrunProvider ( context ) ;
2016
2117 const payer = provider . wallet as anchor . Wallet ;
2218 const program = new anchor . Program < CloseAccountProgram > ( IDL , provider ) ;
2319 // Derive the PDA for the user's account.
24- const [ userAccountAddress ] = PublicKey . findProgramAddressSync (
25- [ Buffer . from ( "user" ) , payer . publicKey . toBuffer ( ) ] ,
26- program . programId
27- ) ;
20+ const [ userAccountAddress ] = PublicKey . findProgramAddressSync ( [ Buffer . from ( 'user' ) , payer . publicKey . toBuffer ( ) ] , program . programId ) ;
2821
29- it ( " Create Account" , async ( ) => {
22+ it ( ' Create Account' , async ( ) => {
3023 await program . methods
3124 . createUser ( )
3225 . accounts ( {
@@ -35,13 +28,11 @@ describe("close-account", async () => {
3528 . rpc ( ) ;
3629
3730 // Fetch the account data
38- const userAccount = await program . account . closeAccountState . fetch (
39- userAccountAddress
40- ) ;
31+ const userAccount = await program . account . closeAccountState . fetch ( userAccountAddress ) ;
4132 assert . equal ( userAccount . user . toBase58 ( ) , payer . publicKey . toBase58 ( ) ) ;
4233 } ) ;
4334
44- it ( " Close Account" , async ( ) => {
35+ it ( ' Close Account' , async ( ) => {
4536 await program . methods
4637 . closeUser ( )
4738 . accounts ( {
@@ -51,9 +42,7 @@ describe("close-account", async () => {
5142
5243 // The account should no longer exist, returning null.
5344 try {
54- const userAccount = await program . account . closeAccountState . fetchNullable (
55- userAccountAddress
56- ) ;
45+ const userAccount = await program . account . closeAccountState . fetchNullable ( userAccountAddress ) ;
5746 assert . equal ( userAccount , null ) ;
5847 } catch ( err ) {
5948 // Won't return null and will throw an error in anchor-bankrun'
0 commit comments