Skip to content

Commit

Permalink
feat:ran pnpm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adpthegreat committed Oct 26, 2024
1 parent d1d0a42 commit 48709b3
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 229 deletions.
4 changes: 2 additions & 2 deletions tokens/token-swap/poseidon/token_swap/migrations/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@coral-xyz/anchor");
const anchor = require('@coral-xyz/anchor');

module.exports = async function (provider) {
module.exports = async (provider) => {
// Configure client to use the provider.
anchor.setProvider(provider);

Expand Down
51 changes: 21 additions & 30 deletions tokens/token-swap/poseidon/token_swap/tests/create-amm.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import * as anchor from "@coral-xyz/anchor";
import type { Program } from "@coral-xyz/anchor";
import { expect } from "chai";
import type { TokenSwap } from "../target/types/token_swap";
import { type TestValues, createValues, expectRevert } from "./utils";
import { PublicKey } from "@solana/web3.js";
import { startAnchor } from "solana-bankrun";
import { BankrunProvider } from "anchor-bankrun";

const IDL = require("../target/idl/token_swap.json");
import * as anchor from '@coral-xyz/anchor';
import type { Program } from '@coral-xyz/anchor';
import { PublicKey } from '@solana/web3.js';
import { BankrunProvider } from 'anchor-bankrun';
import { expect } from 'chai';
import { startAnchor } from 'solana-bankrun';
import type { TokenSwap } from '../target/types/token_swap';
import { type TestValues, createValues, expectRevert } from './utils';

const IDL = require('../target/idl/token_swap.json');
const PROGRAM_ID = new PublicKey(IDL.address);

describe("Create AMM", async () => {
describe('Create AMM', async () => {
// Configure the client to use the anchor-bankrun
const context = await startAnchor(
"",
[{ name: "token_swap", programId: PROGRAM_ID }],
[]
);
const context = await startAnchor('', [{ name: 'token_swap', programId: PROGRAM_ID }], []);

const provider = new BankrunProvider(context);

Expand All @@ -32,38 +28,33 @@ describe("Create AMM", async () => {
values = createValues();
});

it("Creation", async () => {
it('Creation', async () => {
const id = new anchor.BN(values.id);
const fee = values.fee;
await program.methods
.createAmm(id, fee)
.accounts({
payer:payer.publicKey,
.accounts({
payer: payer.publicKey,
})
.rpc();

const ammAccount = await program.account.amm.fetch(values.ammKey);
expect(ammAccount.id.toString()).to.equal(values.id.toString());
expect(ammAccount.admin.toString()).to.equal(
values.admin.publicKey.toString()
);
expect(ammAccount.admin.toString()).to.equal(values.admin.publicKey.toString());
expect(ammAccount.fee.toString()).to.equal(values.fee.toString());
});

it("Invalid fee", async () => {
it('Invalid fee', async () => {
const id = new anchor.BN(values.id);
values.fee = 10000;

await expectRevert(
program.methods
.createAmm(
id,
values.fee
)
.accounts({
payer:payer.publicKey
.createAmm(id, values.fee)
.accounts({
payer: payer.publicKey,
})
.rpc()
.rpc(),
);
});
});
68 changes: 25 additions & 43 deletions tokens/token-swap/poseidon/token_swap/tests/create-pool.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
import * as anchor from "@coral-xyz/anchor";
import type { Program } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import type { TokenSwap } from "../target/types/token_swap";
import {
type TestValues,
createValues,
expectRevert,
mintingTokens,
} from "./utils";
import { startAnchor } from "solana-bankrun";
import { BankrunProvider } from "anchor-bankrun";
import * as anchor from '@coral-xyz/anchor';
import type { Program } from '@coral-xyz/anchor';
import { PublicKey } from '@solana/web3.js';
import { BankrunProvider } from 'anchor-bankrun';
import { startAnchor } from 'solana-bankrun';
import type { TokenSwap } from '../target/types/token_swap';
import { type TestValues, createValues, expectRevert, mintingTokens } from './utils';

const IDL = require("../target/idl/token_swap.json");
const IDL = require('../target/idl/token_swap.json');
const PROGRAM_ID = new PublicKey(IDL.address);

describe("Create pool", async () => {
const context = await startAnchor(
"",
[{ name: "token_swap", programId: PROGRAM_ID }],
[]
);
describe('Create pool', async () => {
const context = await startAnchor('', [{ name: 'token_swap', programId: PROGRAM_ID }], []);

const provider = new BankrunProvider(context);
const provider = new BankrunProvider(context);

const connection = provider.connection;
const connection = provider.connection;

const payer = provider.wallet as anchor.Wallet;
const payer = provider.wallet as anchor.Wallet;

const program = new anchor.Program<TokenSwap>(IDL, provider);
const program = new anchor.Program<TokenSwap>(IDL, provider);

let values: TestValues;

beforeEach(async () => {
values = createValues();
const id = new anchor.BN(values.id)
const fee = values.fee
const id = new anchor.BN(values.id);
const fee = values.fee;
await program.methods
.createAmm(id, fee)
.accounts({
// admin: values.admin.publicKey
// admin: values.admin.publicKey
})
.rpc();

Expand All @@ -50,7 +41,7 @@ const connection = provider.connection;
});
});

it("Creation", async () => {
it('Creation', async () => {
const id = new anchor.BN(values.id);
await program.methods
.createPool(id)
Expand All @@ -67,28 +58,19 @@ const connection = provider.connection;
.rpc({ skipPreflight: true });
});

it("Invalid mints", async () => {
it('Invalid mints', async () => {
values = createValues({
mintBKeypair: values.mintAKeypair,
poolKey: PublicKey.findProgramAddressSync(
[
Buffer.alloc(values.id),
values.mintAKeypair.publicKey.toBuffer(),
values.mintBKeypair.publicKey.toBuffer(),
],
program.programId
[Buffer.alloc(values.id), values.mintAKeypair.publicKey.toBuffer(), values.mintBKeypair.publicKey.toBuffer()],
program.programId,
)[0],
poolAuthority: PublicKey.findProgramAddressSync(
[
Buffer.alloc(values.id),
values.mintAKeypair.publicKey.toBuffer(),
values.mintBKeypair.publicKey.toBuffer(),
Buffer.from("authority"),
],
program.programId
[Buffer.alloc(values.id), values.mintAKeypair.publicKey.toBuffer(), values.mintBKeypair.publicKey.toBuffer(), Buffer.from('authority')],
program.programId,
)[0],
});
const id = new anchor.BN(values.id);
const id = new anchor.BN(values.id);
await expectRevert(
program.methods
.createPool(id)
Expand All @@ -102,7 +84,7 @@ const connection = provider.connection;
// poolAccountA: values.poolAccountA,
// poolAccountB: values.poolAccountB,
})
.rpc()
.rpc(),
);
});
});
Loading

0 comments on commit 48709b3

Please sign in to comment.