bankrun.test.ts 929 B

123456789101112131415161718192021222324
  1. import { describe, it } from 'node:test';
  2. import * as anchor 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 { HelloSolana } from '../target/types/hello_solana';
  7. const IDL = require('../target/idl/hello_solana.json');
  8. const PROGRAM_ID = new PublicKey(IDL.address);
  9. describe('hello-solana', async () => {
  10. // Configure the Anchor provider & load the program IDL for anchor-bankrun
  11. // The IDL gives you a typescript module
  12. const context = await startAnchor('', [{ name: 'hello_solana', programId: PROGRAM_ID }], []);
  13. const provider = new BankrunProvider(context);
  14. const program = new anchor.Program<HelloSolana>(IDL, provider);
  15. it('Say hello!', async () => {
  16. // Just run Anchor's IDL method to build a transaction!
  17. //
  18. await program.methods.hello().accounts({}).rpc();
  19. });
  20. });