feat: Clear PreCachedDB account storage btw tests
[copied from tycho-simulation commit msg] Main issue: - This was causing a big issue in the SDK testing, since accounts were being leaked between test cases. Adding this functionality provides an easy way to clear storage on the rust side, by calling .clear() between subsequent tests. How this manifested: - Incorrect pool balances were being loaded in the BalancerV2SwapAdapter if tests were run altogether. - Pool balances were correct if tests were run in isolation. - We checked that tycho-indexer returned correct pool balances, and we checked pool balances for that block on-chain to be double-sure - In the python test suite, which was passing, there was code which dropped the whole database between subsequent tests, which was not being duplicated in the rust suite.
This commit is contained in:
@@ -329,6 +329,10 @@ fn validate_state(
|
||||
info!("Using adapter contract: {}", adapter_contract_path.display());
|
||||
let adapter_contract_path_str: &str = adapter_contract_path.to_str().unwrap();
|
||||
|
||||
// Clear the shared database state to ensure test isolation
|
||||
// This prevents state from previous tests from affecting the current test
|
||||
tycho_simulation::evm::engine_db::SHARED_TYCHO_DB.clear();
|
||||
|
||||
let mut decoder = TychoStreamDecoder::new();
|
||||
let decoder_context = DecoderContext::new().vm_adapter_path(adapter_contract_path_str);
|
||||
decoder.register_decoder_with_context::<EVMPoolState<PreCachedDB>>(
|
||||
|
||||
Reference in New Issue
Block a user