This guide explains how to test Pump Kit during development and integration into your application.
# Install dependencies
bun install
# Run all tests
bun test
# Run only unit tests (fast, no network)
bun test:unit
# Watch mode for development
bun test:watchUnit tests are fast, deterministic, and don't require network access.
bun test tests/unitThese tests cover:
- Slippage calculations
- PDA derivation logic
- Utility functions
- Type conversions
Integration tests verify instruction building works correctly but don't send transactions.
# Set your RPC endpoint first
export SOLANA_RPC=https://your-dev-or-mainnet-endpoint
# Run integration tests
bun test tests/integrationThese tests cover:
- Buy instruction building
- Sell instruction building
- Mint instruction building
- Liquidity instruction building
bun testFor development, use watch mode to automatically rerun tests on file changes:
bun test:watchGenerate test coverage reports:
bun test:coverageConfigure tests using the following environment variables:
# RPC endpoint to use during integration tests
export SOLANA_RPC=https://your-dev-or-mainnet-endpoint
# Commitment level (optional, defaults to "confirmed")
export SOLANA_COMMITMENT=confirmedCreate a .env file in the project root:
SOLANA_CLUSTER=devnet
SOLANA_COMMITMENT=confirmedTest that instructions build correctly without sending transactions:
import { buyWithSlippage } from "pump-kit";
import { generateKeyPair } from "@solana/kit";
const testWallet = await generateKeyPair();
// This builds the instruction but doesn't send it
const instruction = await buyWithSlippage({
user: testWallet,
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
tokenAmount: 1_000_000n,
estimatedSolCostSol: 0.5,
feeRecipient: "11111111111111111111111111111111",
});
// Verify the instruction is valid
console.log("Instruction built:", instruction);Use Solana's transaction simulation to test without spending SOL:
import { rpc } from "pump-kit";
import { createSolanaRpc } from "@solana/kit";
const devnetRpc = createSolanaRpc("https://api.devnet.solana.com");
// Build your transaction...
// Then simulate it
const simulation = await devnetRpc
.simulateTransaction(transaction, { commitment: "confirmed" })
.send();
console.log("Simulation result:", simulation);Before going to mainnet, always test on devnet:
# Get devnet SOL from the faucet
solana airdrop 2 YOUR_WALLET_ADDRESS --url devnet
# Set your environment to devnet
export SOLANA_CLUSTER=devnet
# Run your app or tests
bun run your-script.tsVerify slippage calculations work as expected:
import { addSlippage, subSlippage } from "pump-kit";
// Expand a SOL budget by 0.5% to cover price movement
const maxBudget = addSlippage(5_000_000n, 50); // 5.025M lamports
console.log("Max budget with slippage:", maxBudget);
// Tighten a SOL output floor by 0.5%
const minOut = subSlippage(1_000_000n, 50); // 995k lamports
console.log("Min output with slippage:", minOut);Never test on mainnet. Use devnet to verify your integration:
// Good ✅
export SOLANA_CLUSTER=devnet
// Bad ❌ - Don't test on mainnet!
export SOLANA_CLUSTER=mainnetTest boundary conditions and error cases:
import { validateSlippage } from "pump-kit";
// Test valid slippage
validateSlippage(50); // ✅
// Test edge cases
try {
validateSlippage(-1); // Should throw
} catch (error) {
console.log("Caught invalid slippage");
}
try {
validateSlippage(10001); // Over 100%, should throw
} catch (error) {
console.log("Caught excessive slippage");
}Don't hit RPC endpoints in unit tests:
// Good ✅ - Pure function test
import { addSlippage } from "pump-kit";
const result = addSlippage(1_000_000n, 50);
expect(result).toBe(1_005_000n);
// Bad ❌ - Don't call RPC in unit tests
// const account = await rpc.getAccountInfo(address).send();// Good ✅
test("buyWithSlippage builds valid instruction with default slippage", async () => {
// ...
});
// Bad ❌
test("buy works", async () => {
// ...
});Close connections and clean up after tests:
import { afterAll } from "bun:test";
afterAll(() => {
// Clean up resources, close connections, etc.
});Tests run automatically on every push and pull request. See .github/workflows/test.yml for configuration.
Run the same checks that CI runs:
# Type-check
bun run dev:typecheck
# Run all tests
bun test
# Build
bun run buildCoverage reports are generated automatically and uploaded to Codecov (if configured).
Set your environment variables:
export SOLANA_CLUSTER=devnetIncrease the timeout or use a faster RPC endpoint:
export SOLANA_RPC=https://your-fast-rpc.comCheck that all required accounts are derived correctly. Enable debug logging:
console.log("User:", user.address);
console.log("Mint:", mint);
console.log("Bonding Curve PDA:", bondingCurve);- Solana CLI - Command-line tools for Solana
- Solana Devnet Faucet - Get test SOL
- Bun Test Docs - Bun's test runner documentation
If you encounter issues while testing:
- Check the test README
- Review example tests in
tests/directory - Open an issue on GitHub with:
- Test output
- Environment details
- Minimal reproduction code