Skip to content

Commit

Permalink
Sync up 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 Jun 7, 2023
1 parent e7c1eee commit 3c96562
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 84 deletions.
16 changes: 10 additions & 6 deletions aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ mod integration_tests {
let tails_file = res.10;
let rev_reg = res.11;

assert!(!is_cred_revoked(&setup.profile, &rev_reg_id, &cred_rev_id)
.await
.unwrap());
assert!(
!is_cred_revoked(&setup.profile.inject_anoncreds_ledger_read(), &rev_reg_id, &cred_rev_id)
.await
.unwrap()
);

let anoncreds = Arc::clone(&setup.profile).inject_anoncreds();

Expand All @@ -137,9 +139,11 @@ mod integration_tests {

std::thread::sleep(std::time::Duration::from_millis(500));

assert!(is_cred_revoked(&setup.profile, &rev_reg_id, &cred_rev_id)
.await
.unwrap());
assert!(
is_cred_revoked(&setup.profile.inject_anoncreds_ledger_read(), &rev_reg_id, &cred_rev_id)
.await
.unwrap()
);
})
.await;
}
Expand Down
13 changes: 8 additions & 5 deletions aries_vcx/src/common/primitives/revocation_registry_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ pub mod integration_tests {
let (_, _, _, _, rev_reg_id, _, _) =
create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await;

assert!(
RevocationRegistryDelta::create_from_ledger(&setup.profile, &rev_reg_id, None, None)
.await
.is_ok()
);
assert!(RevocationRegistryDelta::create_from_ledger(
&setup.profile.inject_anoncreds_ledger_read(),
&rev_reg_id,
None,
None
)
.await
.is_ok());
})
.await;
}
Expand Down
48 changes: 33 additions & 15 deletions aries_vcx/src/common/proofs/prover/prover_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,16 @@ pub mod pool_tests {
#[tokio::test]
#[ignore]
async fn test_pool_build_rev_states_json_empty() {
SetupProfile::run(|_setup| async move {
SetupProfile::run(|setup| async move {
// empty vector
assert_eq!(
build_rev_states_json(&_setup.profile, Vec::new().as_mut())
.await
.unwrap(),
build_rev_states_json(
&setup.profile.inject_anoncreds_ledger_read(),
&setup.profile.inject_anoncreds(),
Vec::new().as_mut()
)
.await
.unwrap(),
"{}".to_string()
);

Expand All @@ -280,9 +284,13 @@ pub mod pool_tests {
revealed: None,
};
assert_eq!(
build_rev_states_json(&_setup.profile, vec![cred1].as_mut())
.await
.unwrap(),
build_rev_states_json(
&setup.profile.inject_anoncreds_ledger_read(),
&setup.profile.inject_anoncreds(),
vec![cred1].as_mut()
)
.await
.unwrap(),
"{}".to_string()
);
})
Expand Down Expand Up @@ -354,7 +362,9 @@ pub mod unit_tests {
};
let creds = vec![cred1, cred2];

let credential_def = build_cred_defs_json_prover(&mock_profile(), &creds).await.unwrap();
let credential_def = build_cred_defs_json_prover(&mock_profile().inject_anoncreds_ledger_read(), &creds)
.await
.unwrap();
assert!(credential_def.len() > 0);
assert!(credential_def.contains(r#""id":"V4SGRU86Z58d6TV7PBUe6f:3:CL:47:tag1","schemaId":"47""#));
}
Expand All @@ -375,7 +385,7 @@ pub mod unit_tests {
timestamp: None,
revealed: None,
}];
let err_kind = build_cred_defs_json_prover(&profile, &credential_ids)
let err_kind = build_cred_defs_json_prover(&profile.inject_anoncreds_ledger_read(), &credential_ids)
.await
.unwrap_err()
.kind();
Expand All @@ -402,7 +412,7 @@ pub mod unit_tests {
}];

assert_eq!(
build_schemas_json_prover(&profile, &credential_ids)
build_schemas_json_prover(&profile.inject_anoncreds_ledger_read(), &credential_ids)
.await
.unwrap_err()
.kind(),
Expand All @@ -417,7 +427,9 @@ pub mod unit_tests {
let _setup = SetupMocks::init();

assert_eq!(
build_schemas_json_prover(&mock_profile(), &Vec::new()).await.unwrap(),
build_schemas_json_prover(&mock_profile().inject_anoncreds_ledger_read(), &Vec::new())
.await
.unwrap(),
"{}".to_string()
);

Expand Down Expand Up @@ -447,7 +459,9 @@ pub mod unit_tests {
};
let creds = vec![cred1, cred2];

let schemas = build_schemas_json_prover(&mock_profile(), &creds).await.unwrap();
let schemas = build_schemas_json_prover(&mock_profile().inject_anoncreds_ledger_read(), &creds)
.await
.unwrap();
assert!(schemas.len() > 0);
assert!(schemas.contains(r#""id":"2hoqvcwupRTUNkXn6ArYzs:2:test-licence:4.4.4","name":"test-licence""#));
}
Expand Down Expand Up @@ -710,9 +724,13 @@ pub mod unit_tests {
revealed: None,
};
let mut cred_info = vec![cred1];
let states = build_rev_states_json(&mock_profile(), cred_info.as_mut())
.await
.unwrap();
let states = build_rev_states_json(
&mock_profile().inject_anoncreds_ledger_read(),
&mock_profile().inject_anoncreds(),
cred_info.as_mut(),
)
.await
.unwrap();
let rev_state_json: Value = serde_json::from_str(REV_STATE_JSON).unwrap();
let expected = json!({REV_REG_ID: {"1": rev_state_json}}).to_string();
assert_eq!(states, expected);
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/common/proofs/verifier/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub mod unit_tests {

assert_eq!(
validate_indy_proof(
&setup.profile.inject_indy_ledger_read(),
&setup.profile.inject_anoncreds_ledger_read(),
&setup.profile.inject_anoncreds(),
&prover_proof_json,
&proof_req_json
Expand Down
17 changes: 11 additions & 6 deletions aries_vcx/src/common/proofs/verifier/verifier_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ pub mod unit_tests {
timestamp: None,
};
let credentials = vec![cred1, cred2];
let credential_json = build_cred_defs_json_verifier(&mock_profile(), &credentials)
.await
.unwrap();
let credential_json =
build_cred_defs_json_verifier(&mock_profile().inject_anoncreds_ledger_read(), &credentials)
.await
.unwrap();

let json: Value = serde_json::from_str(CRED_DEF_JSON).unwrap();
let expected = json!({ CRED_DEF_ID: json }).to_string();
Expand All @@ -263,7 +264,7 @@ pub mod unit_tests {
timestamp: None,
};
let credentials = vec![cred1, cred2];
let schema_json = build_schemas_json_verifier(&mock_profile(), &credentials)
let schema_json = build_schemas_json_verifier(&mock_profile().inject_anoncreds_ledger_read(), &credentials)
.await
.unwrap();

Expand All @@ -289,7 +290,9 @@ pub mod unit_tests {
timestamp: None,
};
let credentials = vec![cred1, cred2];
let rev_reg_defs_json = build_rev_reg_defs_json(&mock_profile(), &credentials).await.unwrap();
let rev_reg_defs_json = build_rev_reg_defs_json(&mock_profile().inject_anoncreds_ledger_read(), &credentials)
.await
.unwrap();

let json: Value = serde_json::from_str(&rev_def_json()).unwrap();
let expected = json!({ REV_REG_ID: json }).to_string();
Expand All @@ -313,7 +316,9 @@ pub mod unit_tests {
timestamp: Some(2),
};
let credentials = vec![cred1, cred2];
let rev_reg_json = build_rev_reg_json(&mock_profile(), &credentials).await.unwrap();
let rev_reg_json = build_rev_reg_json(&mock_profile().inject_anoncreds_ledger_read(), &credentials)
.await
.unwrap();

let json: Value = serde_json::from_str(REV_REG_JSON).unwrap();
let expected = json!({REV_REG_ID:{"1":json}}).to_string();
Expand Down
16 changes: 10 additions & 6 deletions aries_vcx/tests/test_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ mod integration_tests {

info!("test_connection_send_works:: Test if Send Message works");
{
faber.connection.send_message_closure(&faber.profile).await.unwrap()(AriesMessage::from(
message.clone(),
))
faber
.connection
.send_message_closure(faber.profile.inject_wallet())
.await
.unwrap()(AriesMessage::from(message.clone()))
.await
.unwrap();
}
Expand Down Expand Up @@ -249,9 +251,11 @@ mod integration_tests {

let credential_offer = OfferCredential::with_decorators(id, content, decorators);

faber.connection.send_message_closure(&faber.profile).await.unwrap()(AriesMessage::from(
credential_offer,
))
faber
.connection
.send_message_closure(faber.profile.inject_wallet())
.await
.unwrap()(AriesMessage::from(credential_offer))
.await
.unwrap();

Expand Down
30 changes: 19 additions & 11 deletions aries_vcx/tests/test_creds_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ mod tests {
prover_select_credentials_and_send_proof(&mut consumer1, &consumer1_to_verifier, None, None).await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(), &institution.profile.inject_anoncreds_ledger_read(), &institution.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer1)
&verifier.profile.inject_wallet(), &verifier.profile.inject_anoncreds_ledger_read(), &verifier.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer1)
.await
.unwrap();
assert_eq!(
Expand All @@ -797,7 +797,12 @@ mod tests {
prover_select_credentials_and_send_proof(&mut consumer2, &consumer2_to_verifier, None, None).await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(), &institution.profile.inject_anoncreds_ledger_read(), &institution.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer2)
&verifier.profile.inject_wallet(),
&verifier.profile.inject_anoncreds_ledger_read(),
&verifier.profile.inject_anoncreds(),
&verifier.agency_client,
&verifier_to_consumer2
)
.await
.unwrap();
assert_eq!(
Expand Down Expand Up @@ -834,9 +839,9 @@ mod tests {
prover_select_credentials_and_send_proof(&mut consumer, &consumer_to_verifier, request_name1, None).await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(),
&institution.profile.inject_anoncreds_ledger_read(),
&institution.profile.inject_anoncreds(),
&verifier.profile.inject_wallet(),
&verifier.profile.inject_anoncreds_ledger_read(),
&verifier.profile.inject_anoncreds(),
&verifier.agency_client,
&verifier_to_consumer,
)
Expand All @@ -859,9 +864,9 @@ mod tests {
prover_select_credentials_and_send_proof(&mut consumer, &consumer_to_verifier, request_name2, None).await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(),
&institution.profile.inject_anoncreds_ledger_read(),
&institution.profile.inject_anoncreds(),
&verifier.profile.inject_wallet(),
&verifier.profile.inject_anoncreds_ledger_read(),
&verifier.profile.inject_anoncreds(),
&verifier.agency_client,
&verifier_to_consumer,
)
Expand Down Expand Up @@ -1045,7 +1050,10 @@ mod tests {
let mut prover = create_proof(&mut consumer, &consumer_to_issuer, None).await;
info!("test_real_proof :: retrieving matching credentials");

let retrieved_credentials = prover.retrieve_credentials(&consumer.profile).await.unwrap();
let retrieved_credentials = prover
.retrieve_credentials(&consumer.profile.inject_anoncreds())
.await
.unwrap();
let selected_credentials = retrieved_to_selected_credentials_simple(&retrieved_credentials, false);

info!("test_real_proof :: generating and sending proof");
Expand Down Expand Up @@ -1127,7 +1135,7 @@ mod tests {
.await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(), &institution.profile.inject_anoncreds_ledger_read(), &institution.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer)
&verifier.profile.inject_wallet(), &verifier.profile.inject_anoncreds_ledger_read(), &verifier.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer)
.await
.unwrap();
assert_eq!(
Expand All @@ -1147,7 +1155,7 @@ mod tests {
.await;
proof_verifier
.update_state(
&institution.profile.inject_wallet(), &institution.profile.inject_anoncreds_ledger_read(), &institution.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer)
&verifier.profile.inject_wallet(), &verifier.profile.inject_anoncreds_ledger_read(), &verifier.profile.inject_anoncreds(), &verifier.agency_client, &verifier_to_consumer)
.await
.unwrap();
assert_eq!(
Expand Down
Loading

0 comments on commit 3c96562

Please sign in to comment.