Expand description
Debug handler implementations for testing and simulation Debug handler implementations for testing and simulation.
This module provides handler implementations designed for testing, debugging, and simulation scenarios. It includes two main types of handlers:
§Handler Types
§[DebugHandler]
A simple error-only handler that returns detailed error messages for all operations. Useful for testing error conditions and understanding the evaluation flow.
§[SimulationDebugHandler]
An advanced simulation handler that:
- Returns mock values for variables and function calls
- Logs all operations for debugging
- Allows pre-configuration of specific return values
- Generates plausible default values based on naming conventions
§Usage
§Error-Only Debug Handler
ⓘ
let handlers = create_debug_handlers();
let evaluator = ExpressionEvaluator::new(handlers);
// All operations will return detailed error messages§Simulation Handler
ⓘ
let (handlers, debug_handler) = create_simulation_debug_handlers();
debug_handler.set_variable("balance", DynSolValue::Uint(U256::from(1000), 256));
debug_handler.set_function("totalSupply", DynSolValue::Uint(U256::from(1000000), 256));
let evaluator = ExpressionEvaluator::new(handlers);
let result = evaluator.eval("balance + totalSupply()", 0)?; // Returns mock values
// Check execution log
let log = debug_handler.get_log();
for entry in log {
println!("Operation: {}", entry);
}Structs§
- Debug
Handler - Debug handler that returns errors but includes input values for debugging
- Simulation
Debug Handler - Enhanced debug handler that can simulate values and log evaluation flow
Functions§
- create_
debug_ handlers - Create debug handlers for all traits (original error-only version)
- create_
simulation_ debug_ handlers - Create simulation debug handlers that return mock values and log operations