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 Jul 25, 2022
1 parent c5e792c commit 4c826d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
9 changes: 4 additions & 5 deletions aries_vcx/src/libindy/utils/signus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,17 @@ pub async fn get_verkey_from_ledger(did: &str) -> VcxResult<String> {

#[cfg(test)]
mod test {



use crate::libindy::utils::mocks::pool_mocks::PoolMocks;
use crate::libindy::utils::mocks::pool_mocks::{enable_pool_mocks, PoolMocks};
use crate::utils::devsetup::*;
use crate::utils::mockdata::mockdata_pool;

use super::*;

#[tokio::test]
async fn test_rotate_verkey_fails() {
let setup = SetupPoolMocks::init().await;
let setup = SetupInstitutionWallet::init().await;
enable_pool_mocks();

let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();
PoolMocks::set_next_pool_response(mockdata_pool::RESPONSE_REQNACK);
PoolMocks::set_next_pool_response(mockdata_pool::NYM_REQUEST_VALID);
Expand Down
44 changes: 23 additions & 21 deletions aries_vcx/src/utils/devsetup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ pub struct SetupMocks;

pub struct SetupIndyMocks;

pub struct SetupPoolMocks {
pub wallet_handle: WalletHandle,
}

pub struct TestSetupCreateWallet {
pub wallet_config: WalletConfig,
skip_cleanup: bool,
Expand All @@ -62,6 +58,11 @@ pub struct SetupWalletPool {
pub wallet_handle: WalletHandle,
}

pub struct SetupInstitutionWallet {
pub institution_did: String,
pub wallet_handle: WalletHandle,
}

pub struct SetupLibraryAgencyV2;

fn reset_global_state() {
Expand Down Expand Up @@ -217,23 +218,6 @@ impl Drop for SetupPoolConfig {
}
}

impl SetupPoolMocks {
pub async fn init() -> SetupPoolMocks {
init_test_logging();
let (_issuer_did, wallet_handle, _agency_client) = setup_issuer_wallet_and_agency_client().await;
enable_pool_mocks();
SetupPoolMocks {
wallet_handle
}
}
}

impl Drop for SetupPoolMocks {
fn drop(&mut self) {
reset_global_state();
}
}

impl SetupIndyMocks {
pub fn init() -> SetupIndyMocks {
init_test_logging();
Expand Down Expand Up @@ -292,6 +276,24 @@ impl Drop for SetupWalletPool {
}
}

impl SetupInstitutionWallet {
pub async fn init() -> SetupInstitutionWallet {
init_test_logging();
set_test_configs();
let (institution_did, wallet_handle) = setup_issuer_wallet().await;
SetupInstitutionWallet {
institution_did,
wallet_handle,
}
}
}

impl Drop for SetupInstitutionWallet {
fn drop(&mut self) {
reset_global_state();
}
}

impl SetupLibraryAgencyV2 {
pub async fn init() -> SetupLibraryAgencyV2 {
debug!("SetupLibraryAgencyV2 init >> going to setup agency environment");
Expand Down
2 changes: 1 addition & 1 deletion libvcx/src/api_lib/api_handle/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub async fn create_and_publish_schema(source_id: &str,

let (schema_id, schema) = anoncreds::create_schema(&name, &version, &data).await?;
anoncreds::publish_schema(get_main_wallet_handle(), &schema).await?;
std::thread::sleep(std::time::Duration::from_millis(100));

debug!("created schema on ledger with id: {}", schema_id);

let schema_handle = _store_schema(source_id, name, version, schema_id, data, PublicEntityStateType::Published)?;

Ok(schema_handle)
Expand Down

0 comments on commit 4c826d4

Please sign in to comment.