Skip to content

Commit

Permalink
Implement issuer side for IndyVdrLedger, remove most of run_indy tests
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed May 12, 2023
1 parent 0c30182 commit 74c94a5
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 58 deletions.
2 changes: 1 addition & 1 deletion aries_vcx/src/common/anoncreds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_revoke_credential() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential(
Expand Down
6 changes: 3 additions & 3 deletions aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_prover_get_credential() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let res = create_and_store_credential(
Expand Down Expand Up @@ -85,7 +85,7 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_cred_rev_id() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let res = create_and_store_credential(
Expand All @@ -108,7 +108,7 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_is_cred_revoked() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let res = create_and_store_credential(
Expand Down
16 changes: 12 additions & 4 deletions aries_vcx/src/common/primitives/credential_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_create_cred_def_real() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (schema_id, _) =
create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await;

let ledger = Arc::clone(&setup.profile).inject_ledger();
let schema_json = ledger.get_schema(&schema_id, None).await.unwrap();

let (_, cred_def_json) = generate_cred_def(
let (cred_def_id, cred_def_json_local) = generate_cred_def(
&setup.profile,
&setup.institution_did,
&schema_json,
Expand All @@ -304,17 +304,25 @@ pub mod integration_tests {
.unwrap();

ledger
.publish_cred_def(&cred_def_json, &setup.institution_did)
.publish_cred_def(&cred_def_json_local, &setup.institution_did)
.await
.unwrap();

let cred_def_json_ledger = ledger
.get_cred_def(&cred_def_id, Some(&setup.institution_did))
.await
.unwrap();

assert!(cred_def_json_local.contains(&cred_def_id));
assert!(cred_def_json_ledger.contains(&cred_def_id));
})
.await;
}

#[tokio::test]
#[ignore]
async fn test_pool_create_rev_reg_def() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (schema_id, _) =
create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await;
let ledger = Arc::clone(&setup.profile).inject_ledger();
Expand Down
12 changes: 6 additions & 6 deletions aries_vcx/src/common/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod integration_tests {
#[ignore]
async fn test_pool_rev_reg_def_fails_for_cred_def_created_without_revocation() {
// todo: does not need agency setup
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
// Cred def is created with support_revocation=false,
// revoc_reg_def will fail in libindy because cred_Def doesn't have revocation keys
let (_, _, cred_def_id, _, _) = create_and_store_nonrevocable_credential_def(
Expand Down Expand Up @@ -49,7 +49,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_rev_reg_def_json() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let attrs = r#"["address1","address2","city","state","zip"]"#;
let (_, _, _, _, rev_reg_id, _, _) =
create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await;
Expand All @@ -63,7 +63,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_rev_reg_delta_json() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let attrs = r#"["address1","address2","city","state","zip"]"#;
let (_, _, _, _, rev_reg_id, _, _) =
create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await;
Expand All @@ -79,7 +79,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_rev_reg() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let attrs = r#"["address1","address2","city","state","zip"]"#;
let (_, _, _, _, rev_reg_id, _, _) =
create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await;
Expand All @@ -98,7 +98,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_cred_def() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let attrs = r#"["address1","address2","city","state","zip"]"#;
let (_, _, cred_def_id, cred_def_json, _) =
create_and_store_nonrevocable_credential_def(&setup.profile, &setup.institution_did, attrs).await;
Expand All @@ -117,7 +117,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_from_pool_ledger_with_id() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (schema_id, _schema_json) =
create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_create_rev_reg_delta_from_ledger() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let attrs = r#"["address1","address2","city","state","zip"]"#;
let (_, _, _, _, rev_reg_id, _, _) =
create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await;
Expand Down
10 changes: 5 additions & 5 deletions aries_vcx/src/common/proofs/verifier/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub mod unit_tests {
#[tokio::test]
#[ignore]
async fn test_pool_proof_restrictions() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let requested_attrs = json!([
Expand Down Expand Up @@ -218,7 +218,7 @@ pub mod unit_tests {
#[tokio::test]
#[ignore]
async fn test_pool_proof_validate_attribute() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let requested_attrs = json!([
Expand Down Expand Up @@ -334,7 +334,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_prover_verify_proof() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let (schemas, cred_defs, proof_req, proof) =
Expand All @@ -354,7 +354,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_prover_verify_proof_with_predicate_success_case() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let (schemas, cred_defs, proof_req, proof) =
Expand All @@ -374,7 +374,7 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_prover_verify_proof_with_predicate_fail_case() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

let (schemas, cred_defs, proof_req, proof) =
Expand Down
11 changes: 6 additions & 5 deletions aries_vcx/src/core/profile/vdr_proxy_profile.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;

use aries_vcx_core::{
anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds},
anoncreds::{base_anoncreds::BaseAnonCreds, indy_anoncreds::IndySdkAnonCreds},
ledger::{
base_ledger::BaseLedger, indy_vdr_ledger::IndyVdrLedger, request_submitter::vdr_proxy::VdrProxySubmitter,
},
wallet::base_wallet::BaseWallet,
VdrProxyClient,
wallet::{base_wallet::BaseWallet, indy_wallet::IndySdkWallet},
VdrProxyClient, WalletHandle,
};

use super::profile::Profile;
Expand All @@ -19,10 +19,11 @@ pub struct VdrProxyProfile {
}

impl VdrProxyProfile {
pub fn new(wallet: Arc<dyn BaseWallet>, client: VdrProxyClient) -> Self {
pub fn new(wallet_handle: WalletHandle, client: VdrProxyClient) -> Self {
let wallet = Arc::new(IndySdkWallet::new(wallet_handle));
let submitter = Arc::new(VdrProxySubmitter::new(Arc::new(client)));
let ledger = Arc::new(IndyVdrLedger::new(wallet.clone(), submitter));
let anoncreds = Arc::new(IndyCredxAnonCreds::new(Arc::clone(&wallet)));
let anoncreds = Arc::new(IndySdkAnonCreds::new(wallet_handle));
VdrProxyProfile {
wallet,
ledger,
Expand Down
3 changes: 1 addition & 2 deletions aries_vcx/src/utils/devsetup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,9 @@ impl SetupProfile {

// TODO: Test configuration should be handled uniformly
let client_url = env::var("VDR_PROXY_CLIENT_URL").unwrap_or_else(|_| "http://127.0.0.1:3030".to_string());
let wallet = IndySdkWallet::new(wallet_handle);
let client = VdrProxyClient::new(&client_url).unwrap();

let profile: Arc<dyn Profile> = Arc::new(VdrProxyProfile::new(Arc::new(wallet), client));
let profile: Arc<dyn Profile> = Arc::new(VdrProxyProfile::new(wallet_handle, client));

async fn vdr_proxy_teardown() {
// nothing to do
Expand Down
14 changes: 7 additions & 7 deletions aries_vcx/tests/test_creds_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_retrieve_credentials() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

create_and_store_nonrevocable_credential(
Expand Down Expand Up @@ -69,7 +69,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_get_credential_def() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def(
&setup.profile,
&setup.institution_did,
Expand All @@ -91,7 +91,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_retrieve_credentials_empty() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let mut req = json!({
"nonce":"123432421212",
"name":"proof_req_1",
Expand Down Expand Up @@ -148,7 +148,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
create_and_store_nonrevocable_credential(
&setup.profile,
&setup.profile,
Expand Down Expand Up @@ -245,7 +245,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_generate_proof() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
create_and_store_credential(
&setup.profile,
&setup.profile,
Expand Down Expand Up @@ -326,7 +326,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_generate_proof_with_predicates() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
create_and_store_credential(
&setup.profile,
&setup.profile,
Expand Down Expand Up @@ -411,7 +411,7 @@ mod integration_tests {
#[ignore]
async fn test_agency_pool_generate_self_attested_proof() {
// todo - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let indy_proof_req = json!({
"nonce":"123432421212",
"name":"proof_req_1",
Expand Down
4 changes: 2 additions & 2 deletions aries_vcx/tests/test_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod integration_tests {
#[ignore]
async fn test_pool_get_credential_def() {
// TODO - use SetupProfile::run after modular impls
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def(
&setup.profile,
&setup.institution_did,
Expand Down Expand Up @@ -71,7 +71,7 @@ mod integration_tests {
// TODO - future - bring back after all endorser methods added to baseledger
// #[tokio::test]
// async fn test_endorse_transaction() {
// SetupProfile::run_indy(|setup| async move {
// SetupProfile::run(|setup| async move {
// let ledger = Arc::clone(&setup.profile).inject_ledger();
// let (author_did, _) = add_new_did(&setup.profile, &setup.institution_did, None).await.unwrap();
// let (endorser_did, _) = add_new_did(&setup.profile, &setup.institution_did, Some("ENDORSER")).await.unwrap();
Expand Down
Loading

0 comments on commit 74c94a5

Please sign in to comment.