seahorse.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import * as anchor from '@coral-xyz/anchor';
  2. import type { Program } from '@coral-xyz/anchor';
  3. import type { Seahorse } from '../target/types/seahorse';
  4. describe('seahorse', () => {
  5. // Configure the client to use the local cluster.
  6. anchor.setProvider(anchor.AnchorProvider.env());
  7. const program = anchor.workspace.Seahorse as Program<Seahorse>;
  8. const mockReceiverAccount = anchor.web3.PublicKey.findProgramAddressSync([Buffer.from('mock_account')], program.programId);
  9. it('Initialize the Mock account to send our SOL to', async () => {
  10. const tx = await program.methods
  11. .initMockAccount()
  12. .accounts({
  13. mockAccount: mockReceiverAccount[0],
  14. signer: program.provider.publicKey,
  15. })
  16. .rpc();
  17. });
  18. it('Send SOL To Mock account', async () => {
  19. const transferAmount = 1;
  20. // Convert to lamport.
  21. const lamports: number = anchor.web3.LAMPORTS_PER_SOL * transferAmount;
  22. const tx = await program.methods
  23. .transferSolWithCpi(new anchor.BN(lamports))
  24. .accounts({
  25. recipient: mockReceiverAccount[0],
  26. sender: program.provider.publicKey,
  27. })
  28. .rpc();
  29. console.log('Your transaction signature: ', tx);
  30. });
  31. });