This is a program that validates your progress on the "Solana Lending Program Development" challenge using the Mollusk test harness.
The tester has been enhanced with the Mollusk framework, a lightweight test harness for Solana programs. This provides:
- Fast Execution: Direct SVM instruction execution without full validator runtime
- Precise Control: Explicit account management and instruction validation
- Better Testing: Comprehensive checks for account state, lamports, data, and more
The tester is organized into the following modules:
src/main.rs- Entry point that initializes the testersrc/definition.rs- Test case definitionssrc/stages/- Test implementations organized by stagesrc/mollusk/- Mollusk integration modulemod.rs- Main Mollusk managementprogram_loader.rs- Program loading utilitiestest_context.rs- Test context for state management
src/helpers.rs- Helper functions for testing
- Following environment variables:
STACKCLASS_REPOSITORY_DIR- root of the user's code submissionSTACKCLASS_TEST_CASES_JSON- test cases in JSON format
- A binary named
your_program.shthat executes the program. - A file named
stackclass.yml, with the following values:debug.
cargo build --releaseThe tester will automatically load and test the user's lending program using Mollusk. Ensure the program is built before running tests:
cd <user-repo>
anchor build- be1 - Environment Setup
- rs2 - Rust Basics
- sm3 - Solana Model
- at4 - Anchor Try
- st5 - SPL Token Basics
- cp6 - Basic Deposit
- tt7 - Basic Withdraw
- pa1 - PDA Concept
- pa2 - PDA Derivation
- pa3 - Bump Seeds
- pa4 - PDA Practice
- tr1 - Treasury Intro
- tr2 - Treasury Creation
- tr3 - Treasury Security
- tr4 - Treasury Practice
- as1 - Bank Account
- as2 - User Account
- as3 - Account Space
- as4 - Account Practice
- lc1 - Borrow Basics
- lc2 - Repay Basics
- lc3 - LTV Calculation
- lc4 - Core Practice
- or1 - Oracle Concept
- or2 - Pyth Integration
- or3 - Price Fetching
- or4 - Oracle Practice
- li1 - Health Factor
- li2 - Liquidation Trigger
- li3 - Liquidation Process
- li4 - Liquidation Bonus
- li5 - Liquidation Practice
- in1 - Interest Basics
- in2 - Accrued Interest
- in3 - Rate Models
- in4 - Interest Practice
- se1 - Common Vulnerabilities
- se2 - Reentrancy Protection
- se3 - Account Validation
- se4 - Security Practice
The tester uses Mollusk for efficient program testing:
use crate::mollusk::{create_lending_mollusk, LendingTestContext};
// Create Mollusk instance
let mollusk = create_lending_mollusk(&repo_dir)?;
let mut context = LendingTestContext::new(mollusk)?;
// Create accounts and execute instructions
let user = context.create_funded_account(1_000_000_000);
let instruction = create_lending_instruction(data, accounts);
context.execute_instruction(&instruction)?;See LICENSE file for details.