Skip to content

Commit

Permalink
fix(aries_vcx): make tests run in parallel
Browse files Browse the repository at this point in the history
fixes #1050

Signed-off-by: Ondrej Prazak <[email protected]>
  • Loading branch information
xprazak2 committed Nov 10, 2023
1 parent d4e0bb1 commit 1b8eb0c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ jobs:
with:
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }}
- name: "Run aries-vcx integration tests"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdrtools_wallet,credx -- --ignored;
run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdrtools_wallet,credx -- --ignored;

test-integration-aries-vcx-mysql:
needs: workflow-setup
Expand All @@ -295,7 +295,7 @@ jobs:
with:
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }}
- name: "Run aries_vcx tests: mysql_test"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored;
run: cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored;

test-integration-aries-vcx-vdrproxy:
needs: [workflow-setup, build-docker-vdrproxy]
Expand All @@ -319,7 +319,7 @@ jobs:
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }}
skip-vdrproxy-setup: false
- name: "Run aries_vcx tests: vdrproxy_test"
run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger,credx -- --ignored
run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger,credx -- --ignored
- name: "Collect docker logs on failure"
if: failure()
uses: ./.github/actions/upload-docker-logs
Expand Down Expand Up @@ -354,7 +354,7 @@ jobs:
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSON }}
- name: "Run resolver tests"
run: |
RUST_TEST_THREADS=1 cargo test --examples -p did_doc -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov -p did_resolver_web -p did_doc_sov -p did_key -p did_peer --test "*"
cargo test --examples -p did_doc -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov -p did_resolver_web -p did_doc_sov -p did_key -p did_peer --test "*"
test-integration-node-wrapper:
needs: workflow-setup
Expand Down
25 changes: 17 additions & 8 deletions aries_vcx/tests/test_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::utils::{
create_connections_via_oob_invite, create_connections_via_pairwise_invite,
create_connections_via_public_invite,
},
test_agent::{create_test_agent, create_test_agent_trustee},
test_agent::{create_test_agent, create_test_agent_trustee, create_test_endorser},
};

pub mod utils;
Expand Down Expand Up @@ -179,19 +179,28 @@ async fn test_agency_pool_establish_connection_via_pairwise_invite() -> Result<(
#[ignore]
async fn test_agency_pool_establish_connection_via_out_of_band() -> Result<(), Box<dyn Error>> {
let setup = SetupPoolDirectory::init().await;
let mut institution = create_test_agent_trustee(setup.genesis_file_path.clone()).await;
let institution = create_test_agent_trustee(setup.genesis_file_path.clone()).await;

let mut endorser = create_test_endorser(
institution.ledger_write,
institution.wallet,
&setup.genesis_file_path,
&institution.institution_did,
)
.await?;

let mut consumer = create_test_agent(setup.genesis_file_path).await;
create_service(&institution).await;
create_service(&endorser).await;

let (consumer_to_institution, institution_to_consumer) =
create_connections_via_oob_invite(&mut consumer, &mut institution).await;
let (consumer_to_endorser, endorser_to_consumer) =
create_connections_via_oob_invite(&mut consumer, &mut endorser).await;

let basic_message = build_basic_message("Hello TestAgent".to_string());
if let AriesMessage::BasicMessage(message) = send_and_receive_message(
&consumer,
&institution,
&institution_to_consumer,
&consumer_to_institution,
&endorser,
&endorser_to_consumer,
&consumer_to_endorser,
&basic_message.clone().into(),
)
.await
Expand Down
54 changes: 40 additions & 14 deletions aries_vcx/tests/test_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use test_utils::{
use crate::utils::{
create_and_publish_test_rev_reg, create_and_write_test_cred_def, create_and_write_test_schema,
scenarios::attr_names_address_list,
test_agent::{create_test_agent, create_test_agent_trustee},
test_agent::{create_test_agent, create_test_agent_trustee, create_test_endorser},
};

pub mod utils;
Expand Down Expand Up @@ -136,18 +136,31 @@ async fn test_pool_rotate_verkey() -> Result<(), Box<dyn Error>> {
#[ignore]
async fn test_pool_add_get_service() -> Result<(), Box<dyn Error>> {
let setup = build_setup_profile().await;
let did = setup.institution_did.clone();
let acme = create_test_endorser(
setup.ledger_write,
setup.wallet,
&setup.genesis_file_path,
&setup.institution_did,
)
.await?;

let expect_service = AriesService::default();
write_endpoint_legacy(&setup.wallet, &setup.ledger_write, &did, &expect_service).await?;
write_endpoint_legacy(
&acme.wallet,
&acme.ledger_write,
&acme.institution_did,
&expect_service,
)
.await?;
thread::sleep(Duration::from_millis(50));
let service = get_service(&setup.ledger_read, &did).await?;
let service = get_service(&acme.ledger_read, &acme.institution_did).await?;
assert_eq!(expect_service, service);

// clean up written legacy service
clear_attr(
&setup.wallet,
&setup.ledger_write,
&setup.institution_did,
&acme.wallet,
&acme.ledger_write,
&acme.institution_did,
"service",
)
.await?;
Expand Down Expand Up @@ -196,15 +209,28 @@ async fn test_pool_write_new_endorser_did() -> Result<(), Box<dyn Error>> {
#[ignore]
async fn test_pool_add_get_service_public() -> Result<(), Box<dyn Error>> {
let setup = build_setup_profile().await;
let did = setup.institution_did.clone();
let acme = create_test_endorser(
setup.ledger_write,
setup.wallet,
&setup.genesis_file_path,
&setup.institution_did,
)
.await?;

let create_service = EndpointDidSov::create()
.set_service_endpoint("https://example.org".parse()?)
.set_routing_keys(Some(vec!["did:sov:456".into()]));
write_endpoint(&setup.wallet, &setup.ledger_write, &did, &create_service).await?;
write_endpoint(
&acme.wallet,
&acme.ledger_write,
&acme.institution_did,
&create_service,
)
.await?;
thread::sleep(Duration::from_millis(50));
let service = get_service(&setup.ledger_read, &did).await?;
let service = get_service(&acme.ledger_read, &acme.institution_did).await?;
let expect_recipient_key =
get_verkey_from_ledger(&setup.ledger_read, &setup.institution_did).await?;
get_verkey_from_ledger(&acme.ledger_read, &acme.institution_did).await?;
let expect_service = AriesService::default()
.set_service_endpoint("https://example.org".parse()?)
.set_recipient_keys(vec![expect_recipient_key])
Expand All @@ -213,9 +239,9 @@ async fn test_pool_add_get_service_public() -> Result<(), Box<dyn Error>> {

// clean up written endpoint
clear_attr(
&setup.wallet,
&setup.ledger_write,
&setup.institution_did,
&acme.wallet,
&acme.ledger_write,
&acme.institution_did,
"endpoint",
)
.await?;
Expand Down
41 changes: 39 additions & 2 deletions aries_vcx/tests/utils/test_agent.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#![allow(clippy::diverging_sub_expression)]

use aries_vcx::global::settings::DEFAULT_LINK_SECRET_ALIAS;
use aries_vcx::{
common::ledger::transactions::write_endorser_did, global::settings::DEFAULT_LINK_SECRET_ALIAS,
};
use aries_vcx_core::{
anoncreds::base_anoncreds::BaseAnonCreds,
ledger::base_ledger::{
AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite,
},
wallet::base_wallet::BaseWallet,
wallet::{base_wallet::BaseWallet, indy::wallet::get_verkey_from_wallet},
};
use test_utils::{
constants::TRUSTEE_SEED,
Expand Down Expand Up @@ -81,3 +83,38 @@ pub async fn create_test_agent(
> {
create_test_agent_from_seed(&generate_random_seed(), genesis_file_path).await
}

pub async fn create_test_endorser<LW, W>(
ledger_write: LW,
trustee_wallet: W,
genesis_file_path: &str,
trustee_did: &str,
) -> Result<
TestAgent<
impl IndyLedgerRead + AnoncredsLedgerRead,
impl IndyLedgerWrite + AnoncredsLedgerWrite,
impl BaseAnonCreds,
impl BaseWallet,
>,
Box<dyn std::error::Error>,
>
where
LW: IndyLedgerWrite + AnoncredsLedgerWrite,
W: BaseWallet,
{
let acme = create_test_agent(genesis_file_path.to_string()).await;
let acme_vk =
get_verkey_from_wallet(acme.wallet.get_wallet_handle(), &acme.institution_did).await?;

write_endorser_did(
&trustee_wallet,
&ledger_write,
&trustee_did,
&acme.institution_did,
&acme_vk,
None,
)
.await?;

Ok(acme)
}

0 comments on commit 1b8eb0c

Please sign in to comment.