Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further integration test refactoring #979

Merged
merged 13 commits into from
Sep 15, 2023
2 changes: 0 additions & 2 deletions .github/actions/setup-testing-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ runs:
run: |
docker run -d --name mysql --network host -e MYSQL_ROOT_PASSWORD=mysecretpassword mysql:5.7.35
docker run -d --name indypool --network host ${{ env.DOCKER_IMAGE_POOL }}
sleep 5
docker-compose -f ./ci/agency/docker-compose.yml up -d
- name: "Start vdrproxy"
if: ${{ inputs.skip-vdrproxy-setup != 'true' }}
shell: bash
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ jobs:
- name: "Run aries-vcx tests: pool_tests agency_pool_tests"
run: |
cargo test --manifest-path="wallet_migrator/Cargo.toml";
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_creds_proofs -- --include-ignored;
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_creds_proofs_revocations -- --include-ignored;
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_credential_issuance -- --include-ignored;
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_credential_retrieval -- --include-ignored;
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_proof_presentation -- --include-ignored;
RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F migration --test test_revocations -- --include-ignored;

test-integration-libvcx:
needs: workflow-setup
Expand Down
1 change: 1 addition & 0 deletions aries_vcx/src/common/anoncreds.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Convert to unit test or move to ./tests
#[cfg(test)]
#[allow(clippy::unwrap_used)]
pub mod integration_tests {
Expand Down
53 changes: 18 additions & 35 deletions aries_vcx/src/common/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,28 @@ use std::sync::Arc;
use std::thread;
use std::time::Duration;

use aries_vcx_core::wallet::base_wallet::BaseWallet;

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::global::settings;
use crate::utils::constants::{DEFAULT_SCHEMA_ATTRS, TEST_TAILS_URL, TRUSTEE_SEED};
use crate::utils::constants::{DEFAULT_SCHEMA_ATTRS, TEST_TAILS_URL};

pub async fn create_schema(
pub async fn create_and_write_test_schema(
anoncreds: &Arc<dyn BaseAnonCreds>,
attr_list: &str,
ledger_write: &Arc<dyn AnoncredsLedgerWrite>,
submitter_did: &str,
attr_list: &str,
) -> (String, String) {
let data = attr_list.to_string();
let schema_name: String = crate::utils::random::generate_random_schema_name();
let schema_version: String = crate::utils::random::generate_random_schema_version();

anoncreds
let (schema_id, schema_json) = anoncreds
.issuer_create_schema(&submitter_did, &schema_name, &schema_version, &data)
.await
.unwrap()
}
.unwrap();

pub async fn create_and_write_test_schema(
anoncreds: &Arc<dyn BaseAnonCreds>,
ledger_write: &Arc<dyn AnoncredsLedgerWrite>,
submitter_did: &str,
attr_list: &str,
) -> (String, String) {
let (schema_id, schema_json) = create_schema(anoncreds, attr_list, submitter_did).await;
let _response = ledger_write
.publish_schema(&schema_json, submitter_did, None)
.await
Expand All @@ -46,6 +37,7 @@ pub async fn create_and_write_test_schema(
(schema_id, schema_json)
}

// TODO: Deduplicate this with create_and_store_credential_def_and_rev_reg
pub async fn create_and_store_nonrevocable_credential_def(
anoncreds: &Arc<dyn BaseAnonCreds>,
ledger_read: &Arc<dyn AnoncredsLedgerRead>,
Expand All @@ -66,14 +58,14 @@ pub async fn create_and_store_nonrevocable_credential_def(
.publish_cred_def(ledger_read, ledger_write)
.await
.unwrap();
tokio::time::sleep(Duration::from_millis(1000)).await;
let cred_def_id = cred_def.get_cred_def_id();
tokio::time::sleep(Duration::from_millis(1000)).await;

let cred_def_json = ledger_read.get_cred_def(&cred_def_id, None).await.unwrap();
(schema_id, schema_json, cred_def_id, cred_def_json, cred_def)
}

// TODO: Split into schema, cred def, and rev reg creation functions
pub async fn create_and_store_credential_def_and_rev_reg(
anoncreds: &Arc<dyn BaseAnonCreds>,
ledger_read: &Arc<dyn AnoncredsLedgerRead>,
Expand All @@ -91,7 +83,6 @@ pub async fn create_and_store_credential_def_and_rev_reg(
RevocationRegistry,
) {
let (schema_id, schema_json) = create_and_write_test_schema(anoncreds, ledger_write, issuer_did, attr_list).await;
thread::sleep(Duration::from_millis(500));
let config = CredentialDefConfigBuilder::default()
.issuer_did(issuer_did)
.schema_id(&schema_id)
Expand All @@ -115,7 +106,6 @@ pub async fn create_and_store_credential_def_and_rev_reg(
.await
.unwrap();

tokio::time::sleep(Duration::from_millis(1000)).await;
let cred_def_id = cred_def.get_cred_def_id();
tokio::time::sleep(Duration::from_millis(1000)).await;
let cred_def_json = ledger_read.get_cred_def(&cred_def_id, None).await.unwrap();
Expand All @@ -131,7 +121,7 @@ pub async fn create_and_store_credential_def_and_rev_reg(
)
}

pub async fn create_credential_req(
async fn create_credential_req(
anoncreds_issuer: &Arc<dyn BaseAnonCreds>,
anoncreds_holder: &Arc<dyn BaseAnonCreds>,
did: &str,
Expand Down Expand Up @@ -182,14 +172,15 @@ pub async fn create_and_store_credential(
)
.await;

let (offer, req, req_meta) = create_credential_req(
anoncreds_issuer,
anoncreds_holder,
institution_did,
&cred_def_id,
&cred_def_json,
)
.await;
let offer = anoncreds_issuer
.issuer_create_credential_offer(&cred_def_id)
.await
.unwrap();
let master_secret_name = settings::DEFAULT_LINK_SECRET_ALIAS;
let (req, req_meta) = anoncreds_holder
.prover_create_credential_req(&institution_did, &offer, &cred_def_json, master_secret_name)
.await
.unwrap();

/* create cred */
let credential_data = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#;
Expand Down Expand Up @@ -456,11 +447,3 @@ pub async fn create_proof_with_predicate(
.unwrap();
(schemas, cred_defs, proof_req, proof)
}

pub async fn create_trustee_key(wallet: &Arc<dyn BaseWallet>) -> String {
wallet
.create_and_store_my_did(Some(TRUSTEE_SEED), None)
.await
.unwrap()
.1
}
6 changes: 3 additions & 3 deletions aries_vcx/src/utils/devsetup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub async fn dev_setup_wallet_indy(key_seed: &str) -> (String, WalletHandle) {
}

#[cfg(feature = "vdrtools")]
pub async fn dev_build_profile_vdrtools(genesis_file_path: String, wallet: Arc<IndySdkWallet>) -> Arc<dyn Profile> {
pub fn dev_build_profile_vdrtools(genesis_file_path: String, wallet: Arc<IndySdkWallet>) -> Arc<dyn Profile> {
info!("dev_build_profile_vdrtools >>");
let vcx_pool_config = VcxPoolConfig {
genesis_file_path: genesis_file_path.clone(),
Expand Down Expand Up @@ -243,7 +243,7 @@ pub async fn dev_build_featured_profile(genesis_file_path: String, wallet: Arc<I
#[cfg(feature = "migration")]
return {
info!("SetupProfile >> using indy profile");
dev_build_profile_vdrtools(genesis_file_path, wallet).await
dev_build_profile_vdrtools(genesis_file_path, wallet)
};
#[cfg(feature = "modular_libs")]
return {
Expand All @@ -258,7 +258,7 @@ pub async fn dev_build_featured_profile(genesis_file_path: String, wallet: Arc<I
#[cfg(feature = "vdrtools")]
return {
info!("SetupProfile >> using indy profile");
dev_build_profile_vdrtools(genesis_file_path, wallet).await
dev_build_profile_vdrtools(genesis_file_path, wallet)
};
}

Expand Down
Loading
Loading