Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
  • Loading branch information
Patrik-Stas committed Feb 22, 2023
1 parent 8401829 commit 7fb7b6f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_global/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions libvcx_core/src/api_vcx/api_handle/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libvcx_core/src/api_vcx/api_handle/credential_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
15 changes: 9 additions & 6 deletions libvcx_core/src/api_vcx/api_handle/disclosed_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_handle/issuer_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion libvcx_core/src/api_vcx/api_handle/mediated_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_handle/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libvcx_core/src/api_vcx/api_handle/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 7fb7b6f

Please sign in to comment.