diff --git a/teos-common/src/appointment.rs b/teos-common/src/appointment.rs index eb6e6be0..bb635a7f 100644 --- a/teos-common/src/appointment.rs +++ b/teos-common/src/appointment.rs @@ -38,6 +38,13 @@ impl Locators { locator, }) } + + pub fn new(txid: Txid) -> Self { + Locators { + data: txid[..LOCATOR_LEN].try_into().unwrap(), + locator: Locator(txid[..LOCATOR_LEN].try_into().unwrap()), + } + } } diff --git a/teos/src/watcher.rs b/teos/src/watcher.rs index 1f405641..60932fbf 100644 --- a/teos/src/watcher.rs +++ b/teos/src/watcher.rs @@ -972,7 +972,7 @@ mod tests { receipt.subscription_expiry(), START_HEIGHT as u32 + DURATION ); - + #[cfg(feature = "accountable")] assert!(cryptography::verify( &receipt.to_vec(), &receipt.signature().unwrap(), @@ -1072,8 +1072,9 @@ mod tests { user_id, ConfirmationStatus::InMempoolSince(chain.get_block_count()), ); + #[cfg(feature = "accountable")] let receipt = watcher.add_appointment(triggered_appointment.inner, signature); - + #[cfg(feature = "accountable")] assert!(matches!( receipt, Err(AddAppointmentFailure::AlreadyTriggered) diff --git a/watchtower-plugin/src/dbm.rs b/watchtower-plugin/src/dbm.rs index b7f703e9..e5f1f3cc 100755 --- a/watchtower-plugin/src/dbm.rs +++ b/watchtower-plugin/src/dbm.rs @@ -863,7 +863,7 @@ mod tests { receipt.available_slots(), receipt.subscription_start(), receipt.subscription_expiry(), - HashMap::new(), + Vec::new(), Vec::new(), Vec::new() ); @@ -1007,6 +1007,7 @@ mod tests { dbm.store_tower_record(tower_id, net_addr, &receipt).unwrap(); // Add some appointment receipts and check they match + #[cfg(feature = "accountable")] let mut receipts = HashMap::new(); for _ in 0..5 { let appointment = generate_random_appointment(None); @@ -1042,13 +1043,14 @@ mod tests { // If there is no appointment receipt for the given (locator, tower_id) pair, Error::NotFound is returned // Try first with both being unknown + #[cfg(feature = "accountable")] assert!(dbm.load_appointment_receipt(tower_id, appointment.locator).is_none()); // Add the tower but not the appointment and try again let net_addr = "talaia.watch"; let receipt = get_random_registration_receipt(); dbm.store_tower_record(tower_id, net_addr, &receipt).unwrap(); - + #[cfg(feature = "accountable")] assert!(dbm.load_appointment_receipt(tower_id, appointment.locator).is_none()); // Add both @@ -1058,18 +1060,20 @@ mod tests { receipt.subscription_start(), receipt.subscription_expiry() ); + #[cfg(feature = "accountable")] let appointment_receipt = AppointmentReceipt::with_signature( "user_signature".to_owned(), 42, "tower_signature".to_owned() ); + #[cfg(feature = "accountable")] dbm.store_appointment_receipt( tower_id, appointment.locator, tower_summary.available_slots, &appointment_receipt ).unwrap(); - + #[cfg(feature = "accountable")] assert_eq!( dbm.load_appointment_receipt(tower_id, appointment.locator).unwrap(), appointment_receipt @@ -1101,6 +1105,7 @@ mod tests { let mut invalid_appointments = HashSet::new(); for _ in 0..5 { let appointment = generate_random_appointment(None); + #[cfg(feature = "accountable")] let appointment_receipt = AppointmentReceipt::with_signature( user_signature.to_owned(), 42, @@ -1108,7 +1113,7 @@ mod tests { ); let pending_appointment = generate_random_appointment(None); let invalid_appointment = generate_random_appointment(None); - + #[cfg(feature = "accountable")] dbm.store_appointment_receipt( tower_id, appointment.locator, @@ -1341,25 +1346,28 @@ mod tests { // Store a misbehaving proof and load it back let appointment = generate_random_appointment(None); + #[cfg(feature = "accountable")] let appointment_receipt = AppointmentReceipt::with_signature( "user_signature".to_owned(), 42, "tower_signature".to_owned() ); - + #[cfg(feature = "accountable")] let proof = MisbehaviorProof::new( appointment.locator, appointment_receipt, get_random_user_id() ); - + #[cfg(feature = "accountable")] dbm.store_misbehaving_proof(tower_id, &proof).unwrap(); + #[cfg(feature = "accountable")] assert_eq!(dbm.load_misbehaving_proof(tower_id).unwrap(), proof); } #[test] fn test_store_load_non_existing_misbehaving_proof() { let dbm = DBM::in_memory().unwrap(); + #[cfg(feature = "accountable")] assert!(dbm.load_misbehaving_proof(get_random_user_id()).is_none()); } @@ -1383,25 +1391,28 @@ mod tests { // // Store a misbehaving proof check let appointment = generate_random_appointment(None); + #[cfg(feature = "accountable")] let appointment_receipt = AppointmentReceipt::with_signature( "user_signature".to_owned(), 42, "tower_signature".to_owned() ); - + #[cfg(feature = "accountable")] let proof = MisbehaviorProof::new( appointment.locator, appointment_receipt, get_random_user_id() ); - + #[cfg(feature = "accountable")] dbm.store_misbehaving_proof(tower_id, &proof).unwrap(); + #[cfg(feature = "accountable")] assert!(dbm.exists_misbehaving_proof(tower_id)); } #[test] fn test_exists_misbehaving_proof_false() { let dbm = DBM::in_memory().unwrap(); + #[cfg(feature = "accountable")] assert!(!dbm.exists_misbehaving_proof(get_random_user_id())); } diff --git a/watchtower-plugin/src/lib.rs b/watchtower-plugin/src/lib.rs index 5222e03f..105c71f8 100755 --- a/watchtower-plugin/src/lib.rs +++ b/watchtower-plugin/src/lib.rs @@ -290,7 +290,7 @@ impl MisbehaviorProof { #[cfg(test)] mod tests { use super::*; - + #[cfg(feature = "accountable")] const STATUSES: [TowerStatus; 5] = [ TowerStatus::Reachable, TowerStatus::TemporaryUnreachable, @@ -298,7 +298,13 @@ mod tests { TowerStatus::SubscriptionError, TowerStatus::Misbehaving, ]; - + #[cfg(not(feature = "accountable"))] + const STATUSES: [TowerStatus; 4] = [ + TowerStatus::Reachable, + TowerStatus::TemporaryUnreachable, + TowerStatus::Unreachable, + TowerStatus::SubscriptionError, + ]; const AVAILABLE_SLOTS: u32 = 21; const SUBSCRIPTION_START: u32 = 100; const SUBSCRIPTION_EXPIRY: u32 = SUBSCRIPTION_START + 42; @@ -341,6 +347,7 @@ mod tests { } #[test] + #[cfg(feature = "accountable")] fn test_is_misbehaving() { for status in STATUSES { if status == Misbehaving { @@ -461,7 +468,7 @@ mod tests { use super::*; use teos_common::test_utils::{generate_random_appointment, get_random_user_id}; - + #[cfg(feature = "accountable")] impl TowerInfo { pub fn empty( net_addr: String, @@ -480,8 +487,28 @@ mod tests { ) } } + #[cfg(not(feature = "accountable"))] + impl TowerInfo { + pub fn empty( + net_addr: String, + available_slots: u32, + subscription_start: u32, + subscription_expiry: u32, + ) -> Self { + TowerInfo::new( + net_addr, + available_slots, + subscription_start, + subscription_expiry, + Vec::new(), + Vec::new(), + Vec::new(), + ) + } + } #[test] + #[cfg(feature = "accountable")] fn test_new() { let tower_info = TowerInfo::new( "addr".to_owned(), @@ -494,6 +521,23 @@ mod tests { ); assert!(tower_info.status.is_reachable()); + #[cfg(feature = "accountable")] + assert!(tower_info.misbehaving_proof.is_none()); + } + #[cfg(not(feature = "accountable"))] + fn test_new() { + let tower_info = TowerInfo::new( + "addr".to_owned(), + AVAILABLE_SLOTS, + SUBSCRIPTION_START, + SUBSCRIPTION_EXPIRY, + Vec::new(), + Vec::new(), + Vec::new(), + ); + + assert!(tower_info.status.is_reachable()); + #[cfg(feature = "accountable")] assert!(tower_info.misbehaving_proof.is_none()); } @@ -510,7 +554,7 @@ mod tests { tower_info.status = TowerStatus::Unreachable; assert_eq!(unreachable_tower, tower_info); } - + #[cfg(feature = "accountable")] #[test] fn test_set_misbehaving_proof() { let mut tower_info = TowerInfo::empty( diff --git a/watchtower-plugin/src/net/http.rs b/watchtower-plugin/src/net/http.rs index 6a882239..bc25d9e4 100644 --- a/watchtower-plugin/src/net/http.rs +++ b/watchtower-plugin/src/net/http.rs @@ -435,10 +435,14 @@ mod tests { // in case there are no errors. All the error cases will be tested in `send_appointment`. let (tower_sk, tower_pk) = cryptography::get_random_keypair(); let appointment = generate_random_appointment(None); - + #[cfg(feature = "accountable")] let appointment_receipt = get_random_appointment_receipt(tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response(appointment.locator, &appointment_receipt); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = + get_dummy_add_appointment_response(appointment.locator); let mut server = mockito::Server::new_async().await; let api_mock = server @@ -448,7 +452,7 @@ mod tests { .with_body(json!(add_appointment_response).to_string()) .create_async() .await; - + #[cfg(feature = "accountable")] let (response, receipt) = add_appointment( TowerId(tower_pk), &NetAddr::new(server.url()), @@ -458,9 +462,20 @@ mod tests { ) .await .unwrap(); + #[cfg(not(feature = "accountable"))] + let (response) = add_appointment( + TowerId(tower_pk), + &NetAddr::new(server.url()), + &None, + &appointment, + "None" + ) + .await + .unwrap(); api_mock.assert_async().await; assert_eq!(response, add_appointment_response.available_slots); + #[cfg(feature = "accountable")] assert_eq!(receipt, appointment_receipt); } @@ -468,10 +483,14 @@ mod tests { async fn test_send_appointment() { let (tower_sk, tower_pk) = cryptography::get_random_keypair(); let appointment = generate_random_appointment(None); - + #[cfg(feature = "accountable")] let appointment_receipt = get_random_appointment_receipt(tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response(appointment.locator, &appointment_receipt); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = + get_dummy_add_appointment_response(appointment.locator); let mut server = mockito::Server::new_async().await; let api_mock = server @@ -481,7 +500,7 @@ mod tests { .with_body(json!(add_appointment_response).to_string()) .create_async() .await; - + #[cfg(feature = "accountable")] let (response, receipt) = send_appointment( TowerId(tower_pk), &NetAddr::new(server.url()), @@ -491,9 +510,20 @@ mod tests { ) .await .unwrap(); + #[cfg(not(feature = "accountable"))] + let (response) = send_appointment( + TowerId(tower_pk), + &NetAddr::new(server.url()), + &None, + &appointment, + "None", + ) + .await + .unwrap(); api_mock.assert_async().await; assert_eq!(response, add_appointment_response); + #[cfg(feature = "accountable")] assert_eq!(receipt, appointment_receipt); } @@ -502,9 +532,14 @@ mod tests { let (sybil_tower_sk, sibyl_tower_pk) = cryptography::get_random_keypair(); let appointment = generate_random_appointment(None); - let appointment_receipt = get_random_appointment_receipt(sybil_tower_sk); + #[cfg(feature = "accountable")] + let appointment_receipt = get_random_appointment_receipt(tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response(appointment.locator, &appointment_receipt); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = + get_dummy_add_appointment_response(appointment.locator); let mut server = mockito::Server::new_async().await; let api_mock = server @@ -521,12 +556,13 @@ mod tests { &NetAddr::new(server.url()), &None, &appointment, - appointment_receipt.user_signature(), + "None", ) .await .unwrap_err(); api_mock.assert_async().await; + #[cfg(feature = "accountable")] if let AddAppointmentError::SignatureError(proof) = error { assert_eq!( MisbehaviorProof::new( diff --git a/watchtower-plugin/src/retrier.rs b/watchtower-plugin/src/retrier.rs index 11eba23a..564be530 100644 --- a/watchtower-plugin/src/retrier.rs +++ b/watchtower-plugin/src/retrier.rs @@ -657,18 +657,23 @@ mod tests { // Add appointment to pending let appointment = generate_random_appointment(None); wt_client.lock().unwrap().add_pending_appointment(tower_id, &appointment); - + #[cfg(not(feature = "accountable"))] // Prepare the mock response let mut add_appointment_receipt = AppointmentReceipt::new( cryptography::sign(&appointment.to_vec(), &wt_client.lock().unwrap().user_sk).unwrap(), 42 ); + #[cfg(not(feature = "accountable"))] add_appointment_receipt.sign(&tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); - + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -774,11 +779,23 @@ mod tests { cryptography::sign(&appointment.to_vec(), &wt_client.lock().unwrap().user_sk).unwrap(), 42 ); + #[cfg(not(feature = "accountable"))] + // Prepare the mock response + let mut add_appointment_receipt = AppointmentReceipt::new( + cryptography::sign(&appointment.to_vec(), &wt_client.lock().unwrap().user_sk).unwrap(), + 42 + ); + #[cfg(not(feature = "accountable"))] add_appointment_receipt.sign(&tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -921,11 +938,23 @@ mod tests { 42 ); // Sign with a random key so it counts as misbehaving - add_appointment_receipt.sign(&cryptography::get_random_keypair().0); + #[cfg(not(feature = "accountable"))] + // Prepare the mock response + let mut add_appointment_receipt = AppointmentReceipt::new( + cryptography::sign(&appointment.to_vec(), &wt_client.lock().unwrap().user_sk).unwrap(), + 42 + ); + #[cfg(feature = "accountable")] + add_appointment_receipt.sign(&tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -958,6 +987,7 @@ mod tests { wait_until!(wt_client.lock().unwrap().get_retrier_status(&tower_id).is_none()); // The tower should have a misbehaving status. + #[cfg(feature = "accountable")] assert!(wt_client.lock().unwrap().get_tower_status(&tower_id).unwrap().is_misbehaving()); api_mock.assert_async().await; @@ -1039,11 +1069,17 @@ mod tests { cryptography::sign(&appointment.to_vec(), &wt_client.lock().unwrap().user_sk).unwrap(), 42 ); + #[cfg(feature = "accountable")] add_appointment_receipt.sign(&tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", mockito::Matcher::Any) @@ -1179,7 +1215,7 @@ mod tests { // Mock a proper response let mut server = mockito::Server::new_async().await; - + #[cfg(feature = "accountable")] let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -1188,12 +1224,13 @@ mod tests { let body = serde_json ::from_slice::(request.body().unwrap()) .unwrap(); - + let response = if body.appointment.unwrap().locator == appointment.locator.to_vec() { get_dummy_add_appointment_response(appointment.locator, &appointment_receipt) } else { get_dummy_add_appointment_response(appointment2.locator, &appointment2_receipt) }; + json!(response).to_string().into() }) .expect(2) @@ -1217,6 +1254,7 @@ mod tests { assert!( wt_client.lock().unwrap().towers.get(&tower_id).unwrap().pending_appointments.is_empty() ); + #[cfg(feature = "accountable")] api_mock.assert_async().await; task.abort(); @@ -1246,10 +1284,15 @@ mod tests { 42 ); add_appointment_receipt.sign(&tower_sk); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -1307,10 +1350,15 @@ mod tests { 42 ); add_appointment_receipt.sign(&cryptography::get_random_keypair().0); + #[cfg(feature = "accountable")] let add_appointment_response = get_dummy_add_appointment_response( appointment.locator, &add_appointment_receipt ); + #[cfg(not(feature = "accountable"))] + let add_appointment_response = get_dummy_add_appointment_response( + appointment.locator + ); let api_mock = server .mock("POST", Endpoint::AddAppointment.path().as_str()) .with_status(200) @@ -1321,6 +1369,7 @@ mod tests { // Since we are retrying manually, we need to add the data to pending appointments manually too let retrier = Retrier::new(wt_client, tower_id, HashSet::from([appointment.locator])); let r = retrier.run().await; + #[cfg(feature = "accountable")] assert!(matches!(r, Err(Error::Permanent(RetryError::Misbehaving { .. })))); api_mock.assert_async().await; } diff --git a/watchtower-plugin/src/test_utils.rs b/watchtower-plugin/src/test_utils.rs index c95936c1..71970265 100644 --- a/watchtower-plugin/src/test_utils.rs +++ b/watchtower-plugin/src/test_utils.rs @@ -5,7 +5,6 @@ use teos_common::receipts::AppointmentReceipt; #[cfg(feature = "accountable")] pub fn get_dummy_add_appointment_response( locator: Locator, - #[cfg(feature = "accountable")] receipt: &AppointmentReceipt ) -> common_msgs::AddAppointmentResponse { common_msgs::AddAppointmentResponse { @@ -16,3 +15,15 @@ pub fn get_dummy_add_appointment_response( subscription_expiry: 1000, } } +#[cfg(not(feature = "accountable"))] +pub fn get_dummy_add_appointment_response( + locator: Locator +) -> common_msgs::AddAppointmentResponse { + common_msgs::AddAppointmentResponse { + locator: locator.to_vec(), + start_block: 0, + signature: "None".to_string(), + available_slots: 21, + subscription_expiry: 1000, + } +} diff --git a/watchtower-plugin/src/wt_client.rs b/watchtower-plugin/src/wt_client.rs index 8684a0a8..e97a2078 100644 --- a/watchtower-plugin/src/wt_client.rs +++ b/watchtower-plugin/src/wt_client.rs @@ -335,9 +335,16 @@ mod tests { use tempdir::TempDir; use tokio::sync::mpsc::unbounded_channel; - + #[cfg(feature = "accountable")] use teos_common::test_utils::{ - generate_random_appointment, get_random_appointment_receipt, + generate_random_appointment, + get_random_appointment_receipt, + get_random_registration_receipt, get_random_user_id, + get_registration_receipt_from_previous, + }; + #[cfg(not(feature = "accountable"))] + use teos_common::test_utils::{ + generate_random_appointment, get_random_registration_receipt, get_random_user_id, get_registration_receipt_from_previous, }; @@ -425,6 +432,7 @@ mod tests { // Decrease the slots count (simulate exhaustion) and update with more than the current count it should work let locator = generate_random_appointment(None).locator; + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower_id, locator, @@ -482,6 +490,7 @@ mod tests { TowerStatus::TemporaryUnreachable, TowerStatus::Unreachable, TowerStatus::SubscriptionError, + #[cfg(feature = "accountable")] TowerStatus::Misbehaving, ] { wt_client.set_tower_status(tower_id, status); @@ -500,9 +509,11 @@ mod tests { let locator = generate_random_appointment(None).locator; let registration_receipt = get_random_registration_receipt(); + #[cfg(feature = "accountable")] let appointment_receipt = get_random_appointment_receipt(tower_sk); // If we call this on an unknown tower it will simply do nothing + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower_id, locator, @@ -512,6 +523,7 @@ mod tests { assert!(!wt_client.towers.contains_key(&tower_id)); // Add the tower to the state and try again + #[cfg(feature = "accountable")] let tower_info = TowerInfo::new( "talaia.watch".to_owned(), registration_receipt.available_slots(), @@ -521,9 +533,20 @@ mod tests { Vec::new(), Vec::new(), ); + #[cfg(not(feature = "accountable"))] + let tower_info = TowerInfo::new( + "talaia.watch".to_owned(), + registration_receipt.available_slots(), + registration_receipt.subscription_start(), + registration_receipt.subscription_expiry(), + Vec::new(), + Vec::new(), + Vec::new(), + ); wt_client .add_update_tower(tower_id, &tower_info.net_addr, ®istration_receipt) .unwrap(); + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower_id, locator, @@ -555,6 +578,7 @@ mod tests { assert!(!wt_client.towers.contains_key(&tower_id)); // Add the tower to the state and try again + #[cfg(feature = "accountable")] let tower_info = TowerInfo::new( "talaia.watch".to_owned(), registration_receipt.available_slots(), @@ -564,6 +588,16 @@ mod tests { vec![appointment.clone()], Vec::new(), ); + #[cfg(not(feature = "accountable"))] + let tower_info = TowerInfo::new( + "talaia.watch".to_owned(), + registration_receipt.available_slots(), + registration_receipt.subscription_start(), + registration_receipt.subscription_expiry(), + Vec::new(), + vec![appointment.clone()], + Vec::new(), + ); wt_client .add_update_tower(tower_id, &tower_info.net_addr, ®istration_receipt) @@ -629,14 +663,25 @@ mod tests { assert!(!wt_client.towers.contains_key(&tower_id)); // Add the tower to the state and try again + #[cfg(feature = "accountable")] let tower_info = TowerInfo::new( "talaia.watch".to_owned(), registration_receipt.available_slots(), registration_receipt.subscription_start(), registration_receipt.subscription_expiry(), HashMap::new(), + vec![appointment.clone()], + Vec::new(), + ); + #[cfg(not(feature = "accountable"))] + let tower_info = TowerInfo::new( + "talaia.watch".to_owned(), + registration_receipt.available_slots(), + registration_receipt.subscription_start(), + registration_receipt.subscription_expiry(), Vec::new(), vec![appointment.clone()], + Vec::new(), ); wt_client @@ -781,8 +826,11 @@ mod tests { // If we call this on an unknown tower it will simply do nothing let appointment = generate_random_appointment(None); + #[cfg(feature = "accountable")] let receipt = get_random_appointment_receipt(tower_sk); + #[cfg(feature = "accountable")] let proof = MisbehaviorProof::new(appointment.locator, receipt, get_random_user_id()); + #[cfg(feature = "accountable")] wt_client.flag_misbehaving_tower(tower_id, proof.clone()); assert!(!wt_client.towers.contains_key(&tower_id)); @@ -791,17 +839,22 @@ mod tests { wt_client .add_update_tower(tower_id, "talaia.watch", ®istration_receipt) .unwrap(); + #[cfg(feature = "accountable")] wt_client.flag_misbehaving_tower(tower_id, proof.clone()); // Check data in memory let tower_summary = wt_client.towers.get(&tower_id); assert!(tower_summary.is_some()); + #[cfg(feature = "accountable")] assert!(tower_summary.unwrap().status.is_misbehaving()); // Check data in DB let loaded_info = wt_client.load_tower_info(tower_id).unwrap(); + #[cfg(feature = "accountable")] assert!(loaded_info.status.is_misbehaving()); + #[cfg(feature = "accountable")] assert_eq!(loaded_info.misbehaving_proof, Some(proof)); + #[cfg(feature = "accountable")] assert!(loaded_info.appointments.contains_key(&appointment.locator)); } @@ -843,9 +896,11 @@ mod tests { let locator = generate_random_appointment(None).locator; let registration_receipt = get_random_registration_receipt(); + #[cfg(feature = "accountable")] let appointment_receipt = get_random_appointment_receipt(tower_sk); // If we call this on an unknown tower it will simply do nothing + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower_id, locator, @@ -885,15 +940,18 @@ mod tests { let locator = generate_random_appointment(None).locator; let registration_receipt = get_random_registration_receipt(); + #[cfg(feature = "accountable")] let appointment_receipt_1 = get_random_appointment_receipt(tower1_sk); + #[cfg(feature = "accountable")] let appointment_receipt_2 = get_random_appointment_receipt(tower2_sk); - + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower1_id, locator, registration_receipt.available_slots(), &appointment_receipt_1, ); + #[cfg(feature = "accountable")] wt_client.add_appointment_receipt( tower2_id, locator,