A specialized HTTP API mock server designed for blockchain developers to mock Web3 RPC endpoints and smart contract interactions. This implementation focuses on simulating blockchain behaviors including transaction mining, event emissions, and gas estimations, enabling comprehensive testing of decentralized application (dApp) frontends.
A blockchain developer testing dApp frontends who needs to mock blockchain RPC endpoints and smart contract interactions. He requires specialized mocking for Web3 protocols and transaction simulations.
-
Ethereum JSON-RPC method simulation with block progression
- Essential for testing dApp interactions with blockchain nodes
- Enables realistic blockchain state progression and queries
-
Transaction mining simulation with configurable confirmation times
- Critical for testing transaction lifecycle and user experience
- Allows validation of pending state handling and confirmations
-
Smart contract event emission with log filtering
- Vital for testing event-driven dApp functionality
- Enables verification of event listeners and state updates
-
Gas estimation mocking with dynamic pricing
- Required for testing transaction cost calculations
- Ensures proper handling of gas price fluctuations
-
Multiple chain simulation for cross-chain testing
- Essential for testing multi-chain dApps
- Allows validation of chain switching and compatibility
- All blockchain behaviors must be deterministic and controllable
- RPC responses must match Ethereum JSON-RPC specification
- Event emissions must be queryable and verifiable
- Gas calculations must be predictable
- RPC method responses within 50ms
- Support for 100+ concurrent Web3 connections
- Block generation at configurable intervals
- Event filtering with minimal latency
- Ethereum JSON-RPC 2.0 compliant endpoints
- WebSocket support for event subscriptions
- REST API for test configuration
- Block explorer-like query APIs
- Implementation must be pure Python with no UI components
- All functionality must be testable via pytest
- Must be compatible with standard Web3 libraries
- Should support common Ethereum standards (ERC-20, ERC-721)
IMPORTANT: The implementation should have NO UI/UX components. All functionality must be implemented as testable Python modules and classes that can be thoroughly tested using pytest. Focus on creating well-defined APIs and interfaces rather than user interfaces.
The mock server must provide:
-
JSON-RPC Engine: Complete implementation of Ethereum JSON-RPC methods including eth_call, eth_sendTransaction, eth_getBalance, with automatic block progression and state management.
-
Transaction Pool Manager: Realistic transaction lifecycle simulation with mempool behavior, mining delays, confirmation counts, and reorganization support.
-
Event Emitter System: Smart contract event generation with proper log indexing, bloom filters, topic filtering, and historical event queries.
-
Gas Oracle: Dynamic gas price simulation with EIP-1559 support, priority fees, base fee calculations, and gas limit estimation.
-
Multi-Chain Router: Support for multiple blockchain simulations with different chain IDs, consensus rules, native currencies, and network parameters.
- JSON-RPC methods return spec-compliant responses
- Transactions progress through correct lifecycle states
- Events are emitted with proper indexing and filtering
- Gas estimations accurately reflect transaction complexity
- Multi-chain routing works with standard libraries
- Sending transactions and monitoring confirmations
- Subscribing to smart contract events
- Estimating gas for complex transactions
- Switching between different blockchain networks
- Querying historical blockchain data
- RPC response time under 50ms
- Support 100+ concurrent connections
- Process 1000+ transactions per second
- Event emission latency under 100ms
- Block generation at precise intervals
- Handling invalid transaction signatures
- Transaction reversion and error messages
- Event log overflow conditions
- Gas price spike scenarios
- Chain reorganization handling
- Minimum 95% code coverage for all core modules
- 100% coverage for RPC method implementations
- Specification compliance tests
- Integration tests with Web3 libraries
- Multi-chain scenario tests
IMPORTANT:
- ALL functionality must be testable via pytest without any manual intervention
- Tests should verify behavior against requirements, not implementation details
- Tests should be designed to validate the WHAT (requirements) not the HOW (implementation)
- Tests should be comprehensive enough to verify all aspects of the requirements
- Tests should not assume or dictate specific implementation approaches
- REQUIRED: Tests must be run with pytest-json-report to generate a pytest_results.json file:
pip install pytest-json-report pytest --json-report --json-report-file=pytest_results.json - The pytest_results.json file must be included as proof that all tests pass
The implementation will be considered successful when:
- All standard Ethereum JSON-RPC methods are supported
- Transaction lifecycle accurately mimics real blockchain behavior
- Smart contract events work identically to real implementations
- Gas estimations provide realistic cost predictions
- Multi-chain support enables comprehensive dApp testing
REQUIRED FOR SUCCESS:
- All tests must pass when run with pytest
- A valid pytest_results.json file must be generated showing all tests passing
- The implementation must satisfy all key requirements specified for this persona
To set up the development environment:
- Create a virtual environment using
uv venvfrom within the project directory - Activate the environment with
source .venv/bin/activate - Install the project in editable mode with
uv pip install -e . - Install test dependencies including pytest-json-report
The final implementation must be validated by:
- Running all tests with pytest-json-report
- Generating and providing the pytest_results.json file
- Demonstrating all five key requirements are fully implemented
- Showing compatibility with standard Web3 libraries
CRITICAL: Running tests with pytest-json-report and providing the pytest_results.json file is MANDATORY for project completion.