Skip to content

Commit

Permalink
refactor: move MockWallet to test_utils, closes #1111 (#1114)
Browse files Browse the repository at this point in the history
* refactor: move MockWallet to test_utils, closes #1111

Signed-off-by: Ondrej Prazak <[email protected]>
  • Loading branch information
xprazak2 authored Feb 16, 2024
1 parent ec0df29 commit cb28bad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
3 changes: 1 addition & 2 deletions aries/aries_vcx/src/protocols/connection/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ impl GenericConnection {
/// of the [`crate::protocols::connection::Connection`], if modified, will be modified together.
#[cfg(test)]
mod connection_serde_tests {
use aries_vcx_core::wallet::mock_wallet::MockWallet;
use async_trait::async_trait;
use chrono::Utc;
use messages::{
Expand All @@ -230,7 +229,7 @@ mod connection_serde_tests {
notification::ack::{Ack, AckContent, AckDecorators, AckStatus},
},
};
use test_utils::mockdata::mock_ledger::MockLedger;
use test_utils::{mock_wallet::MockWallet, mockdata::mock_ledger::MockLedger};
use url::Url;
use uuid::Uuid;

Expand Down
1 change: 0 additions & 1 deletion aries/aries_vcx_core/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ pub mod agency_client_wallet;
pub mod base_wallet;
#[cfg(feature = "vdrtools_wallet")]
pub mod indy;
pub mod mock_wallet;
pub mod record_tags;
pub mod structs_io;
2 changes: 1 addition & 1 deletion aries/misc/legacy/libvcx_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ wallet_migrator = { path = "../../wallet_migrator" }
shared = { path = "../../shared" }

[dev-dependencies]
test_utils = {path = "../../test_utils" }
test_utils = {path = "../../test_utils", features = ["vdrtools_wallet"] }
tokio = { version = "1.20", features = [ "rt", "macros" ] }
5 changes: 2 additions & 3 deletions aries/misc/test_utils/src/devsetup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::constants::{POOL1_TXN, TRUSTEE_SEED};

#[cfg(feature = "vdr_proxy_ledger")]
pub mod vdr_proxy_ledger;

#[cfg(feature = "vdr_proxy_ledger")]
use crate::devsetup::vdr_proxy_ledger::dev_build_profile_vdr_proxy_ledger;

Expand Down Expand Up @@ -216,9 +217,7 @@ pub async fn dev_build_featured_wallet(key_seed: &str) -> (String, impl BaseWall

#[cfg(not(feature = "vdrtools_wallet"))]
{
use aries_vcx_core::wallet::mock_wallet::MockWallet;

use crate::constants::INSTITUTION_DID;
use crate::{constants::INSTITUTION_DID, mock_wallet::MockWallet};

return (INSTITUTION_DID.to_owned(), MockWallet);
}
Expand Down
2 changes: 2 additions & 0 deletions aries/misc/test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ pub mod mockdata;
pub mod random;
#[rustfmt::skip]
pub mod constants;

pub mod mock_wallet;
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
use async_trait::async_trait;
use public_key::{Key, KeyType};

use super::{
base_wallet::{
did_data::DidData, record::Record, search_filter::SearchFilter, BaseWallet, DidWallet,
RecordWallet,
},
record_tags::RecordTags,
structs_io::UnpackMessageOutput,
};
use crate::{
use aries_vcx_core::{
errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult},
utils::{self},
wallet::{
base_wallet::{
did_data::DidData, record::Record, search_filter::SearchFilter, BaseWallet, DidWallet,
RecordWallet,
},
record_tags::RecordTags,
structs_io::UnpackMessageOutput,
},
};
use async_trait::async_trait;
use public_key::{Key, KeyType};

#[derive(Debug)]
pub struct MockWallet;

impl BaseWallet for MockWallet {}

pub const DID: &str = "FhrSrYtQcw3p9xwf7NYemf";
pub const VERKEY: &str = "91qMFrZjXDoi2Vc8Mm14Ys112tEZdDegBZZoembFEATE";

#[async_trait]
#[allow(unused_variables)]
impl RecordWallet for MockWallet {
Expand Down Expand Up @@ -77,17 +78,17 @@ impl DidWallet for MockWallet {
method_name: Option<&str>,
) -> VcxCoreResult<DidData> {
Ok(DidData::new(
utils::constants::DID,
Key::new(utils::constants::VERKEY.into(), KeyType::Ed25519).unwrap(),
DID,
Key::new(VERKEY.into(), KeyType::Ed25519).unwrap(),
))
}

async fn key_for_did(&self, name: &str) -> VcxCoreResult<Key> {
Ok(Key::new(utils::constants::VERKEY.into(), KeyType::Ed25519).unwrap())
Ok(Key::new(VERKEY.into(), KeyType::Ed25519).unwrap())
}

async fn replace_did_key_start(&self, did: &str, seed: Option<&str>) -> VcxCoreResult<Key> {
Ok(Key::new(utils::constants::VERKEY.into(), KeyType::Ed25519).unwrap())
Ok(Key::new(VERKEY.into(), KeyType::Ed25519).unwrap())
}

async fn replace_did_key_apply(&self, did: &str) -> VcxCoreResult<()> {
Expand Down

0 comments on commit cb28bad

Please sign in to comment.