Skip to content

Commit

Permalink
Feature/credx issuer (#854)
Browse files Browse the repository at this point in the history
* Implement anoncreds trait with credx

Signed-off-by: Bogdan Mircea <mirceapetrebogdan@gmail.com>
  • Loading branch information
bobozaur authored May 29, 2023
1 parent a6ad85a commit 1222ef7
Show file tree
Hide file tree
Showing 22 changed files with 620 additions and 212 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup-codecov-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ inputs:
runs:
using: "composite"
steps:
- name: Install latest nightly
- name: Install nightly 1.71
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: nightly-2023-05-08
override: true
- uses: Swatinem/rust-cache@v2
- name: "Install dependencies"
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ jobs:
cargo check --features vdrtools --no-default-features
cargo check --features modular_libs --no-default-features
cargo check --features vdr_proxy_ledger --no-default-features
cargo check --features mixed_breed
##########################################################################################
############################## DOCKER BUILD ##########################################
Expand Down Expand Up @@ -500,6 +501,17 @@ jobs:
- name: "Run aries-vcx tests: vdrproxy_test"
run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger -- --ignored

test-integration-aries-vcx-mixed-breed:
needs: workflow-setup
runs-on: ubuntu-20.04
steps:
- name: "Git checkout"
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" -F mixed_breed -- --include-ignored;

test-integration-libvcx:
needs: workflow-setup
if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }}
Expand Down
3 changes: 3 additions & 0 deletions aries_vcx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ modular_libs = ["aries_vcx_core/modular_libs"]
# TODO: Remove using "vdrtools" feature flag for vdr_proxy_ledger once IndyCredxAnonCreds
# is fully implemented
vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger", "vdrtools"]
# Temporary feature used for testing the full credx anoncreds impl
# using vdrtools ledger and wallet.
mixed_breed = ["vdrtools", "modular_libs"]

[dependencies]
agency_client = { path = "../agency_client" }
Expand Down
10 changes: 4 additions & 6 deletions aries_vcx/src/common/anoncreds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod integration_tests {

use crate::common::test_utils::create_and_store_credential;
use crate::utils::constants::TAILS_DIR;
use crate::utils::devsetup::{init_holder_setup_in_indy_context, SetupProfile};
use crate::utils::devsetup::SetupProfile;
use crate::utils::get_temp_dir_path;

#[tokio::test]
Expand Down Expand Up @@ -60,18 +60,16 @@ pub mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_revoke_credential() {
SetupProfile::run_indy(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

SetupProfile::run(|setup| async move {
let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential(
&setup.profile,
&holder_setup.profile,
&setup.profile,
&setup.institution_did,
crate::utils::constants::DEFAULT_SCHEMA_ATTRS,
)
.await;

let ledger = Arc::clone(&holder_setup.profile).inject_anoncreds_ledger_read();
let ledger = Arc::clone(&setup.profile).inject_anoncreds_ledger_read();

let (_, first_rev_reg_delta, first_timestamp) =
ledger.get_rev_reg_delta_json(&rev_reg_id, None, None).await.unwrap();
Expand Down
28 changes: 11 additions & 17 deletions aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ mod integration_tests {

use crate::common::test_utils::create_and_store_credential;
use crate::utils::constants::DEFAULT_SCHEMA_ATTRS;
use crate::utils::devsetup::{init_holder_setup_in_indy_context, SetupProfile};
use crate::utils::devsetup::SetupProfile;

#[tokio::test]
#[ignore]
async fn test_pool_prover_get_credential() {
SetupProfile::run_indy(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

SetupProfile::run(|setup| async move {
let res = create_and_store_credential(
&setup.profile,
&holder_setup.profile,
&setup.profile,
&setup.institution_did,
DEFAULT_SCHEMA_ATTRS,
)
Expand All @@ -69,7 +67,7 @@ mod integration_tests {
let rev_reg_id = res.8;
let cred_rev_id = res.9;

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

let cred_json = anoncreds.prover_get_credential(&cred_id).await.unwrap();
let prover_cred = serde_json::from_str::<ProverCredential>(&cred_json).unwrap();
Expand All @@ -85,20 +83,18 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_get_cred_rev_id() {
SetupProfile::run_indy(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

SetupProfile::run(|setup| async move {
let res = create_and_store_credential(
&setup.profile,
&holder_setup.profile,
&setup.profile,
&setup.institution_did,
DEFAULT_SCHEMA_ATTRS,
)
.await;
let cred_id = res.7;
let cred_rev_id = res.9;

let cred_rev_id_ = get_cred_rev_id(&holder_setup.profile, &cred_id).await.unwrap();
let cred_rev_id_ = get_cred_rev_id(&setup.profile, &cred_id).await.unwrap();

assert_eq!(cred_rev_id, cred_rev_id_.to_string());
})
Expand All @@ -108,12 +104,10 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_pool_is_cred_revoked() {
SetupProfile::run_indy(|setup| async move {
let holder_setup = init_holder_setup_in_indy_context(&setup).await;

SetupProfile::run(|setup| async move {
let res = create_and_store_credential(
&setup.profile,
&holder_setup.profile,
&setup.profile,
&setup.institution_did,
DEFAULT_SCHEMA_ATTRS,
)
Expand All @@ -123,7 +117,7 @@ mod integration_tests {
let tails_file = res.10;
let rev_reg = res.11;

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

Expand All @@ -140,7 +134,7 @@ mod integration_tests {

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

assert!(is_cred_revoked(&holder_setup.profile, &rev_reg_id, &cred_rev_id)
assert!(is_cred_revoked(&setup.profile, &rev_reg_id, &cred_rev_id)
.await
.unwrap());
})
Expand Down
8 changes: 6 additions & 2 deletions aries_vcx/src/common/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ pub async fn get_verkey_from_ledger(profile: &Arc<dyn Profile>, did: &str) -> Vc
mod test {
#[tokio::test]
#[ignore]
#[cfg(not(feature = "vdr_proxy_ledger"))]
#[cfg(all(
not(feature = "vdr_proxy_ledger"),
not(feature = "modular_libs"),
not(feature = "mixed_breed")
))]
async fn test_pool_rotate_verkey_fails() {
use super::*;

Expand All @@ -86,7 +90,7 @@ mod test {
use crate::utils::devsetup::*;
use crate::utils::mockdata::mockdata_pool;

SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
enable_pool_mocks();

PoolMocks::set_next_pool_response(mockdata_pool::RESPONSE_REQNACK);
Expand Down
12 changes: 8 additions & 4 deletions aries_vcx/src/common/primitives/credential_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ pub mod integration_tests {
use crate::common::primitives::credential_definition::generate_cred_def;
use crate::common::primitives::revocation_registry::generate_rev_reg;
use crate::common::test_utils::create_and_write_test_schema;
use crate::utils::constants::DEFAULT_SCHEMA_ATTRS;
use crate::utils::constants::{DEFAULT_SCHEMA_ATTRS, TAILS_DIR};
use crate::utils::devsetup::SetupProfile;
use crate::utils::get_temp_dir_path;

#[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;

Expand Down Expand Up @@ -328,7 +329,7 @@ pub mod integration_tests {
#[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_read = Arc::clone(&setup.profile).inject_anoncreds_ledger_read();
Expand All @@ -350,11 +351,14 @@ pub mod integration_tests {
.await
.unwrap();

let path = get_temp_dir_path(TAILS_DIR);
std::fs::create_dir_all(&path).unwrap();

let (rev_reg_def_id, rev_reg_def_json, rev_reg_entry_json) = generate_rev_reg(
&setup.profile,
&setup.institution_did,
&cred_def_id,
"tails.txt",
path.to_str().unwrap(),
2,
"tag1",
)
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 All @@ -41,15 +41,15 @@ pub mod integration_tests {
)
.await;

assert_eq!(rc.unwrap_err().kind(), AriesVcxErrorKind::LibindyInvalidStructure);
assert_eq!(rc.unwrap_err().kind(), AriesVcxErrorKind::InvalidInput);
})
.await;
}

#[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 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
Loading

0 comments on commit 1222ef7

Please sign in to comment.