bankrun.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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 type { RentProgram } from '../target/types/rent_program';
  7. const IDL = require('../target/idl/rent_program.json');
  8. const PROGRAM_ID = new PublicKey(IDL.address);
  9. describe('Bankrun example', async () => {
  10. const context = await startAnchor('', [{ name: 'rent_program', programId: PROGRAM_ID }], []);
  11. const provider = new BankrunProvider(context);
  12. const wallet = provider.wallet as anchor.Wallet;
  13. const program = new anchor.Program<RentProgram>(IDL, provider);
  14. const addressData = {
  15. id: 87615,
  16. zipCode: 94016,
  17. };
  18. it('Create the account', async () => {
  19. const newKeypair = anchor.web3.Keypair.generate();
  20. await program.methods
  21. .createSystemAccount(new anchor.BN(addressData.id), new anchor.BN(addressData.zipCode))
  22. .accounts({
  23. owner: wallet.publicKey,
  24. })
  25. .signers([wallet.payer])
  26. .rpc();
  27. });
  28. });