diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 05b58b2104..88374ab9a7 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -1,5 +1,5 @@ use { - super::{colocation::start_legacy_solver, TestAccount}, + super::TestAccount, crate::setup::{ colocation::{self, SolverEngine}, wait_for_condition, @@ -9,7 +9,7 @@ use { app_data::{AppDataDocument, AppDataHash}, autopilot::infra::persistence::dto, clap::Parser, - ethcontract::{H256, U256}, + ethcontract::H256, model::{ order::{Order, OrderCreation, OrderUid}, quote::{OrderQuoteRequest, OrderQuoteResponse}, @@ -209,52 +209,61 @@ impl<'a> Services<'a> { .await; } - /// Starts a basic version of the protocol with a single legacy solver and - /// quoter. - pub async fn start_protocol_legacy_solver( + /// Starts a basic version of the protocol with a single external solver. + /// Optionally starts a baseline solver and uses it for price estimation. + pub async fn start_protocol_external_solver( &self, solver: TestAccount, solver_endpoint: Option, - quoter_endpoint: Option, - chain_id: Option, + run_baseline: bool, ) { let external_solver_endpoint = - solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap()); - let colocated_solver_endpoint = - start_legacy_solver(external_solver_endpoint, chain_id).await; + solver_endpoint.unwrap_or("http://localhost:8000/".parse().unwrap()); - let external_quoter_endpoint = - quoter_endpoint.unwrap_or("http://localhost:8000/quote".parse().unwrap()); - let colocated_quoter_endpoint = - start_legacy_solver(external_quoter_endpoint, chain_id).await; + let mut solvers = vec![SolverEngine { + name: "test_solver".into(), + account: solver.clone(), + endpoint: external_solver_endpoint, + }]; - colocation::start_driver( - self.contracts, - vec![ - SolverEngine { - name: "test_solver".into(), - account: solver.clone(), - endpoint: colocated_solver_endpoint, - }, - SolverEngine { - name: "test_quoter".into(), - account: solver, - endpoint: colocated_quoter_endpoint, - }, - ], - ); - self.start_autopilot( - Some(Duration::from_secs(11)), - vec![ + let (autopilot_args, api_args) = if run_baseline { + let baseline_solver_endpoint = + colocation::start_baseline_solver(self.contracts.weth.address()).await; + + solvers.push(SolverEngine { + name: "baseline_solver".into(), + account: solver, + endpoint: baseline_solver_endpoint, + }); + + // Here we call the baseline_solver "test_quoter" to make the native price + // estimation use the baseline_solver instead of the test_quoter + let autopilot_args = vec![ + "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,test_solver|http://localhost:11088/test_solver".to_string(), + ]; + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,test_solver|http://localhost:11088/test_solver".to_string(), + ]; + (autopilot_args, api_args) + } else { + let autopilot_args = vec![ "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_solver" .to_string(), - ], - ); - self.start_api(vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter".to_string(), - ]) - .await; + ]; + + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_solver" + .to_string(), + ]; + (autopilot_args, api_args) + }; + + colocation::start_driver(self.contracts, solvers); + + self.start_autopilot(Some(Duration::from_secs(11)), autopilot_args); + self.start_api(api_args).await; } async fn wait_for_api_to_come_up() {