Skip to content

Commit

Permalink
try with removing sequencer1 from clients
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Nov 25, 2024
1 parent c5ce4cc commit 312beba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ ESPRESSO_NASTY_CLIENT_PORT=24011
ESPRESSO_SEQUENCER_ETH_MULTISIG_ADDRESS=8626f6940e2eb28930efb4cef49b2d1f2c9c1199

# Set this to the number of blocks you would like to confirm the sequencer can reach
INTEGRATION_TEST_EXPECTED_BLOCK_HEIGHT=10
INTEGRATION_TEST_EXPECTED_BLOCK_HEIGHT=200

INTEGRATION_TEST_HOST=localhost
INTEGRATION_TEST_PROTO=http
Expand Down
12 changes: 5 additions & 7 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use anyhow::Context;
use espresso_types::{FeeAccount, FeeAmount, FeeMerkleTree, Header};
use ethers::types::Address;
use futures::{stream::BoxStream, StreamExt};
use jf_merkle_tree::{
prelude::{MerkleProof, Sha3Node},
MerkleTreeScheme,
};
use std::time::Duration;
use surf_disco::{
error::ClientError,
socket::{Connection, Unsupported},
Url,
};
use surf_disco::{error::ClientError, Url};
use tokio::time::sleep;
use vbs::version::StaticVersion;

Expand Down Expand Up @@ -48,12 +45,13 @@ impl SequencerClient {
pub async fn subscribe_headers(
&self,
height: u64,
) -> anyhow::Result<Connection<Header, Unsupported, ClientError, SequencerApiVersion>> {
) -> anyhow::Result<BoxStream<'static, Result<Header, ClientError>>> {
self.0
.socket(&format!("availability/stream/headers/{height}"))
.subscribe()
.subscribe::<Header>()
.await
.context("subscribing to Espresso headers")
.map(|s| s.boxed())
}

/// Get the balance for a given account at a given block height, defaulting to current balance.
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ impl TestConfig {
let sequencer_api_url = url_from_port(dotenvy::var("ESPRESSO_SEQUENCER1_API_PORT")?)?;
let sequencer_clients = [
dotenvy::var("ESPRESSO_SEQUENCER_API_PORT")?,
dotenvy::var("ESPRESSO_SEQUENCER1_API_PORT")?,
dotenvy::var("ESPRESSO_SEQUENCER2_API_PORT")?,
dotenvy::var("ESPRESSO_SEQUENCER5_API_PORT")?,
dotenvy::var("ESPRESSO_SEQUENCER6_API_PORT")?,
]
.iter()
.map(|port| url_from_port(port.clone()).unwrap())
Expand Down
12 changes: 6 additions & 6 deletions tests/upgrades.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::TestConfig;
use anyhow::Result;
use espresso_types::{FeeVersion, MarketplaceVersion};
use futures::StreamExt;
use futures::{future::join_all, StreamExt};
use vbs::version::StaticVersionType;

const SEQUENCER_BLOCKS_TIMEOUT: u64 = 200;
Expand All @@ -28,15 +28,15 @@ async fn test_upgrade() -> Result<()> {

// Test is limited to those sequencers with correct modules
// enabled. It would be less fragile if we could discover them.
let subscriptions = vec![
clients[0].subscribe_headers(0).await?,
clients[1].subscribe_headers(0).await?,
];
let subscriptions = join_all(clients.iter().map(|c| c.subscribe_headers(0)))
.await
.into_iter()
.collect::<anyhow::Result<Vec<_>>>()?;

for mut stream in subscriptions {
while let Some(header) = stream.next().await {
let header = header.unwrap();
println!("{header:?}");
println!("height={:?}", header.height());

// TODO is it possible to discover the view at which upgrade should be finished?
// First few views should be `Base` version.
Expand Down

0 comments on commit 312beba

Please sign in to comment.