1- import * as anchor from " @coral-xyz/anchor" ;
2- import { Keypair , PublicKey } from " @solana/web3.js" ;
3- import { BankrunProvider } from " anchor-bankrun" ;
4- import { assert } from " chai" ;
5- import { startAnchor } from " solana-bankrun" ;
6- import type { CounterProgramPoseidon } from " ../target/types/counter_program_poseidon" ;
7-
8- const IDL = require ( " ../target/idl/counter_program.json" ) ;
1+ import * as anchor from ' @coral-xyz/anchor' ;
2+ import { Keypair , PublicKey } from ' @solana/web3.js' ;
3+ import { BankrunProvider } from ' anchor-bankrun' ;
4+ import { assert } from ' chai' ;
5+ import { startAnchor } from ' solana-bankrun' ;
6+ import type { CounterProgramPoseidon } from ' ../target/types/counter_program_poseidon' ;
7+
8+ const IDL = require ( ' ../target/idl/counter_program.json' ) ;
99const PROGRAM_ID = new PublicKey ( IDL . address ) ;
1010
11- describe ( " counter_program" , async ( ) => {
11+ describe ( ' counter_program' , async ( ) => {
1212 // Configure the client to use the anchor-bankrun
13- const context = await startAnchor (
14- "" ,
15- [ { name : "counter_program" , programId : PROGRAM_ID } ] ,
16- [ ]
17- ) ;
13+ const context = await startAnchor ( '' , [ { name : 'counter_program' , programId : PROGRAM_ID } ] , [ ] ) ;
1814
1915 const provider = new BankrunProvider ( context ) ;
2016
@@ -25,7 +21,7 @@ describe("counter_program", async () => {
2521 // Generate a new keypair for the counter account
2622 const counterKeypair = new Keypair ( ) ;
2723
28- it ( " Initialize Counter" , async ( ) => {
24+ it ( ' Initialize Counter' , async ( ) => {
2925 await program . methods
3026 . initializeCounter ( )
3127 . accounts ( {
@@ -35,44 +31,24 @@ describe("counter_program", async () => {
3531 } )
3632 . rpc ( ) ;
3733
38- const currentCount = await program . account . counterState . fetch (
39- counterKeypair . publicKey
40- ) ;
34+ const currentCount = await program . account . counterState . fetch ( counterKeypair . publicKey ) ;
4135
42- assert (
43- currentCount . count . toNumber ( ) === 0 ,
44- "Expected initialized count to be 0"
45- ) ;
36+ assert ( currentCount . count . toNumber ( ) === 0 , 'Expected initialized count to be 0' ) ;
4637 } ) ;
4738
48- it ( "Increment Counter" , async ( ) => {
49- await program . methods
50- . incrementCounter ( )
51- . accounts ( { counter : counterKeypair . publicKey } )
52- . rpc ( ) ;
39+ it ( 'Increment Counter' , async ( ) => {
40+ await program . methods . incrementCounter ( ) . accounts ( { counter : counterKeypair . publicKey } ) . rpc ( ) ;
5341
54- const currentCount = await program . account . counterState . fetch (
55- counterKeypair . publicKey
56- ) ;
42+ const currentCount = await program . account . counterState . fetch ( counterKeypair . publicKey ) ;
5743
58- assert ( currentCount . count . toNumber ( ) === 1 , " Expected count to be 1" ) ;
44+ assert ( currentCount . count . toNumber ( ) === 1 , ' Expected count to be 1' ) ;
5945 } ) ;
6046
61- it ( "Decrement Counter" , async ( ) => {
62- await program . methods
63- . decrementCounter ( )
64- . accounts ( { counter : counterKeypair . publicKey } )
65- . rpc ( ) ;
47+ it ( 'Decrement Counter' , async ( ) => {
48+ await program . methods . decrementCounter ( ) . accounts ( { counter : counterKeypair . publicKey } ) . rpc ( ) ;
6649
67- const currentCount = await program . account . counterState . fetch (
68- counterKeypair . publicKey
69- ) ;
50+ const currentCount = await program . account . counterState . fetch ( counterKeypair . publicKey ) ;
7051
71- assert (
72- currentCount . count . toNumber ( ) === 0 ,
73- "Expected count to be 0 after decrement"
74- ) ;
52+ assert ( currentCount . count . toNumber ( ) === 0 , 'Expected count to be 0 after decrement' ) ;
7553 } ) ;
76-
77-
78- } ) ;
54+ } ) ;
0 commit comments