Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor bankrun #113

Merged
merged 14 commits into from
Aug 27, 2024
Merged

Anchor bankrun #113

merged 14 commits into from
Aug 27, 2024

Conversation

heyAyushh
Copy link
Contributor

Added seperate tests for anchor bankrun
Summary of changes

anchor-bankrun migration.

pnpm i
pnpm i -D solana-bankrun anchor-bankrun 
pnpm i @coral-xyz/anchor @solana/web3.js

++
import * as anchor from '@coral-xyz/anchor';
import type { CloseAccountProgram } from '../target/types/close_account_program';
import { PublicKey } from '@solana/web3.js';
import assert from 'node:assert';

import { startAnchor } from "solana-bankrun";
import { BankrunProvider } from "anchor-bankrun";
import { it, describe } from "node:test"

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

--
describe('Account Data!', () => {
 const provider = anchor.AnchorProvider.env();
  anchor.setProvider(provider);

++ if using ts-mocha
describe('Bankrun example', async () => {
  const context = await startAnchor("", [{name: "anchor_program_example", programId: PROGRAM_ID}], []);
  const provider = new BankrunProvider(context);

  const payer = provider.wallet as anchor.Wallet;
  const program = new anchor.Program<AnchorProgramExample>(
    IDL,
    provider,
  );

++ if using jest
describe('Bankrun example', () => {
    let context: anchor.ProgramContext<AnchorProgramExample>;
    let provider: BankrunProvider;
    let payer: anchor.Wallet;
    let program: anchor.Program<AnchorProgramExample>;
    
    beforeAll(async () => {
        context = await startAnchor("", [{name: "anchor_program_example", programId: PROGRAM_ID}], []);
        provider = new BankrunProvider(context);
        payer = provider.wallet as anchor.Wallet;
        program = new anchor.Program<AnchorProgramExample>(
            IDL,
            provider,
        );
    });

@heyAyushh heyAyushh marked this pull request as draft August 9, 2024 14:59
@heyAyushh heyAyushh marked this pull request as ready for review August 27, 2024 13:29
@jacobcreech jacobcreech merged commit 9750528 into solana-developers:main Aug 27, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants