diff --git a/aries_vcx/src/common/proofs/prover/prover_internal.rs b/aries_vcx/src/common/proofs/prover/prover_internal.rs index f6fb9a53e6..72b0e3cc10 100644 --- a/aries_vcx/src/common/proofs/prover/prover_internal.rs +++ b/aries_vcx/src/common/proofs/prover/prover_internal.rs @@ -276,47 +276,50 @@ pub fn build_requested_credentials_json( #[cfg(test)] pub mod pool_tests { + use std::error::Error; + use aries_vcx_core::ledger::indy::pool::test_utils::get_temp_dir_path; use test_utils::{ constants::{CRED_DEF_ID, CRED_REV_ID, LICENCE_CRED_ID, SCHEMA_ID}, - run_setup_test, + devsetup::build_setup_profile, }; use crate::common::proofs::prover::prover_internal::{build_rev_states_json, CredInfoProver}; #[tokio::test] #[ignore] - async fn test_pool_build_rev_states_json_empty() { - run_setup_test!(|setup| async move { - // empty vector - assert_eq!( - build_rev_states_json(&setup.ledger_read, &setup.anoncreds, Vec::new().as_mut()) - .await - .unwrap(), - "{}".to_string() - ); - - // no rev_reg_id - let cred1 = CredInfoProver { - referent: "height_1".to_string(), - credential_referent: LICENCE_CRED_ID.to_string(), - schema_id: SCHEMA_ID.to_string(), - cred_def_id: CRED_DEF_ID.to_string(), - rev_reg_id: None, - cred_rev_id: Some(CRED_REV_ID.to_string()), - tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()), - revocation_interval: None, - timestamp: None, - revealed: None, - }; - assert_eq!( - build_rev_states_json(&setup.ledger_read, &setup.anoncreds, vec![cred1].as_mut()) - .await - .unwrap(), - "{}".to_string() - ); - }) - .await; + async fn test_pool_build_rev_states_json_empty() -> Result<(), Box> { + let setup = build_setup_profile().await; + let mut empty_credential_identifiers = Vec::new(); + assert_eq!( + build_rev_states_json( + &setup.ledger_read, + &setup.anoncreds, + empty_credential_identifiers.as_mut() + ) + .await?, + "{}".to_string() + ); + + // no rev_reg_id + let cred1 = CredInfoProver { + referent: "height_1".to_string(), + credential_referent: LICENCE_CRED_ID.to_string(), + schema_id: SCHEMA_ID.to_string(), + cred_def_id: CRED_DEF_ID.to_string(), + rev_reg_id: None, + cred_rev_id: Some(CRED_REV_ID.to_string()), + tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()), + revocation_interval: None, + timestamp: None, + revealed: None, + }; + assert_eq!( + build_rev_states_json(&setup.ledger_read, &setup.anoncreds, vec![cred1].as_mut()) + .await?, + "{}".to_string() + ); + Ok(()) } } @@ -546,7 +549,7 @@ pub mod unit_tests { assert_eq!( credential_def_identifiers( &serde_json::from_str("{}").unwrap(), - &proof_req_no_interval() + &proof_req_no_interval(), ) .unwrap(), Vec::new() @@ -554,7 +557,7 @@ pub mod unit_tests { assert_eq!( credential_def_identifiers( &serde_json::from_str(r#"{"attrs":{}}"#).unwrap(), - &proof_req_no_interval() + &proof_req_no_interval(), ) .unwrap(), Vec::new() @@ -598,7 +601,7 @@ pub mod unit_tests { assert_eq!( &credential_def_identifiers( &serde_json::from_value(selected_credentials.clone()).unwrap(), - &proof_req_no_interval() + &proof_req_no_interval(), ) .unwrap(), &creds @@ -610,7 +613,7 @@ pub mod unit_tests { assert_eq!( &credential_def_identifiers( &serde_json::from_value(selected_credentials).unwrap(), - &proof_req_no_interval() + &proof_req_no_interval(), ) .unwrap(), &creds diff --git a/did_resolver_sov/tests/resolution.rs b/did_resolver_sov/tests/resolution.rs index 135d88ad7a..98acb4ff86 100644 --- a/did_resolver_sov/tests/resolution.rs +++ b/did_resolver_sov/tests/resolution.rs @@ -10,7 +10,7 @@ use did_resolver::{ traits::resolvable::{resolution_options::DidResolutionOptions, DidResolvable}, }; use did_resolver_sov::resolution::DidSovResolver; -use test_utils::run_setup_test; +use test_utils::devsetup::build_setup_profile; async fn write_test_endpoint( wallet: &impl BaseWallet, @@ -29,37 +29,39 @@ async fn write_test_endpoint( #[tokio::test] async fn write_service_on_ledger_and_resolve_did_doc() { - run_setup_test!(|init| async move { - let did = format!("did:sov:{}", init.institution_did); - write_test_endpoint(&init.wallet, &init.ledger_write, &init.institution_did).await; - let resolver = DidSovResolver::new(&init.ledger_read); - let did_doc = resolver - .resolve( - &Did::parse(did.clone()).unwrap(), - &DidResolutionOptions::default(), - ) - .await - .unwrap(); - assert_eq!(did_doc.did_document().id().to_string(), did); - }) + let profile = build_setup_profile().await; + write_test_endpoint( + &profile.wallet, + &profile.ledger_write, + &profile.institution_did, + ) .await; + let resolver = DidSovResolver::new(&profile.ledger_read); + let did = format!("did:sov:{}", profile.institution_did); + + let did_doc = resolver + .resolve( + &Did::parse(did.clone()).unwrap(), + &DidResolutionOptions::default(), + ) + .await + .unwrap(); + + assert_eq!(did_doc.did_document().id().to_string(), did); } #[tokio::test] async fn test_error_handling_during_resolution() { - run_setup_test!(|init| async move { - let did = format!("did:unknownmethod:{}", init.institution_did); - - let resolver = DidSovResolver::new(&init.ledger_read); + let profile = build_setup_profile().await; + let resolver = DidSovResolver::new(&profile.ledger_read); + let did = format!("did:unknownmethod:{}", profile.institution_did); - let result = resolver - .resolve( - &Did::parse(did.clone()).unwrap(), - &DidResolutionOptions::default(), - ) - .await; + let result = resolver + .resolve( + &Did::parse(did.clone()).unwrap(), + &DidResolutionOptions::default(), + ) + .await; - assert!(result.is_err()); - }) - .await; + assert!(result.is_err()); } diff --git a/tools/test_utils/src/devsetup.rs b/tools/test_utils/src/devsetup.rs index 446db27f86..27decd4efc 100644 --- a/tools/test_utils/src/devsetup.rs +++ b/tools/test_utils/src/devsetup.rs @@ -293,13 +293,6 @@ pub async fn dev_build_featured_wallet(key_seed: &str) -> (String, impl BaseWall return (INSTITUTION_DID.to_owned(), MockWallet); } -#[macro_export] -macro_rules! run_setup_test { - ($func:expr) => {{ - $crate::devsetup::build_setup_profile().await.run($func) - }}; -} - pub async fn build_setup_profile() -> SetupProfile< impl IndyLedgerRead + AnoncredsLedgerRead, impl IndyLedgerWrite + AnoncredsLedgerWrite, @@ -338,21 +331,6 @@ pub async fn build_setup_profile() -> SetupProfile< } } -impl SetupProfile -where - LR: IndyLedgerRead + AnoncredsLedgerRead, - LW: IndyLedgerWrite + AnoncredsLedgerWrite, - A: BaseAnonCreds, - W: BaseWallet, -{ - pub async fn run(self, f: impl FnOnce(Self) -> F) - where - F: Future, - { - f(self).await; - } -} - impl SetupPoolDirectory { pub async fn init() -> SetupPoolDirectory { debug!("SetupPoolDirectory init >> going to setup agency environment"); @@ -364,17 +342,6 @@ impl SetupPoolDirectory { debug!("SetupPoolDirectory init >> completed"); SetupPoolDirectory { genesis_file_path } } - - pub async fn run(f: impl FnOnce(Self) -> F) - where - F: Future, - { - let init = Self::init().await; - - f(init).await; - - reset_global_state(); - } } pub struct TempFile {