1- import * as anchor from "@coral-xyz/anchor" ;
2- import type { Program } from "@coral-xyz/anchor" ;
3- import { PublicKey } from "@solana/web3.js" ;
4- import type { TokenSwap } from "../target/types/token_swap" ;
5- import {
6- type TestValues ,
7- createValues ,
8- expectRevert ,
9- mintingTokens ,
10- } from "./utils" ;
11- import { startAnchor } from "solana-bankrun" ;
12- import { BankrunProvider } from "anchor-bankrun" ;
1+ import * as anchor from '@coral-xyz/anchor' ;
2+ import type { Program } from '@coral-xyz/anchor' ;
3+ import { PublicKey } from '@solana/web3.js' ;
4+ import { BankrunProvider } from 'anchor-bankrun' ;
5+ import { startAnchor } from 'solana-bankrun' ;
6+ import type { TokenSwap } from '../target/types/token_swap' ;
7+ import { type TestValues , createValues , expectRevert , mintingTokens } from './utils' ;
138
14- const IDL = require ( " ../target/idl/token_swap.json" ) ;
9+ const IDL = require ( ' ../target/idl/token_swap.json' ) ;
1510const PROGRAM_ID = new PublicKey ( IDL . address ) ;
1611
17- describe ( "Create pool" , async ( ) => {
18- const context = await startAnchor (
19- "" ,
20- [ { name : "token_swap" , programId : PROGRAM_ID } ] ,
21- [ ]
22- ) ;
12+ describe ( 'Create pool' , async ( ) => {
13+ const context = await startAnchor ( '' , [ { name : 'token_swap' , programId : PROGRAM_ID } ] , [ ] ) ;
2314
24- const provider = new BankrunProvider ( context ) ;
15+ const provider = new BankrunProvider ( context ) ;
2516
26- const connection = provider . connection ;
17+ const connection = provider . connection ;
2718
28- const payer = provider . wallet as anchor . Wallet ;
19+ const payer = provider . wallet as anchor . Wallet ;
2920
30- const program = new anchor . Program < TokenSwap > ( IDL , provider ) ;
21+ const program = new anchor . Program < TokenSwap > ( IDL , provider ) ;
3122
3223 let values : TestValues ;
3324
3425 beforeEach ( async ( ) => {
3526 values = createValues ( ) ;
36- const id = new anchor . BN ( values . id )
37- const fee = values . fee
27+ const id = new anchor . BN ( values . id ) ;
28+ const fee = values . fee ;
3829 await program . methods
3930 . createAmm ( id , fee )
4031 . accounts ( {
41- // admin: values.admin.publicKey
32+ // admin: values.admin.publicKey
4233 } )
4334 . rpc ( ) ;
4435
@@ -50,7 +41,7 @@ const connection = provider.connection;
5041 } ) ;
5142 } ) ;
5243
53- it ( " Creation" , async ( ) => {
44+ it ( ' Creation' , async ( ) => {
5445 const id = new anchor . BN ( values . id ) ;
5546 await program . methods
5647 . createPool ( id )
@@ -67,28 +58,19 @@ const connection = provider.connection;
6758 . rpc ( { skipPreflight : true } ) ;
6859 } ) ;
6960
70- it ( " Invalid mints" , async ( ) => {
61+ it ( ' Invalid mints' , async ( ) => {
7162 values = createValues ( {
7263 mintBKeypair : values . mintAKeypair ,
7364 poolKey : PublicKey . findProgramAddressSync (
74- [
75- Buffer . alloc ( values . id ) ,
76- values . mintAKeypair . publicKey . toBuffer ( ) ,
77- values . mintBKeypair . publicKey . toBuffer ( ) ,
78- ] ,
79- program . programId
65+ [ Buffer . alloc ( values . id ) , values . mintAKeypair . publicKey . toBuffer ( ) , values . mintBKeypair . publicKey . toBuffer ( ) ] ,
66+ program . programId ,
8067 ) [ 0 ] ,
8168 poolAuthority : PublicKey . findProgramAddressSync (
82- [
83- Buffer . alloc ( values . id ) ,
84- values . mintAKeypair . publicKey . toBuffer ( ) ,
85- values . mintBKeypair . publicKey . toBuffer ( ) ,
86- Buffer . from ( "authority" ) ,
87- ] ,
88- program . programId
69+ [ Buffer . alloc ( values . id ) , values . mintAKeypair . publicKey . toBuffer ( ) , values . mintBKeypair . publicKey . toBuffer ( ) , Buffer . from ( 'authority' ) ] ,
70+ program . programId ,
8971 ) [ 0 ] ,
9072 } ) ;
91- const id = new anchor . BN ( values . id ) ;
73+ const id = new anchor . BN ( values . id ) ;
9274 await expectRevert (
9375 program . methods
9476 . createPool ( id )
@@ -102,7 +84,7 @@ const connection = provider.connection;
10284 // poolAccountA: values.poolAccountA,
10385 // poolAccountB: values.poolAccountB,
10486 } )
105- . rpc ( )
87+ . rpc ( ) ,
10688 ) ;
10789 } ) ;
10890} ) ;
0 commit comments