Skip to content

Commit

Permalink
Correct the termination of the end-to-end tests. (#2985)
Browse files Browse the repository at this point in the history
* Make sure that the `node_service` terminates with `node_service.ensure_is_running`.
* Terminates the `net` in all cases where it is created.
  • Loading branch information
MathieuDutSik authored Nov 29, 2024
1 parent a601098 commit 8e5e236
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
10 changes: 8 additions & 2 deletions linera-service/tests/linera_net_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ async fn test_wasm_end_to_end_ethereum_tracker(config: impl LineraNetConfig) ->
};

// Setting up the validators
let (_net, client) = config.instantiate().await?;
let (mut net, client) = config.instantiate().await?;
let chain = client.load_wallet()?.default_chain().unwrap();

// Change the ownership so that the blocks inserted are not
Expand All @@ -433,7 +433,7 @@ async fn test_wasm_end_to_end_ethereum_tracker(config: impl LineraNetConfig) ->
)
.await?;
let port = get_node_port().await;
let node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;

let app = EthereumTrackerApp(
node_service
Expand Down Expand Up @@ -465,6 +465,12 @@ async fn test_wasm_end_to_end_ethereum_tracker(config: impl LineraNetConfig) ->
(address1.clone(), U256::from(10)),
])
.await;

node_service.ensure_is_running()?;

net.ensure_is_running().await?;
net.terminate().await?;

Ok(())
}

Expand Down
17 changes: 13 additions & 4 deletions linera-service/tests/local_net_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async fn test_end_to_end_reconfiguration(config: LocalNetConfig) -> Result<()> {
)
.await?;

if let Some(node_service_2) = node_service_2 {
if let Some(mut node_service_2) = node_service_2 {
node_service_2.process_inbox(&chain_2).await?;
let query = format!(
"query {{ chain(chainId:\"{chain_2}\") {{
Expand All @@ -214,6 +214,8 @@ async fn test_end_to_end_reconfiguration(config: LocalNetConfig) -> Result<()> {
let committees = &response["chain"]["executionState"]["system"]["committees"];
let epochs = committees.as_object().unwrap().keys().collect::<Vec<_>>();
assert_eq!(&epochs, &["7"]);

node_service_2.ensure_is_running()?;
} else {
client_2.sync(chain_2).await?;
client_2.process_inbox(chain_2).await?;
Expand Down Expand Up @@ -584,13 +586,15 @@ async fn test_project_publish(database: Database, network: Network) -> Result<()
let chain = client.load_wallet()?.default_chain().unwrap();

let port = get_node_port().await;
let node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;

assert_eq!(
node_service.try_get_applications_uri(&chain).await?.len(),
1
);

node_service.ensure_is_running()?;

net.ensure_is_running().await?;
net.terminate().await?;

Expand Down Expand Up @@ -619,13 +623,15 @@ async fn test_example_publish(database: Database, network: Network) -> Result<()
let chain = client.load_wallet()?.default_chain().unwrap();

let port = get_node_port().await;
let node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;

assert_eq!(
node_service.try_get_applications_uri(&chain).await?.len(),
1
);

node_service.ensure_is_running()?;

net.ensure_is_running().await?;
net.terminate().await?;

Expand Down Expand Up @@ -686,7 +692,7 @@ async fn test_storage_service_wallet_lock() -> Result<()> {
let _guard = INTEGRATION_TEST_GUARD.lock().await;
tracing::info!("Starting test {}", test_name!());

let (_net, client) = config.instantiate().await?;
let (mut net, client) = config.instantiate().await?;

let wallet_state = WalletState::read_from_file(client.wallet_path().as_path())?;
let chain_id = wallet_state.default_chain().unwrap();
Expand All @@ -697,6 +703,9 @@ async fn test_storage_service_wallet_lock() -> Result<()> {
drop(lock);
assert!(client.process_inbox(chain_id).await.is_ok());

net.ensure_is_running().await?;
net.terminate().await?;

Ok(())
}

Expand Down

0 comments on commit 8e5e236

Please sign in to comment.