From 7fb7b6fa6e72c6ac5aff8c61af75791aab49f572 Mon Sep 17 00:00:00 2001 From: Patrik Stas Date: Wed, 22 Feb 2023 10:58:03 +0100 Subject: [PATCH] Fix tests Signed-off-by: Patrik Stas --- libvcx_core/src/api_vcx/api_global/state.rs | 2 +- libvcx_core/src/api_vcx/api_handle/credential.rs | 8 ++++++-- .../src/api_vcx/api_handle/credential_def.rs | 4 ++-- .../src/api_vcx/api_handle/disclosed_proof.rs | 15 +++++++++------ .../src/api_vcx/api_handle/issuer_credential.rs | 2 +- .../src/api_vcx/api_handle/mediated_connection.rs | 3 ++- libvcx_core/src/api_vcx/api_handle/proof.rs | 2 +- libvcx_core/src/api_vcx/api_handle/schema.rs | 4 ++-- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/libvcx_core/src/api_vcx/api_global/state.rs b/libvcx_core/src/api_vcx/api_global/state.rs index 1fe7a1964b..50a289e59e 100644 --- a/libvcx_core/src/api_vcx/api_global/state.rs +++ b/libvcx_core/src/api_vcx/api_global/state.rs @@ -75,7 +75,7 @@ pub mod tests { let _setup = SetupMocks::init(); let data = r#"["name","male"]"#; - let connection = mediated_connection::tests::build_test_connection_inviter_invited().await; + let connection = mediated_connection::test_utils::build_test_connection_inviter_invited().await; let credentialdef = credential_def::create("SID".to_string(), "id".to_string(), "tag".to_string(), false) .await .unwrap(); diff --git a/libvcx_core/src/api_vcx/api_handle/credential.rs b/libvcx_core/src/api_vcx/api_handle/credential.rs index 7a51e1334d..2df94016c6 100644 --- a/libvcx_core/src/api_vcx/api_handle/credential.rs +++ b/libvcx_core/src/api_vcx/api_handle/credential.rs @@ -352,10 +352,14 @@ pub mod tests { ARIES_CREDENTIAL_OFFER, ARIES_CREDENTIAL_OFFER_JSON_FORMAT, ARIES_CREDENTIAL_RESPONSE, CREDENTIAL_SM_FINISHED, }; + use crate::api_vcx::api_handle::credential::tests_utils::BAD_CREDENTIAL_OFFER; use crate::api_vcx::api_handle::credential::{ credential_create_with_offer, get_attributes, get_credential, send_credential_request, }; use crate::api_vcx::api_handle::mediated_connection; + use crate::api_vcx::api_handle::mediated_connection::test_utils::{ + build_test_connection_invitee_completed, build_test_connection_inviter_requested, + }; use crate::aries_vcx::messages::protocols::issuance::credential::Credential; use super::*; @@ -431,7 +435,7 @@ pub mod tests { let _setup = SetupMocks::init(); info!("full_credential_test:: going to build_test_connection"); - let handle_conn = mediated_connection::tests::build_test_connection_inviter_requested().await; + let handle_conn = build_test_connection_inviter_requested().await; info!("full_credential_test:: going to _get_offer"); let offer = _get_offer(handle_conn).await; @@ -499,7 +503,7 @@ pub mod tests { async fn test_get_credential_offer() { let _setup = SetupMocks::init(); - let connection_h = mediated_connection::tests::build_test_connection_invitee_completed(); + let connection_h = build_test_connection_invitee_completed(); let offer = get_credential_offer_messages_with_conn_handle(connection_h) .await diff --git a/libvcx_core/src/api_vcx/api_handle/credential_def.rs b/libvcx_core/src/api_vcx/api_handle/credential_def.rs index a2fc279cfd..6496ee9749 100644 --- a/libvcx_core/src/api_vcx/api_handle/credential_def.rs +++ b/libvcx_core/src/api_vcx/api_handle/credential_def.rs @@ -122,7 +122,7 @@ pub mod tests { #[cfg(feature = "general_test")] async fn test_vcx_credentialdef_release() { let _setup = SetupMocks::init(); - let schema_handle = schema::tests::create_schema_real().await; + let schema_handle = schema::test_utils::create_schema_real().await; sleep(Duration::from_secs(1)); let schema_id = schema::get_schema_id(schema_handle).unwrap(); @@ -138,7 +138,7 @@ pub mod tests { } pub async fn create_and_publish_nonrevocable_creddef() -> (u32, u32) { - let schema_handle = schema::tests::create_schema_real().await; + let schema_handle = schema::test_utils::create_schema_real().await; sleep(Duration::from_secs(1)); let schema_id = schema::get_schema_id(schema_handle).unwrap(); diff --git a/libvcx_core/src/api_vcx/api_handle/disclosed_proof.rs b/libvcx_core/src/api_vcx/api_handle/disclosed_proof.rs index d41647584d..40a9d45b34 100644 --- a/libvcx_core/src/api_vcx/api_handle/disclosed_proof.rs +++ b/libvcx_core/src/api_vcx/api_handle/disclosed_proof.rs @@ -292,6 +292,9 @@ mod tests { use serde_json::Value; + use crate::api_vcx::api_handle::mediated_connection::test_utils::{ + build_test_connection_invitee_completed, build_test_connection_inviter_requested, + }; use aries_vcx::utils; use aries_vcx::utils::constants::{ ARIES_PROVER_CREDENTIALS, ARIES_PROVER_SELF_ATTESTED_ATTRS, GET_MESSAGES_DECRYPTED_RESPONSE, @@ -346,7 +349,7 @@ mod tests { async fn test_proof_cycle() { let _setup = SetupMocks::init(); - let connection_h = mediated_connection::tests::build_test_connection_inviter_requested().await; + let connection_h = build_test_connection_inviter_requested().await; AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(ARIES_PROOF_REQUEST_PRESENTATION); @@ -378,7 +381,7 @@ mod tests { async fn test_proof_update_state_v2() { let _setup = SetupMocks::init(); - let connection_handle = mediated_connection::tests::build_test_connection_inviter_requested().await; + let connection_handle = build_test_connection_inviter_requested().await; AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(mockdata_proof::ARIES_PRESENTATION_REQUEST); @@ -400,7 +403,7 @@ mod tests { assert_eq!(ProverState::PresentationSent as u32, get_state(handle).unwrap()); mediated_connection::release(connection_handle).unwrap(); - let connection_handle = mediated_connection::tests::build_test_connection_inviter_requested().await; + let connection_handle = build_test_connection_inviter_requested().await; AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(mockdata_proof::ARIES_PROOF_PRESENTATION_ACK); @@ -414,7 +417,7 @@ mod tests { async fn test_proof_reject_cycle() { let _setup = SetupMocks::init(); - let connection_h = mediated_connection::tests::build_test_connection_inviter_requested().await; + let connection_h = build_test_connection_inviter_requested().await; AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(ARIES_PROOF_REQUEST_PRESENTATION); @@ -471,7 +474,7 @@ mod tests { async fn test_get_proof_request() { let _setup = SetupMocks::init(); - let connection_h = mediated_connection::tests::build_test_connection_invitee_completed(); + let connection_h = build_test_connection_invitee_completed(); let request = get_proof_request(connection_h, "123").await.unwrap(); let _request: PresentationRequest = serde_json::from_str(&request).unwrap(); @@ -493,7 +496,7 @@ mod tests { async fn test_get_proof_request_attachment() { let _setup = SetupMocks::init(); - let connection_h = mediated_connection::tests::build_test_connection_inviter_requested().await; + let connection_h = build_test_connection_inviter_requested().await; AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(ARIES_PROOF_REQUEST_PRESENTATION); diff --git a/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs b/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs index f2c511ac7e..e9c4d4f372 100644 --- a/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs +++ b/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs @@ -283,7 +283,7 @@ pub mod tests { use crate::api_vcx::api_handle::credential_def::tests::create_and_publish_nonrevocable_creddef; use crate::api_vcx::api_handle::issuer_credential; - use crate::api_vcx::api_handle::mediated_connection::tests::build_test_connection_inviter_requested; + use crate::api_vcx::api_handle::mediated_connection::test_utils::build_test_connection_inviter_requested; use crate::aries_vcx::protocols::issuance::issuer::state_machine::IssuerState; use crate::errors::error; diff --git a/libvcx_core/src/api_vcx/api_handle/mediated_connection.rs b/libvcx_core/src/api_vcx/api_handle/mediated_connection.rs index 52db7d6150..3b99c9100f 100644 --- a/libvcx_core/src/api_vcx/api_handle/mediated_connection.rs +++ b/libvcx_core/src/api_vcx/api_handle/mediated_connection.rs @@ -487,6 +487,7 @@ pub mod tests { }; use crate::api_vcx::api_handle::mediated_connection; + use crate::api_vcx::api_handle::mediated_connection::test_utils::build_test_connection_inviter_invited; use crate::api_vcx::VcxStateType; use super::*; @@ -717,7 +718,7 @@ pub mod tests { async fn test_send_generic_message_fails_with_invalid_connection() { let _setup = SetupMocks::init(); - let handle = mediated_connection::tests::build_test_connection_inviter_invited().await; + let handle = build_test_connection_inviter_invited().await; let err = send_generic_message(handle, "this is the message").await.unwrap_err(); assert_eq!(err.kind(), LibvcxErrorKind::NotReady); diff --git a/libvcx_core/src/api_vcx/api_handle/proof.rs b/libvcx_core/src/api_vcx/api_handle/proof.rs index 884d1fe1a3..649487b15c 100644 --- a/libvcx_core/src/api_vcx/api_handle/proof.rs +++ b/libvcx_core/src/api_vcx/api_handle/proof.rs @@ -224,7 +224,7 @@ pub mod tests { use aries_vcx::utils::mockdata::mock_settings::MockBuilder; use aries_vcx::utils::mockdata::mockdata_proof; - use crate::api_vcx::api_handle::mediated_connection::tests::build_test_connection_inviter_requested; + use crate::api_vcx::api_handle::mediated_connection::test_utils::build_test_connection_inviter_requested; use crate::api_vcx::api_handle::proof; use crate::aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState; use crate::errors::error; diff --git a/libvcx_core/src/api_vcx/api_handle/schema.rs b/libvcx_core/src/api_vcx/api_handle/schema.rs index c5c68a36f3..d1ee8f241d 100644 --- a/libvcx_core/src/api_vcx/api_handle/schema.rs +++ b/libvcx_core/src/api_vcx/api_handle/schema.rs @@ -197,7 +197,7 @@ pub mod test_utils { .unwrap() } - fn check_schema(schema_handle: u32, schema_json: &str, schema_id: &str, data: &str) { + pub fn check_schema(schema_handle: u32, schema_json: &str, schema_id: &str, data: &str) { let schema: Schema = Schema::from_string_versioned(schema_json).unwrap(); assert_eq!(schema.schema_id, schema_id.to_string()); assert_eq!(schema.data.clone().sort(), vec!(data).sort()); @@ -233,7 +233,7 @@ pub mod tests { use crate::api_vcx::api_global::wallet::get_main_wallet_handle; #[cfg(feature = "pool_tests")] use crate::api_vcx::api_handle::schema; - use crate::api_vcx::api_handle::schema::test_utils::{create_schema_real, prepare_schema_data}; + use crate::api_vcx::api_handle::schema::test_utils::{check_schema, create_schema_real, prepare_schema_data}; #[cfg(feature = "pool_tests")] use crate::api_vcx::utils::devsetup::SetupGlobalsWalletPoolAgency;