Complete test execution - everything happens here for isolation
(test_path: PathBuf, args: &Commands)
| 211 | |
| 212 | // Complete test execution - everything happens here for isolation |
| 213 | async fn execute_test(test_path: PathBuf, args: &Commands) -> Result<()> { |
| 214 | let test_config = TestConfig::from_file(test_path.to_string_lossy().to_string()).await?; |
| 215 | |
| 216 | // Check if test is disabled |
| 217 | if test_config.settings.disabled { |
| 218 | println!("[{}] SKIPPED: Test disabled - {}", Local::now().format("%H:%M:%S.%3f"), test_path.display()); |
| 219 | return Ok(()); |
| 220 | } |
| 221 | |
| 222 | println!("[{}] TEST STARTED: {}", Local::now().format("%H:%M:%S.%3f"), test_path.display()); |
| 223 | println!("[{}] Block: {} | Timeout: {}s", Local::now().format("%H:%M:%S.%3f"), test_config.settings.block, args.timeout); |
| 224 | |
| 225 | // Create a fresh Anvil instance for this test |
| 226 | let node_url = env::var("MAINNET_WS")?; |
| 227 | let client = AnvilDebugProviderFactory::from_node_on_block(node_url, test_config.settings.block).await?; |
| 228 | let priv_key = client.privkey()?.to_bytes().to_vec(); |
| 229 | |
| 230 | let mut mock_server: Option<MockServer> = None; |
| 231 | if test_config.modules.flashbots { |
| 232 | // Start flashbots mock server |
| 233 | mock_server = Some(MockServer::start().await); |
| 234 | mount_flashbots_mock(mock_server.as_ref().unwrap()).await; |
| 235 | } |
| 236 | |
| 237 | let multicaller_address = MulticallerDeployer::new() |
| 238 | .set_code(client.clone(), address!("FCfCfcfC0AC30164AFdaB927F441F2401161F358")) |
| 239 | .await? |
| 240 | .address() |
| 241 | .ok_or_eyre("MULTICALLER_NOT_DEPLOYED")?; |
| 242 | info!("Multicaller deployed at {:?}", multicaller_address); |
| 243 | |
| 244 | let multicaller_encoder = MulticallerSwapEncoder::default_with_address(multicaller_address); |
| 245 | |
| 246 | let block_number = client.get_block_number().await?; |
| 247 | info!("Current block_number={}", block_number); |
| 248 | |
| 249 | let block_response = client.get_block(block_number.into()).await?.unwrap(); |
| 250 | let block = <BlockTy<EthPrimitives> as TryFromBlockResponse<Ethereum>>::from_block_response(block_response)?; |
| 251 | let block_header = block.header().clone(); |
| 252 | info!("Current block_header={:?}", block_header); |
| 253 | |
| 254 | let block_response = client.get_block(block_number.into()).await?.unwrap(); |
| 255 | |
| 256 | let block_header_with_txes = <BlockTy<EthPrimitives> as TryFromBlockResponse<Ethereum>>::from_block_response(block_response)?; |
| 257 | |
| 258 | // Create AlloyDB connected to the forked Anvil instance |
| 259 | let alloy_db = |
| 260 | AlloyDB::new(client.clone(), BlockId::Number(BlockNumberOrTag::Number(block_number))).ok_or_eyre("Failed to create AlloyDB")?; |
| 261 | let state_db = KabuDB::new().with_ext_db(alloy_db); |
| 262 | let market_state_instance = MarketState::new(state_db); |
| 263 | |
| 264 | // Add default tokens for price actor |
| 265 | |
| 266 | info!("Creating blockchain and initial state"); |
| 267 | // Create Blockchain instance which manages all channels |
| 268 | // Disable influxdb for test runner |
| 269 | let blockchain = Blockchain::new_with_config(1, false); // Chain ID 1 for mainnet, influxdb disabled |
| 270 |
no test coverage detected