Skip to content

Commit 8e5e236

Browse files
Correct the termination of the end-to-end tests. (#2985)
* Make sure that the `node_service` terminates with `node_service.ensure_is_running`. * Terminates the `net` in all cases where it is created.
1 parent a601098 commit 8e5e236

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

linera-service/tests/linera_net_tests.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async fn test_wasm_end_to_end_ethereum_tracker(config: impl LineraNetConfig) ->
406406
};
407407

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

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

438438
let app = EthereumTrackerApp(
439439
node_service
@@ -465,6 +465,12 @@ async fn test_wasm_end_to_end_ethereum_tracker(config: impl LineraNetConfig) ->
465465
(address1.clone(), U256::from(10)),
466466
])
467467
.await;
468+
469+
node_service.ensure_is_running()?;
470+
471+
net.ensure_is_running().await?;
472+
net.terminate().await?;
473+
468474
Ok(())
469475
}
470476

linera-service/tests/local_net_tests.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async fn test_end_to_end_reconfiguration(config: LocalNetConfig) -> Result<()> {
192192
)
193193
.await?;
194194

195-
if let Some(node_service_2) = node_service_2 {
195+
if let Some(mut node_service_2) = node_service_2 {
196196
node_service_2.process_inbox(&chain_2).await?;
197197
let query = format!(
198198
"query {{ chain(chainId:\"{chain_2}\") {{
@@ -214,6 +214,8 @@ async fn test_end_to_end_reconfiguration(config: LocalNetConfig) -> Result<()> {
214214
let committees = &response["chain"]["executionState"]["system"]["committees"];
215215
let epochs = committees.as_object().unwrap().keys().collect::<Vec<_>>();
216216
assert_eq!(&epochs, &["7"]);
217+
218+
node_service_2.ensure_is_running()?;
217219
} else {
218220
client_2.sync(chain_2).await?;
219221
client_2.process_inbox(chain_2).await?;
@@ -584,13 +586,15 @@ async fn test_project_publish(database: Database, network: Network) -> Result<()
584586
let chain = client.load_wallet()?.default_chain().unwrap();
585587

586588
let port = get_node_port().await;
587-
let node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
589+
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
588590

589591
assert_eq!(
590592
node_service.try_get_applications_uri(&chain).await?.len(),
591593
1
592594
);
593595

596+
node_service.ensure_is_running()?;
597+
594598
net.ensure_is_running().await?;
595599
net.terminate().await?;
596600

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

621625
let port = get_node_port().await;
622-
let node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
626+
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
623627

624628
assert_eq!(
625629
node_service.try_get_applications_uri(&chain).await?.len(),
626630
1
627631
);
628632

633+
node_service.ensure_is_running()?;
634+
629635
net.ensure_is_running().await?;
630636
net.terminate().await?;
631637

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

689-
let (_net, client) = config.instantiate().await?;
695+
let (mut net, client) = config.instantiate().await?;
690696

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

706+
net.ensure_is_running().await?;
707+
net.terminate().await?;
708+
700709
Ok(())
701710
}
702711

0 commit comments

Comments
 (0)