litesvm.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import assert from 'node:assert';
  2. import * as anchor from '@coral-xyz/anchor';
  3. import { Program } from '@coral-xyz/anchor';
  4. import { Keypair, PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';
  5. import { LiteSVMProvider, fromWorkspace } from 'anchor-litesvm';
  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('anchor', () => {
  10. let client: any;
  11. let provider: LiteSVMProvider;
  12. let program: Program<HelloSolana>;
  13. let payer: Keypair;
  14. before(async () => {
  15. // Configure the Anchor provider & load the program IDL for anchor-bankrun
  16. // The IDL gives you a typescript module
  17. client = fromWorkspace('');
  18. provider = new LiteSVMProvider(client);
  19. payer = provider.wallet.payer;
  20. program = new anchor.Program<HelloSolana>(IDL, provider);
  21. });
  22. it('Say hello!', async () => {
  23. const signature = await program.methods.hello().accounts({}).rpc();
  24. assert(signature);
  25. console.log(`Signature: ${signature}`);
  26. });
  27. });