Skip to content

Commit

Permalink
add e2e test helper functions to run a legacy solver
Browse files Browse the repository at this point in the history
  • Loading branch information
devanoneth committed Jan 15, 2024
1 parent 80833b8 commit 3dd562b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
12 changes: 12 additions & 0 deletions crates/e2e/src/setup/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ pub async fn start_naive_solver() -> Url {
start_solver(config_file, "naive".to_string()).await
}

pub async fn start_legacy_solver(solver_endpoint: Url) -> Url {
let config_file = config_tmp_file(format!(
r#"
chain-id = "1"
solver-name = "legacy"
endpoint = "{solver_endpoint}"
"#,
));

start_solver(config_file, "legacy".to_string()).await
}

async fn start_solver(config_file: TempPath, solver_name: String) -> Url {
let args = vec![
"solvers".to_string(),
Expand Down
43 changes: 41 additions & 2 deletions crates/e2e/src/setup/services.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
super::TestAccount,
super::{colocation::start_legacy_solver, TestAccount},
crate::setup::{
colocation::{self, SolverEngine},
wait_for_condition,
Expand All @@ -16,7 +16,7 @@ use {
solver_competition::SolverCompetitionAPI,
trade::Trade,
},
reqwest::{Client, StatusCode},
reqwest::{Client, StatusCode, Url},
sqlx::Connection,
std::time::Duration,
};
Expand Down Expand Up @@ -149,6 +149,45 @@ 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(
&self,
solver_endpoint: Option<Url>,
quoter_endpoint: Option<Url>,
solver: TestAccount,
) {
let solver_endpoint =
solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap());
let solver_endpoint = start_legacy_solver(solver_endpoint).await;

let quoter_endpoint =
quoter_endpoint.unwrap_or("http://localhost:8000/quote".parse().unwrap());
let quoter_endpoint = start_legacy_solver(quoter_endpoint).await;

colocation::start_driver(
self.contracts,
vec![
SolverEngine {
name: "test_solver".into(),
account: solver.clone(),
endpoint: solver_endpoint,
},
SolverEngine {
name: "test_quoter".into(),
account: solver,
endpoint: quoter_endpoint,
},
],
);
self.start_autopilot(vec![
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
self.start_api(vec![
"--price-estimation-drivers=test_solver|http://localhost:11088/test_quoter".to_string(),
])
.await;
}

async fn wait_for_api_to_come_up() {
let is_up = || async {
reqwest::get(format!("{API_HOST}{VERSION_ENDPOINT}"))
Expand Down

0 comments on commit 3dd562b

Please sign in to comment.