diff --git a/src/connectivity/bluetooth/core/bt-gap/src/host_dispatcher.rs b/src/connectivity/bluetooth/core/bt-gap/src/host_dispatcher.rs index 59e88c4126c5..fa08d47f5933 100644 --- a/src/connectivity/bluetooth/core/bt-gap/src/host_dispatcher.rs +++ b/src/connectivity/bluetooth/core/bt-gap/src/host_dispatcher.rs @@ -778,7 +778,8 @@ async fn try_restore_bonds( Some(data) => data, None => return Ok(()), }; - let res = host_device.read().restore_bonds(data).await; + let fut = host_device.read().restore_bonds(data); + let res = fut.await; res.map_err(|e| { fx_log_err!("failed to restore bonding data for host: {:?}", e); e diff --git a/src/connectivity/bluetooth/lib/fuchsia-bluetooth/src/hci_emulator.rs b/src/connectivity/bluetooth/lib/fuchsia-bluetooth/src/hci_emulator.rs index 3ed3c526e34c..e58221c707fa 100644 --- a/src/connectivity/bluetooth/lib/fuchsia-bluetooth/src/hci_emulator.rs +++ b/src/connectivity/bluetooth/lib/fuchsia-bluetooth/src/hci_emulator.rs @@ -167,7 +167,7 @@ impl TestDevice { let channel = fdio::clone_channel(&self.0)?; let controller = ControllerProxy::new(fasync::Channel::from_channel(channel)?); - let _ = controller + controller .bind(EMULATOR_DRIVER_PATH) .map_err(Error::from) .on_timeout(10.seconds().after_now(), || { diff --git a/src/connectivity/bluetooth/tests/integration/src/harness/control.rs b/src/connectivity/bluetooth/tests/integration/src/harness/control.rs index 4f04d600462f..88a6b26f075c 100644 --- a/src/connectivity/bluetooth/tests/integration/src/harness/control.rs +++ b/src/connectivity/bluetooth/tests/integration/src/harness/control.rs @@ -83,7 +83,8 @@ pub async fn new_control_harness() -> Result { let control_harness = ControlHarness::new(proxy); // Store existing hosts in our state, as we won't get notified about them - let hosts = control_harness.aux().get_adapters().await?; + let fut = control_harness.aux().get_adapters(); + let hosts = fut.await?; if let Some(hosts) = hosts { for host in hosts { control_harness.write_state().hosts.insert(host.identifier.clone(), host); @@ -198,7 +199,8 @@ pub async fn activate_fake_host( .identifier .to_string(); // We can safely unwrap here as this is guarded by the previous expectation - control.aux().set_active_adapter(&host).await?; + let fut = control.aux().set_active_adapter(&host); + fut.await?; control .when_satisfied(control_expectation::active_host_is(host.clone()), control_timeout()) .await?; diff --git a/src/connectivity/bluetooth/tests/integration/src/harness/host_driver.rs b/src/connectivity/bluetooth/tests/integration/src/harness/host_driver.rs index ec68852820fc..1a8095b876b3 100644 --- a/src/connectivity/bluetooth/tests/integration/src/harness/host_driver.rs +++ b/src/connectivity/bluetooth/tests/integration/src/harness/host_driver.rs @@ -58,11 +58,11 @@ pub fn expect_remote_device( // Returns a future that resolves when a peer matching `id` is not present on the host. pub async fn expect_no_peer(host: &HostDriverHarness, id: String) -> Result<(), Error> { - host.when_satisfied( + let fut = host.when_satisfied( Predicate::::new(move |host| host.peers.iter().all(|(i, _)| i != &id), None), timeout_duration(), - ) - .await?; + ); + fut.await?; Ok(()) } @@ -115,21 +115,21 @@ pub async fn expect_host_peer( host: &HostDriverHarness, target: Predicate, ) -> Result { - host.when_satisfied( + let fut = host.when_satisfied( Predicate::::new( move |host| host.peers.iter().any(|(_, p)| target.satisfied(p)), None, ), timeout_duration(), - ) - .await + ); + fut.await } pub async fn expect_adapter_state( host: &HostDriverHarness, target: Predicate, ) -> Result { - host.when_satisfied( + let fut = host.when_satisfied( Predicate::::new( move |host| match &host.host_info.state { Some(state) => target.satisfied(state), @@ -138,8 +138,8 @@ pub async fn expect_adapter_state( None, ), timeout_duration(), - ) - .await + ); + fut.await } impl TestHarness for HostDriverHarness { diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/bonding.rs b/src/connectivity/bluetooth/tests/integration/src/tests/bonding.rs index 961d51242cbb..52265991b100 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/bonding.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/bonding.rs @@ -57,7 +57,8 @@ async fn add_bonds( state: &HostDriverHarness, mut bonds: Vec, ) -> Result<(Status), Error> { - state.aux().proxy().add_bonded_devices(&mut bonds.iter_mut()).err_into().await + let fut = state.aux().proxy().add_bonded_devices(&mut bonds.iter_mut()).err_into(); + fut.await } const TEST_ID1: &str = "1234"; @@ -70,7 +71,8 @@ const TEST_NAME2: &str = "Name2"; // Tests initializing bonded LE devices. async fn test_add_bonded_devices_success(test_state: HostDriverHarness) -> Result<(), Error> { // Devices should be initially empty. - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; let bond_data1 = new_le_bond_data(TEST_ID1, TEST_ADDR1, TEST_NAME1, true /* has LTK */); @@ -90,7 +92,8 @@ async fn test_add_bonded_devices_success(test_state: HostDriverHarness) -> Resul expect_host_peer(&test_state, expected1).await?; expect_host_peer(&test_state, expected2).await?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(2, devices.len())?; expect_true!(devices.iter().any(|dev| dev.address == TEST_ADDR1))?; expect_true!(devices.iter().any(|dev| dev.address == TEST_ADDR2))?; @@ -103,7 +106,8 @@ async fn test_add_bonded_devices_success(test_state: HostDriverHarness) -> Resul async fn test_add_bonded_devices_no_ltk_fails(test_state: HostDriverHarness) -> Result<(), Error> { // Devices should be initially empty. - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; // Inserting a bonded device without a LTK should fail. @@ -111,7 +115,8 @@ async fn test_add_bonded_devices_no_ltk_fails(test_state: HostDriverHarness) -> let status = add_bonds(&test_state, vec![bond_data]).await?; expect_true!(status.error.is_some())?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; Ok(()) @@ -121,7 +126,8 @@ async fn test_add_bonded_devices_duplicate_entry( test_state: HostDriverHarness, ) -> Result<(), Error> { // Devices should be initially empty. - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; // Initialize one entry. @@ -135,7 +141,8 @@ async fn test_add_bonded_devices_duplicate_entry( .and(expectation::peer::bonded(true)); expect_host_peer(&test_state, expected.clone()).await?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(1, devices.len())?; // Adding an entry with the existing id should fail. @@ -155,7 +162,8 @@ async fn test_add_bonded_devices_duplicate_entry( // but reports an error. async fn test_add_bonded_devices_invalid_entry(test_state: HostDriverHarness) -> Result<(), Error> { // Devices should be initially empty. - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; // Add one entry with no LTK (invalid) and one with (valid). This should create an entry for the @@ -170,7 +178,8 @@ async fn test_add_bonded_devices_invalid_entry(test_state: HostDriverHarness) -> .and(expectation::peer::bonded(true)); expect_host_peer(&test_state, expected.clone()).await?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(1, devices.len())?; expect_remote_device(&test_state, TEST_ADDR2, &expected)?; diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/control.rs b/src/connectivity/bluetooth/tests/integration/src/tests/control.rs index dbb9d1234a17..7a93aa49b4dd 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/control.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/control.rs @@ -52,7 +52,8 @@ async fn test_set_active_host(control: ControlHarness) -> Result<(), Error> { .collect(); for (id, _) in state.hosts { - control.aux().set_active_adapter(&id).await?; + let fut = control.aux().set_active_adapter(&id); + fut.await?; control.when_satisfied(control_expectation::active_host_is(id), control_timeout()).await?; } @@ -89,7 +90,8 @@ async fn test_disconnect(control: ControlHarness) -> Result<(), Error> { .await? .map_err(|e| format_err!("Failed to register fake peer: {:#?}", e))?; - control.aux().request_discovery(true).await?; + let fut = control.aux().request_discovery(true); + fut.await?; let state = control .when_satisfied( control_expectation::peer_exists(expectation::peer::address(&peer_address_string)), @@ -103,12 +105,14 @@ async fn test_disconnect(control: ControlHarness) -> Result<(), Error> { // We can safely unwrap here as this is guarded by the previous expectation let peer = state.peers.iter().find(|(_, d)| &d.address == &peer_address_string).unwrap().0; - control.aux().connect(peer).await?; + let fut = control.aux().connect(peer); + fut.await?; control .when_satisfied(control_expectation::peer_connected(peer, true), control_timeout()) .await?; - control.aux().disconnect(peer).await?; + let fut = control.aux().disconnect(peer); + fut.await?; control .when_satisfied(control_expectation::peer_connected(peer, false), control_timeout()) diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/host_driver.rs b/src/connectivity/bluetooth/tests/integration/src/tests/host_driver.rs index fd9a20869267..2cac100a8501 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/host_driver.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/host_driver.rs @@ -69,10 +69,11 @@ async fn test_lifecycle(_: ()) -> Result<(), Error> { // Tests that the local host driver address is 0. async fn test_bd_addr(test_state: HostDriverHarness) -> Result<(), Error> { - let info = test_state + let fut = test_state .aux() .proxy() - .get_info() + .get_info(); + let info = fut .await .map_err(|_| BtError::new("failed to read host driver info"))?; expect_eq!("00:00:00:00:00:00", info.address.as_str()) @@ -82,8 +83,10 @@ async fn test_bd_addr(test_state: HostDriverHarness) -> Result<(), Error> { // TODO(armansito): Test for FakeHciDevice state changes. async fn test_set_local_name(test_state: HostDriverHarness) -> Result<(), Error> { let name = "test1234"; - test_state.aux().proxy().set_local_name(&name).await?; - expect_adapter_state(&test_state, expectation::host_driver::name(name)).await?; + let fut = test_state.aux().proxy().set_local_name(&name); + fut.await?; + let fut = expect_adapter_state(&test_state, expectation::host_driver::name(name)); + fut.await?; Ok(()) } @@ -92,11 +95,13 @@ async fn test_set_local_name(test_state: HostDriverHarness) -> Result<(), Error> // TODO(armansito): Test for FakeHciDevice state changes. async fn test_discoverable(test_state: HostDriverHarness) -> Result<(), Error> { // Enable discoverable mode. - test_state.aux().proxy().set_discoverable(true).await?; + let fut = test_state.aux().proxy().set_discoverable(true); + fut.await?; expect_adapter_state(&test_state, expectation::host_driver::discoverable(true)).await?; // Disable discoverable mode - test_state.aux().proxy().set_discoverable(false).await?; + let fut = test_state.aux().proxy().set_discoverable(false); + fut.await?; expect_adapter_state(&test_state, expectation::host_driver::discoverable(false)).await?; Ok(()) @@ -106,18 +111,21 @@ async fn test_discoverable(test_state: HostDriverHarness) -> Result<(), Error> { // TODO(armansito): Test for FakeHciDevice state changes. async fn test_discovery(test_state: HostDriverHarness) -> Result<(), Error> { // Start discovery. "discovering" should get set to true. - test_state.aux().proxy().start_discovery().await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; expect_adapter_state(&test_state, expectation::host_driver::discovering(true)).await?; let address = Address::Random([1, 0, 0, 0, 0, 0]); - let _peer = test_state.aux().add_le_peer_default(&address).await?; + let fut = test_state.aux().add_le_peer_default(&address); + let _peer = fut.await?; // The host should discover a fake peer. expect_host_peer(&test_state, peer::name("Fake").and(peer::address(&address.to_string()))) .await?; // Stop discovery. "discovering" should get set to false. - test_state.aux().proxy().stop_discovery().await?; + let fut = test_state.aux().proxy().stop_discovery(); + fut.await?; expect_adapter_state(&test_state, expectation::host_driver::discovering(false)).await?; Ok(()) @@ -127,8 +135,10 @@ async fn test_discovery(test_state: HostDriverHarness) -> Result<(), Error> { // TODO(armansito): Test for FakeHciDevice state changes. async fn test_close(test_state: HostDriverHarness) -> Result<(), Error> { // Enable all procedures. - test_state.aux().proxy().start_discovery().await?; - test_state.aux().proxy().set_discoverable(true).await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; + let fut = test_state.aux().proxy().set_discoverable(true); + fut.await?; let active_state = expectation::host_driver::discoverable(true) .and(expectation::host_driver::discovering(true)); expect_adapter_state(&test_state, active_state).await?; @@ -147,18 +157,22 @@ async fn test_close(test_state: HostDriverHarness) -> Result<(), Error> { // Tests that "list_devices" returns devices from a host's cache. async fn test_list_devices(test_state: HostDriverHarness) -> Result<(), Error> { // Devices should be initially empty. - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_eq!(vec![], devices)?; // Add a LE and a BR/EDR peer with the given addresses. let le_peer_address = Address::Random([1, 0, 0, 0, 0, 0]); let bredr_peer_address = Address::Public([2, 0, 0, 0, 0, 0]); - let _le_peer = test_state.aux().add_le_peer_default(&le_peer_address).await?; - let _bredr_peer = test_state.aux().add_bredr_peer_default(&bredr_peer_address).await?; + let fut = test_state.aux().add_le_peer_default(&le_peer_address); + let _le_peer = fut.await?; + let fut = test_state.aux().add_bredr_peer_default(&bredr_peer_address); + let _bredr_peer = fut.await?; // Wait for all fake devices to be discovered. - test_state.aux().proxy().start_discovery().await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; let expected_le = peer::address(&le_peer_address.to_string()) .and(peer::technology(TechnologyType::LowEnergy)); let expected_bredr = peer::address(&bredr_peer_address.to_string()) @@ -168,7 +182,8 @@ async fn test_list_devices(test_state: HostDriverHarness) -> Result<(), Error> { expect_host_peer(&test_state, expected_bredr.clone()).await?; // List the host's devices - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; // Both fake devices should be in the map. expect_eq!(2, devices.len())?; @@ -180,14 +195,17 @@ async fn test_list_devices(test_state: HostDriverHarness) -> Result<(), Error> { async fn test_connect(test_state: HostDriverHarness) -> Result<(), Error> { let address1 = Address::Random([1, 0, 0, 0, 0, 0]); let address2 = Address::Random([2, 0, 0, 0, 0, 0]); - let _peer1 = test_state.aux().add_le_peer_default(&address1).await?; - let peer2 = test_state.aux().add_le_peer_default(&address2).await?; + let fut = test_state.aux().add_le_peer_default(&address1); + let _peer1 = fut.await?; + let fut = test_state.aux().add_le_peer_default(&address2); + let peer2 = fut.await?; // Configure `peer2` to return an error for the connection attempt. let _ = peer2.assign_connection_status(HciError::ConnectionTimeout).await?; // Start discovery and let bt-host process the fake devices. - test_state.aux().proxy().start_discovery().await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; let le_dev = peer::address(&address1.to_string()); let le_error_dev = peer::address(&address2.to_string()); @@ -195,7 +213,8 @@ async fn test_connect(test_state: HostDriverHarness) -> Result<(), Error> { expect_host_peer(&test_state, le_dev).await?; expect_host_peer(&test_state, le_error_dev).await?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_true!(devices.len() >= 2)?; // Obtain bt-host assigned IDs of the devices. @@ -209,11 +228,13 @@ async fn test_connect(test_state: HostDriverHarness) -> Result<(), Error> { .ok_or(err_msg("error peer not found"))?; // Connecting to the failure peer should result in an error. - let status = test_state.aux().proxy().connect(&failure_dev.identifier).await?; + let fut = test_state.aux().proxy().connect(&failure_dev.identifier); + let status = fut.await?; expect_true!(status.error.is_some())?; // Connecting to the success peer should return success and the peer should become connected. - let status = test_state.aux().proxy().connect(&success_dev.identifier).await?; + let fut = test_state.aux().proxy().connect(&success_dev.identifier); + let status = fut.await?; expect_true!(status.error.is_none())?; let connected = peer::identifier(&success_dev.identifier).and(peer::connected(true)); @@ -225,13 +246,16 @@ async fn wait_for_test_device( test_state: HostDriverHarness, address: &Address, ) -> Result<(String, PeerProxy), Error> { - let peer = test_state.aux().add_le_peer_default(&address).await?; + let fut = test_state.aux().add_le_peer_default(&address); + let peer = fut.await?; // Start discovery and let bt-host process the fake LE peer. - test_state.aux().proxy().start_discovery().await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; let le_dev = expectation::peer::address(&address.to_string()); expect_host_peer(&test_state, le_dev).await?; - let devices = test_state.aux().proxy().list_devices().await?; + let fut = test_state.aux().proxy().list_devices(); + let devices = fut.await?; expect_true!(devices.len() == 1)?; // Obtain bt-host assigned IDs of the device. @@ -249,7 +273,8 @@ async fn wait_for_test_device( /// Disconnecting from an unknown device should succeed async fn test_disconnect_unknown_device(test_state: HostDriverHarness) -> Result<(), Error> { let unknown_id = "0123401234"; - let status = test_state.aux().proxy().disconnect(unknown_id).await?; + let fut = test_state.aux().proxy().disconnect(unknown_id); + let status = fut.await?; expect_eq!(status.error, None) } @@ -257,7 +282,8 @@ async fn test_disconnect_unknown_device(test_state: HostDriverHarness) -> Result async fn test_disconnect_unconnected_device(test_state: HostDriverHarness) -> Result<(), Error> { let address = Address::Random([1, 0, 0, 0, 0, 0]); let (success_dev, _proxy) = wait_for_test_device(test_state.clone(), &address).await?; - let status = test_state.aux().proxy().disconnect(&success_dev).await?; + let fut = test_state.aux().proxy().disconnect(&success_dev); + let status = fut.await?; expect_eq!(status.error, None) } @@ -266,14 +292,16 @@ async fn test_disconnect_connected_device(test_state: HostDriverHarness) -> Resu let address = Address::Random([1, 0, 0, 0, 0, 0]); let (success_dev, _proxy) = wait_for_test_device(test_state.clone(), &address).await?; - let status = test_state.aux().proxy().connect(&success_dev).await?; + let fut = test_state.aux().proxy().connect(&success_dev); + let status = fut.await?; expect_eq!(status.error, None)?; let connected = peer::address(&address.to_string()).and(peer::connected(true)); let disconnected = peer::address(&address.to_string()).and(peer::connected(false)); let _ = expect_host_peer(&test_state, connected).await?; - let status = test_state.aux().proxy().disconnect(&success_dev).await?; + let fut = test_state.aux().proxy().disconnect(&success_dev); + let status = fut.await?; expect_eq!(status.error, None)?; let _ = expect_host_peer(&test_state, disconnected).await?; Ok(()) @@ -284,20 +312,23 @@ async fn test_forget(test_state: HostDriverHarness) -> Result<(), Error> { let (le_peer, _proxy) = wait_for_test_device(test_state.clone(), &address).await?; // Start discovery and let bt-host process the fake peers. - test_state.aux().proxy().start_discovery().await?; + let fut = test_state.aux().proxy().start_discovery(); + fut.await?; // Wait for fake peer to be discovered. let expected_peer = expectation::peer::address(&address.to_string()); expect_host_peer(&test_state, expected_peer.clone()).await?; // Connecting to the peer should return success and the peer should become connected. - let mut status = test_state.aux().proxy().connect(&le_peer).await?; + let fut = test_state.aux().proxy().connect(&le_peer); + let mut status = fut.await?; expect_true!(status.error.is_none())?; expect_host_peer(&test_state, expected_peer.and(expectation::peer::connected(true))).await?; // Forgetting the peer should result in its removal. - status = test_state.aux().proxy().forget(&le_peer).await?; + let fut = test_state.aux().proxy().forget(&le_peer); + status = fut.await?; expect_true!(status.error.is_none())?; expect_no_peer(&test_state, le_peer).await?; diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_central.rs b/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_central.rs index 173222ceee50..bf004388b109 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_central.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_central.rs @@ -63,13 +63,13 @@ fn scan_timeout() -> Duration { } async fn start_scan(central: &CentralHarness) -> Result<(), Error> { - let status = central + let fut = central .aux() .proxy() .start_scan(None) .map_err(|e| e.context("FIDL error sending command").into()) - .on_timeout(scan_timeout().after_now(), move || Err(err_msg("Timed out"))) - .await + .on_timeout(scan_timeout().after_now(), move || Err(err_msg("Timed out"))); + let status = fut.await .context("Could not initialize scan")?; if let Some(e) = status.error { return Err(BTError::from(*e).into()); @@ -79,7 +79,8 @@ async fn start_scan(central: &CentralHarness) -> Result<(), Error> { async fn test_enable_scan(central: CentralHarness) -> Result<(), Error> { let address = Address::Random([1, 0, 0, 0, 0, 0]); - let _peer = central.aux().add_le_peer_default(&address).await?; + let fut = central.aux().add_le_peer_default(&address); + let _peer = fut.await?; start_scan(¢ral).await?; let _ = central .when_satisfied( diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_peripheral.rs b/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_peripheral.rs index 0a4c0c5a72f3..e6e8d4fec11c 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_peripheral.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/low_energy_peripheral.rs @@ -65,13 +65,13 @@ async fn start_advertising( params: AdvertisingParameters, handle: ServerEnd, ) -> Result { - harness + let fut = harness .aux() .proxy() .start_advertising(params, handle) .map_err(|e| e.context("FIDL error sending command").into()) - .on_timeout(test_timeout().after_now(), move || Err(err_msg("timed out"))) - .await + .on_timeout(test_timeout().after_now(), move || Err(err_msg("timed out"))); + fut.await .map_err(|e| e.context("Could not start advertising").into()) } diff --git a/src/connectivity/bluetooth/tests/integration/src/tests/profile.rs b/src/connectivity/bluetooth/tests/integration/src/tests/profile.rs index bf2ac53c98fe..ae325d573627 100644 --- a/src/connectivity/bluetooth/tests/integration/src/tests/profile.rs +++ b/src/connectivity/bluetooth/tests/integration/src/tests/profile.rs @@ -34,10 +34,10 @@ fn service_definition_for_testing() -> ServiceDefinition { async fn add_service(profile: &ProfileHarness) -> Result { let mut service_def = service_definition_for_testing(); - let (status, id) = profile + let fut = profile .aux() - .add_service(&mut service_def, SecurityLevel::EncryptionOptional, false) - .await?; + .add_service(&mut service_def, SecurityLevel::EncryptionOptional, false); + let (status, id) = fut.await?; if let Some(e) = status.error { return Err(BTError::from(*e).into()); } @@ -68,7 +68,8 @@ async fn test_add_and_remove_profile(profile: ProfileHarness) -> Result<(), Erro } async fn test_connect_unknown_peer(profile: ProfileHarness) -> Result<(), Error> { - let (status, socket) = profile.aux().connect_l2cap("unknown_peer", PSM_AVDTP as u16).await?; + let fut = profile.aux().connect_l2cap("unknown_peer", PSM_AVDTP as u16); + let (status, socket) = fut.await?; // Should be an error if status.error.is_none() { return Err(format_err!("Expected an error from connecting to an unknown peer"));