Skip to content

Commit

Permalink
fix healthcheck for builder service in integration test (#2443)
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit authored Jan 9, 2025
2 parents 46d7fc3 + cfe093d commit b73be56
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 4 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ test-all:

test-integration:
@echo 'NOTE that demo-native must be running for this test to succeed.'
cargo nextest run --all-features --nocapture --profile integration
INTEGRATION_TEST_SEQUENCER_VERSION=2 cargo nextest run --all-features --nocapture --profile integration smoke
test-integration-mp:
@echo 'NOTE that demo-native-mp must be running for this test to succeed.'
INTEGRATION_TEST_SEQUENCER_VERSION=99 cargo nextest run --all-features --nocapture --profile integration

clippy:
@echo 'features: "embedded-db"'
Expand Down
3 changes: 2 additions & 1 deletion sequencer-sqlite/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use anyhow::{anyhow, Result};
use client::SequencerClient;
use espresso_types::FeeAmount;
use espresso_types::{FeeAmount, MarketplaceVersion};
use ethers::prelude::*;
use futures::future::join_all;
use std::{fmt, str::FromStr, time::Duration};
use surf_disco::Url;
use tokio::time::{sleep, timeout};
use vbs::version::StaticVersionType;

const L1_PROVIDER_RETRY_INTERVAL: Duration = Duration::from_secs(1);
// TODO add to .env
Expand Down Expand Up @@ -93,17 +94,18 @@ impl TestConfig {
};

// TODO test both builders (probably requires some refactoring).
let builder_url = if sequencer_version >= 3 {
let builder_url = if sequencer_version as u16 >= MarketplaceVersion::version().minor {
let url = url_from_port(dotenvy::var("ESPRESSO_RESERVE_BUILDER_SERVER_PORT")?)?;
let url = Url::from_str(&url)?;
wait_for_service(url.clone(), 1000, 200).await.unwrap();

Url::from_str(&url)?
.join("bundle_info/builderaddress")
.unwrap()
url.join("bundle_info/builderaddress").unwrap()
} else {
let url = url_from_port(dotenvy::var("ESPRESSO_BUILDER_SERVER_PORT")?)?;
Url::from_str(&url)?
.join("block_info/builderaddress")
.unwrap()
let url = Url::from_str(&url)?;
wait_for_service(url.clone(), 1000, 200).await.unwrap();

url.join("block_info/builderaddress").unwrap()
};

let builder_address = get_builder_address(builder_url).await;
Expand Down Expand Up @@ -222,9 +224,8 @@ impl TestConfig {
}
}

/// Get Address from builder after waiting for builder to become ready.
/// Get Address from builder
pub async fn get_builder_address(url: Url) -> Address {
let _ = wait_for_service(url.clone(), 1000, 200).await;
for _ in 0..5 {
// Try to get builder address somehow
if let Ok(body) = reqwest::get(url.clone()).await {
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn test_upgrade() -> Result<()> {

let testing = TestConfig::new().await.unwrap();

let versions = if testing.sequencer_version >= 3 {
let versions = if testing.sequencer_version as u16 >= MarketplaceVersion::version().minor {
(FeeVersion::version(), MarketplaceVersion::version())
} else {
panic!("Invalid sequencer version provided for upgrade test.");
Expand Down

0 comments on commit b73be56

Please sign in to comment.