What is the primary tool used to test Solana programs locally? A. Remix B. Truffle C. Solana Test Validator ✅ D. Hardhat →Solana Test Validator provides a local blockchain for testing programs.
Which Solana tool is commonly used for writing tests in Rust? A. Jest B. Mocha C. Solana-Test-Suite D. Anchor ✅ → Anchor framework includes testing features using Rust.
What does BPF stand for in Solana? A. Blockchain Process Framework B. Berkeley Packet Filter ✅ C. Block Programming Function D. Bytecode Performance Framework → BPF is the VM model Solana uses for smart contracts.
Which command starts a local validator for testing Solana programs? A. solana run B. solana validator C. solana-test-validator ✅ D. anchor run → This spins up a local Solana cluster for testing.
Which folder contains test cases in an Anchor project? A. /build B. /programs C. /migrations D. /tests ✅ → The /tests folder contains JavaScript or TypeScript tests in Anchor.
Unit Testing and Integration Testing
Which testing framework is used by default with Anchor for JavaScript tests? A. Mocha ✅ B. Jest C. Jasmine D. Truffle → Anchor uses Mocha + Chai in JS/TS tests.
What is the purpose of assert in test cases? A. Log errors B. Submit transactions C. Compare expected vs actual values ✅ D. Test deployment →assert checks conditions like expected outputs.
What does anchor test do? A. Starts validator only B. Compiles only C. Runs full suite of tests ✅ D. Publishes program → Runs validator, deploys program, runs tests.
In testing, how can you simulate Solana token transfers? A. Using web3.js and test validator ✅ B. On mainnet only C. Using MetaMask D. It’s not possible → Solana Web3.js allows test token transfers on local validator.
Which of the following best describes an integration test? A. Test one function B. Test two variables C. Test interaction between smart contract and other components ✅ D. Print logs only → Integration tests test interactions between components.
Accounts, PDAs, and Clients
What is a PDA in Solana? A. Private Development API B. Program Derived Address ✅ C. Personal Digital Asset D. Public Data Access → PDA is an address generated by program logic.
How are PDAs used in testing? A. To access secret data B. To store contract state ✅ C. To avoid transactions D. To test memory → PDAs are used to store state specific to programs.
What is the default Solana cluster for tests? A. devnet B. testnet C. mainnet D. localnet ✅ →solana-test-validator runs on a localnet cluster.
In Solana, Keypair::new() is used to: A. Generate PDA B. Deploy program C. Create new wallet ✅ D. Sign logs → Used in tests to create test accounts.
Which method is used to airdrop SOL in local testing? A. anchor airdrop B. solana balance C. provider.connection.requestAirdrop() ✅ D. wallet.add() → This airdrops SOL to wallet addresses for local tests.
Test Execution and Debugging
How do you check logs of test transactions in Solana? A. Use solana logs B. Use console.log in JavaScript C. Use solana-test-validator output ✅ D. None → Validator output logs transaction messages.
What does #[cfg(test)] do in Rust? A. Compiles test binary ✅ B. Ignores code C. Comments code D. Adds log statements → Marks test modules to be compiled only during testing.
What Rust macro is used to write a test function? A. @test B. #test C. #[test] ✅ D. test! → Standard Rust test macro.
What should be tested in smart contracts? A. UI B. Logic, boundaries, state ✅ C. Browser compatibility D. External APIs → Tests must validate contract logic, state transitions.
What command resets the Anchor test environment? A. anchor reset B. anchor clean ✅ C. anchor restart D. anchor reload → Cleans and rebuilds project.
Advanced Testing
Which Solana SDK is commonly used for writing tests in TypeScript? A. solana-web3.js ✅ B. ethers.js C. web3.py D. solana-toolkit → Official JS SDK.
Which Anchor method returns a reference to the provider? A. getProgram() B. Program.new() C. anchor.getProvider() ✅ D. solana.provider() → Used to access the test environment.
How to test custom program errors in Anchor? A. Catch logs B. Try-catch block and assert error code ✅ C. Ignore errors D. Write to file → Anchor maps custom errors to codes; test with .code.
How do you generate test wallets? A. From mnemonic B. Keypair::generate() or Keypair::new() ✅ C. Use hardware wallet D. From faucet → Dynamically generated for test runs.
What does anchor deploy do during tests? A. Upload UI B. Create token C. Deploy smart contract ✅ D. Create Solana wallet → Deploys program on cluster.
Anchor, IDL, and Simulations
What file stores IDL in Anchor? A. index.ts B. program.json C. target/idl/your_program.json ✅ D. idl.rs → The program interface is generated in this file.
Which Anchor command is used for generating IDL types in TS? A. anchor idl gen B. anchor build C. anchor-client-gen D. anchor build && anchor-client-gen ✅ → Generates TypeScript types from IDL.
What kind of error would test insufficient funds? A. AnchorError::Custom(1) B. ProgramError::InsufficientFunds ✅ C. ClientError D. None → BPF programs throw this on SOL/token shortages.
How to simulate program instructions? A. Using logs B. simulateTransaction() in web3 ✅ C. Not possible D. From browser → Simulates transaction logic without committing.
What should be tested before deploying on devnet or mainnet? A. Gas fees B. UI responsiveness C. Local validator tests ✅ D. DNS → Local testing is vital to catch bugs early.
Transactions, Signers, and Simulation
What is required to sign a Solana transaction? A. PDA B. Wallet or Keypair ✅ C. IDL D. Airdrop → Every transaction must be signed by one or more valid Keypairs.
Which function simulates a transaction without actually sending it? A. sendTransaction() B. simulateTransaction() ✅ C. broadcastTransaction() D. processInstruction() → Used to test logic without changing state.
Which of the following errors indicates a signer was missing in the transaction? A. ProgramError::MissingRequiredSignature ✅ B. AccountNotFound C. InstructionTooLarge D. IncorrectProgramId → Happens when a required account didn’t sign.
In Solana testing, what is the purpose of using airdrop? A. Deploy program B. Fund accounts with SOL ✅ C. Upgrade program D. Generate tokens → Essential to provide SOL for transactions on localnet.
What does ProgramTest allow in Solana Rust tests? A. UI testing B. Deploys program to devnet C. Runs in-process program tests ✅ D. Wallet recovery →ProgramTest helps in simulating a Solana cluster in Rust unit tests.
Testing Edge Cases and Errors
Which method helps validate program errors in JavaScript tests? A. try...catch and match error code ✅ B. error.message only C. No way D. console.error() → Anchor error codes are matched using try...catch.
Which testing approach is best to test extreme values or limits? A. Unit testing B. Edge case testing ✅ C. Visual testing D. Performance testing → Important for overflows, limits, missing accounts, etc.
What is the purpose of the assert.rejects() in JavaScript/TypeScript tests? A. Expect function to run B. Expect function to throw ✅ C. Test for UI D. Skip test → Ensures the program fails as expected.
In Rust, how would you assert a test fails with a specific error? A. assert_eq!(result, Ok(...)) B. assert!(result.is_err()) ✅ C. panic!(...) D. Use print! → Use .is_err() or match the Err(...) variant.
What happens if a required account is missing from the instruction during a test? A. Transaction continues B. Instruction gets skipped C. Program panics with error ✅ D. Account is auto-generated → Every account must be provided explicitly.
Anchor Testing Features
Which file in Anchor defines tests in TypeScript? A. Cargo.toml B. lib.rs C. index.js D. tests/*.ts ✅ → Anchor places tests in tests/.
How do you pass custom arguments in an Anchor test? A. In Cargo.lock B. In #[derive] C. In test instruction .rpc(...) ✅ D. env.args() → Anchor .rpc() calls accept parameters matching your instruction.
Which Anchor module helps fetch program state? A. program.account.fetch() ✅ B. provider.request() C. client.fetcher() D. anchor.get() → This retrieves the current state of an account.
How do you get the transaction signature in Anchor? A. .rpc() returns it ✅ B. .txid() C. .getSig() D. .simulate() →.rpc() returns the transaction signature for logging or inspection.
What is the benefit of using Anchor’s workspace in tests? A. Runs UI B. Manages logs C. Access program ID and methods easily ✅ D. Adds documentation → Anchor’s workspace object simplifies test interactions.
Mocking, Environment, and CI/CD
Can you mock Solana programs in local testing? A. No B. Only on testnet C. Yes, using ProgramTest in Rust ✅ D. Only via UI →ProgramTest can register mock programs.
Which config sets cluster URL in Anchor tests? A. Cargo.toml B. package.json C. Anchor.toml ✅ D. .env.local →Anchor.toml defines default cluster and wallet.
How do you change the payer wallet used for Anchor tests? A. Edit wallet.json B. Set ANCHOR_WALLET env variable ✅ C. Change lib.rs D. Modify provider → You can set the ANCHOR_WALLET to point to a specific keypair.
How do you test time-based logic in local Solana programs? A. Wait manually B. Use devnet C. Mock Clock sysvar ✅ D. Call delay() → Simulated Clock sysvar allows testing time-dependent contracts.
Which method helps test SysvarRent usage in programs? A. create_sysvar() B. Rent::default() ✅ C. sysvar::fake() D. mock_rent() → You can use Rent::default() for dummy rent values.
CLI and Deployment Testing
Which CLI command builds your Solana smart contract? A. solana build B. anchor compile C. anchor build ✅ D. solana deploy → Anchor build compiles your program using Cargo.
What file contains Anchor’s test config and metadata? A. test_config.toml B. Anchor.toml ✅ C. test.json D. .solana.yml → All metadata and cluster settings are in Anchor.toml.
How do you deploy a smart contract to local validator? A. anchor deploy ✅ B. anchor simulate C. solana run D. ts-node deploy.js → Anchor’s deploy command handles build, deploy, and IDL updates.
What command starts a validator and runs all tests in one go? A. anchor test ✅ B. anchor validate C. anchor run D. solana up →anchor test spins up local validator and runs integration tests.
Which folder in Anchor project contains compiled programs? A. /src B. /programs C. /target/deploy ✅ D. /dist → Compiled .so and .json files are output to this folder.
Miscellaneous and Best Practices
Which Solana error is thrown for invalid program ID? A. IncorrectProgramId ✅ B. SignatureMismatch C. DataCorruptionError D. PanicError → Happens if the transaction targets the wrong program address.
Which test best ensures the program handles real-world input? A. Unit test B. Property-based test C. Fuzz test ✅ D. Snapshot test → Fuzzing sends randomized inputs to test program resilience.
How do you confirm all test instructions succeeded? A. By printing logs B. By inspecting return values and logs ✅ C. Using cargo run D. Cannot be confirmed → Check return values and logs from each transaction.
What is the purpose of the Anchor IDL? A. Documentation B. Client-server link ✅ C. UI framework D. Validator monitor → The IDL defines program interface and enables client access.
Which Anchor library wraps Solana Web3.js for easier usage? A. @solana/web3.js B. @project-serum/anchor ✅ C. @anchor/web3 D. @solana/helper → Anchor provides high-level abstractions for Solana programs.