Skip to content

Commit

Permalink
Improve testing
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 4, 2023
1 parent 57c57e0 commit 276cab8
Show file tree
Hide file tree
Showing 112 changed files with 2,035 additions and 2,799 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ jobs:
uses: ./.github/actions/setup-codecov-rust
with:
skip-docker-setup: true
- name: "Run workspace tests: general_test"
- name: "Run aries-vcx unit tests"
run: |
RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
Expand Down Expand Up @@ -415,7 +415,7 @@ jobs:
uses: actions/checkout@v3
- name: "Setup rust codecov environment"
uses: ./.github/actions/setup-codecov-rust
- name: "Run workspace tests: pool_tests agency_pool_tests"
- name: "Run workspace tests: vdrtools profile"
run: |
RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
Expand All @@ -436,8 +436,7 @@ jobs:
name: code-coverage-report-unit-aries-vcx
path: /tmp/artifacts/coverage

#TODO - can this be included within code-coverage-aries-vcx-integration-tests?
code-coverage-aries-vcx-modular-dependencies-integration-tests:
code-coverage-aries-vcx-integration-modular-libs:
needs: workflow-setup
if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }}
runs-on: ubuntu-20.04
Expand All @@ -446,7 +445,7 @@ jobs:
uses: actions/checkout@v3
- name: "Setup rust codecov environment"
uses: ./.github/actions/setup-codecov-rust
- name: "Run workspace tests: modular_libs_tests pool_tests agency_pool_tests"
- name: "Run workspace tests: modular libs profile"
run: |
RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \
Expand Down Expand Up @@ -480,7 +479,7 @@ jobs:
uses: ./.github/actions/setup-testing-rust
with:
skip-docker-setup: true
- name: "Run workspace tests: general_test"
- name: "Run workspace unit tests"
run: RUST_TEST_THREADS=1 cargo test --workspace --lib --exclude aries-vcx-agent --exclude libvdrtools --exclude wallet_migrator

test-integration-aries-vcx:
Expand All @@ -491,8 +490,8 @@ jobs:
uses: actions/checkout@v3
- name: "Setup rust testing environment"
uses: ./.github/actions/setup-testing-rust
- name: "Run aries-vcx tests: pool_tests agency_pool_tests"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored;
- name: "Run aries-vcx integration tests"
run: RUST_LOG=trace RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored;

test-integration-aries-vcx-mysql:
needs: workflow-setup
Expand Down Expand Up @@ -526,7 +525,7 @@ jobs:
with:
skip-vdrproxy-setup: false
- name: "Run aries-vcx tests: vdrproxy_test"
run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger -- --ignored
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger -- --ignored
- name: "Collect docker logs on failure"
if: failure()
uses: ./.github/actions/upload-docker-logs
Expand All @@ -541,7 +540,7 @@ jobs:
uses: actions/checkout@v3
- name: "Setup rust testing environment"
uses: ./.github/actions/setup-testing-rust
- name: "Run aries-vcx tests: pool_tests agency_pool_tests"
- name: "Run aries-vcx integration tests"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F mixed_breed -- --include-ignored;

test-integration-aries-vcx-migration:
Expand All @@ -567,10 +566,10 @@ jobs:
uses: actions/checkout@v3
- name: "Setup rust testing environment"
uses: ./.github/actions/setup-testing-rust
- name: "Run libvcx tests: pool_tests"
- name: "Run libvcx integration tests"
run: |
RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -F "pool_tests";
RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx_core/Cargo.toml" -F "pool_tests";
RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -- --include-ignored;
RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx_core/Cargo.toml" -- --include-ignored;
test-integration-resolver:
needs: workflow-setup
Expand Down
4 changes: 2 additions & 2 deletions agents/rust/aries-vcx-agent/src/agent/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aries_vcx::{
utils::provision::provision_cloud_agent,
};
use aries_vcx_core::indy::{
ledger::pool::{create_pool_ledger_config, open_pool_ledger, PoolConfigBuilder},
ledger::pool::{create_pool_ledger_config, indy_open_pool, PoolConfigBuilder},
wallet::{create_wallet_with_master_secret, open_wallet, wallet_configure_issuer, WalletConfig},
};
use url::Url;
Expand Down Expand Up @@ -83,7 +83,7 @@ impl Agent {
&init_config.pool_config.genesis_path,
)
.unwrap();
let pool_handle = open_pool_ledger(&init_config.pool_config.pool_name, Some(pool_config))
let pool_handle = indy_open_pool(&init_config.pool_config.pool_name, pool_config.pool_config)
.await
.unwrap();

Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds;
use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use time::OffsetDateTime;

use crate::core::profile::profile::Profile;
use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};

use super::primitives::revocation_registry_delta::RevocationRegistryDelta;
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/common/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use aries_vcx_core::ledger::base_ledger::{IndyLedgerRead, IndyLedgerWrite};
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use serde_json::Value;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;

pub async fn rotate_verkey_apply(
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/common/ledger/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use aries_vcx_core::wallet::base_wallet::BaseWallet;
use serde_json::Value;

use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};
use crate::{common::keys::get_verkey_from_ledger, core::profile::profile::Profile, global::settings};
use crate::{common::keys::get_verkey_from_ledger, global::settings};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/common/primitives/credential_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};
use crate::utils::constants::{CRED_DEF_ID, CRED_DEF_JSON, DEFAULT_SERIALIZE_VERSION};
use crate::utils::serialization::ObjectWithVersion;

use crate::global::settings::{self, indy_mocks_enabled};
use crate::global::settings::indy_mocks_enabled;
use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds;
use std::fmt;
use std::sync::Arc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use std::sync::Arc;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;

#[derive(Clone, Deserialize, Debug, Serialize, Default)]
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/common/proofs/proof_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::vec::Vec;
use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds;
use serde_json;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;

use super::proof_request_internal::{AttrInfo, NonRevokedInterval, PredicateInfo};
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/common/proofs/prover/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::common::proofs::prover::prover_internal::{
build_cred_defs_json_prover, build_requested_credentials_json, build_rev_states_json, build_schemas_json_prover,
credential_def_identifiers,
};
use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::global::settings;
use crate::handlers::proof_presentation::types::SelectedCredentials;
Expand Down
58 changes: 1 addition & 57 deletions aries_vcx/src/common/proofs/prover/prover_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ use aries_vcx_core::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind};
use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use serde_json::Value;

use crate::common::proofs::{proof_request::ProofRequestData, proof_request_internal::NonRevokedInterval};
use crate::errors::error::prelude::*;
use crate::handlers::proof_presentation::types::SelectedCredentials;
use crate::{
common::proofs::{proof_request::ProofRequestData, proof_request_internal::NonRevokedInterval},
core::profile::profile::Profile,
};

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct CredInfoProver {
Expand Down Expand Up @@ -370,59 +367,6 @@ pub mod unit_tests {
assert!(credential_def.contains(r#""id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:47:tag1","schemaId":"47""#));
}

#[tokio::test]
async fn test_find_credential_def_fails() {
SetupLibraryWallet::run(|setup| async move {
let profile = Arc::new(VdrtoolsProfile::init(setup.wallet_handle, INVALID_POOL_HANDLE));
let credential_ids = vec![CredInfoProver {
referent: "1".to_string(),
credential_referent: "2".to_string(),
schema_id: "3".to_string(),
cred_def_id: "3".to_string(),
rev_reg_id: Some("4".to_string()),
cred_rev_id: Some("5".to_string()),
revocation_interval: None,
tails_file: None,
timestamp: None,
revealed: None,
}];
let err_kind = build_cred_defs_json_prover(&profile.inject_anoncreds_ledger_read(), &credential_ids)
.await
.unwrap_err()
.kind();
assert_eq!(err_kind, AriesVcxErrorKind::InvalidProofCredentialData);
})
.await;
}

#[tokio::test]
async fn test_find_schemas_fails() {
SetupLibraryWallet::run(|setup| async move {
let profile = Arc::new(VdrtoolsProfile::init(setup.wallet_handle, INVALID_POOL_HANDLE));
let credential_ids = vec![CredInfoProver {
referent: "1".to_string(),
credential_referent: "2".to_string(),
schema_id: "3".to_string(),
cred_def_id: "3".to_string(),
rev_reg_id: Some("4".to_string()),
cred_rev_id: Some("5".to_string()),
revocation_interval: None,
tails_file: None,
timestamp: None,
revealed: None,
}];

assert_eq!(
build_schemas_json_prover(&profile.inject_anoncreds_ledger_read(), &credential_ids)
.await
.unwrap_err()
.kind(),
AriesVcxErrorKind::InvalidSchema
);
})
.await;
}

#[tokio::test]
async fn test_find_schemas() {
let _setup = SetupMocks::init();
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/common/proofs/verifier/verifier_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use serde_json;
use serde_json::Value;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::global::settings;
use crate::utils::openssl::encode;
Expand Down
4 changes: 0 additions & 4 deletions aries_vcx/src/common/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ use std::thread;
use std::time::Duration;

use aries_vcx_core::wallet::base_wallet::BaseWallet;
use aries_vcx_core::PoolHandle;
use aries_vcx_core::WalletHandle;

use crate::common::credentials::encoding::encode_attributes;
use crate::common::primitives::credential_definition::CredentialDef;
use crate::common::primitives::credential_definition::CredentialDefConfigBuilder;
use crate::common::primitives::revocation_registry::RevocationRegistry;
use crate::core::profile::profile::Profile;
use crate::global::settings;
use crate::utils::constants::{DEFAULT_SCHEMA_ATTRS, TAILS_DIR, TEST_TAILS_URL, TRUSTEE_SEED};
use crate::utils::get_temp_dir_path;
use crate::utils::mockdata::profile::mock_profile::MockProfile;

pub async fn create_schema(
anoncreds: &Arc<dyn BaseAnonCreds>,
Expand Down
2 changes: 2 additions & 0 deletions aries_vcx/src/core/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ pub mod vdr_proxy_profile;
#[cfg(feature = "vdrtools")]
pub mod vdrtools_profile;

#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
const DEFAULT_AML_LABEL: &str = "eula";

#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
use std::sync::Arc;

#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
Expand Down
10 changes: 5 additions & 5 deletions aries_vcx/src/core/profile/vdrtools_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ pub struct VdrtoolsProfile {
}

impl VdrtoolsProfile {
pub fn init(indy_wallet_handle: WalletHandle, indy_pool_handle: PoolHandle) -> Self {
let wallet = Arc::new(IndySdkWallet::new(indy_wallet_handle));
let anoncreds = Arc::new(IndySdkAnonCreds::new(indy_wallet_handle));
let ledger_read = Arc::new(IndySdkLedgerRead::new(indy_wallet_handle, indy_pool_handle));
let ledger_write = Arc::new(IndySdkLedgerWrite::new(indy_wallet_handle, indy_pool_handle));
pub fn init(wallet_handle: WalletHandle, pool_handle: PoolHandle) -> Self {
let wallet = Arc::new(IndySdkWallet::new(wallet_handle));
let anoncreds = Arc::new(IndySdkAnonCreds::new(wallet_handle));
let ledger_read = Arc::new(IndySdkLedgerRead::new(wallet_handle, pool_handle));
let ledger_write = Arc::new(IndySdkLedgerWrite::new(wallet_handle, pool_handle));
VdrtoolsProfile {
wallet,
anoncreds,
Expand Down
23 changes: 1 addition & 22 deletions aries_vcx/src/global/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use aries_vcx_core::global::settings::{disable_indy_mocks, enable_indy_mocks};

use crate::errors::error::prelude::*;

pub static CONFIG_POOL_NAME: &str = "pool_name";
pub static CONFIG_SDK_TO_REMOTE_ROLE: &str = "sdk_to_remote_role";
pub static CONFIG_INSTITUTION_DID: &str = "institution_did";
pub static CONFIG_INSTITUTION_VERKEY: &str = "institution_verkey";
Expand All @@ -16,7 +15,6 @@ pub static CONFIG_ENABLE_TEST_MODE: &str = "enable_test_mode";
pub static CONFIG_GENESIS_PATH: &str = "genesis_path";
pub static CONFIG_LOG_CONFIG: &str = "log_config";
pub static CONFIG_EXPORTED_WALLET_PATH: &str = "exported_wallet_path";
pub static CONFIG_WALLET_BACKUP_KEY: &str = "backup_key";
pub static CONFIG_WALLET_KEY: &str = "wallet_key";
pub static CONFIG_WALLET_NAME: &str = "wallet_name";
pub static CONFIG_WALLET_TYPE: &str = "wallet_type";
Expand Down Expand Up @@ -99,32 +97,13 @@ pub fn set_config_value(key: &str, value: &str) -> VcxResult<()> {
Ok(())
}

pub fn reset_config_values() -> VcxResult<()> {
pub fn reset_config_values_ariesvcx() -> VcxResult<()> {
trace!("reset_config_values >>>");
let mut config = SETTINGS.write()?;
config.clear();
Ok(())
}

pub fn set_test_configs() -> String {
trace!("set_testing_defaults >>>");
let mut settings = SETTINGS
.write()
.expect("Unabled to access SETTINGS while setting test configs");
let institution_did = CONFIG_INSTITUTION_DID;
settings.insert(CONFIG_POOL_NAME.to_string(), DEFAULT_POOL_NAME.to_string());
settings.insert(institution_did.to_string(), DEFAULT_DID.to_string());
settings.insert(
CONFIG_PROTOCOL_VERSION.to_string(),
DEFAULT_PROTOCOL_VERSION.to_string(),
);
settings.insert(
CONFIG_WALLET_BACKUP_KEY.to_string(),
DEFAULT_WALLET_BACKUP_KEY.to_string(),
);
institution_did.to_string()
}

pub fn get_protocol_version() -> usize {
let protocol_version = match get_config_value(CONFIG_PROTOCOL_VERSION) {
Ok(ver) => ver.parse::<usize>().unwrap_or_else(|err| {
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/handlers/connection/mediated_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use aries_vcx_core::wallet::base_wallet::BaseWallet;
use url::Url;
use uuid::Uuid;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::handlers::connection::cloud_agent::CloudAgentInfo;
use crate::handlers::connection::legacy_agent_info::LegacyAgentInfo;
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/handlers/issuance/holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use aries_vcx_core::wallet::base_wallet::BaseWallet;

use crate::common::credentials::get_cred_rev_id;
use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::handlers::connection::mediated_connection::MediatedConnection;
use crate::handlers::revocation_notification::receiver::RevocationNotificationReceiver;
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/handlers/issuance/issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds;
use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead;
use aries_vcx_core::wallet::base_wallet::BaseWallet;

use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::handlers::connection::mediated_connection::MediatedConnection;
use crate::handlers::revocation_notification::sender::RevocationNotificationSender;
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/handlers/out_of_band/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use serde::Deserialize;
use serde_json::Value;

use crate::common::ledger::transactions::resolve_service;
use crate::core::profile::profile::Profile;
use crate::errors::error::prelude::*;
use crate::handlers::connection::mediated_connection::MediatedConnection;
use crate::handlers::util::{AnyInvitation, AttachmentId};
Expand Down
Loading

0 comments on commit 276cab8

Please sign in to comment.