Testing

Complete testing framework and best practices for MemeTrade smart contracts, APIs, and integrations. Learn how to test locally, on testnets, and in production environments.

Testing Environment Setup

Local Development Environment

Prerequisites:

# Install Foundry (recommended)
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Or install Hardhat
npm install -g hardhat

# Install Node.js dependencies
npm install ethers dotenv @nomiclabs/hardhat-ethers

Environment Configuration:

# .env file
BASE_SEPOLIA_RPC_URL="https://sepolia.base.org"
BASE_MAINNET_RPC_URL="https://mainnet.base.org"
PRIVATE_KEY="your-test-private-key"
MEMETRADE_API_KEY="your-api-key"
ETHERSCAN_API_KEY="your-etherscan-key"

Foundry Testing Setup

foundry.toml Configuration:

Smart Contract Testing

Unit Testing with Foundry

Basic Test Structure:

Advanced Testing Patterns:

Fuzz Testing

Property-Based Testing:

Integration Testing

Cross-Contract Testing:

API Testing

REST API Testing

Jest Test Setup:

API Test Examples:

Load Testing:

WebSocket Testing

WebSocket Test Framework:

Frontend Testing

React Component Testing

Component Test Setup:

Component Tests:

E2E Testing with Playwright

Playwright Setup:

E2E Test Examples:

Performance Testing

Contract Gas Optimization

Gas Testing:

Load Testing Scripts

Artillery Load Testing:

Testnet Testing

Base Sepolia Testing

Faucet Integration:

Automated Testing Pipeline:

CI/CD Testing

GitHub Actions Workflow

Best Practices

Testing Strategies

Test Pyramid:

Code Coverage Goals:

  • Smart contracts: >95%

  • APIs: >90%

  • Frontend components: >80%

  • E2E critical paths: 100%

Security Testing

Common Vulnerabilities to Test:

Performance Benchmarks

Target Metrics:

  • API response time: <100ms (95th percentile)

  • WebSocket message latency: <50ms

  • Contract deployment: <500k gas

  • Token creation: <300k gas

  • Trade execution: <200k gas


Ready to test your integration? Start with the basic test setup and gradually add more comprehensive testing as your integration grows. Join our Discord #testing-support channel for help with specific testing scenarios.

Next Steps:

Last updated