Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
  • Loading branch information
mirgee committed Jul 1, 2021
1 parent 5a080a6 commit 03cd4e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ members = [
debug = true
panic = 'unwind'
incremental = false

[profile.dev]
split-debuginfo = "unpacked"
12 changes: 6 additions & 6 deletions libvcx/src/aries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub mod test {
alice.credential_handle = credential_handle;

credential::send_credential_request(alice.credential_handle, alice_connection_by_handle).unwrap();
assert_eq!(2, credential::get_state(alice.credential_handle).unwrap());
assert_eq!(1, credential::get_state(alice.credential_handle).unwrap());
}

faber.send_credential();
Expand All @@ -183,11 +183,11 @@ pub mod test {
let credentials = alice.get_credentials_for_presentation();

disclosed_proof::generate_proof(alice.presentation_handle, credentials.to_string(), String::from("{}")).unwrap();
assert_eq!(3, disclosed_proof::get_state(alice.presentation_handle).unwrap());
assert_eq!(1, disclosed_proof::get_state(alice.presentation_handle).unwrap());

let alice_connection_by_handle = connection::store_connection(alice.connection.clone()).unwrap();
disclosed_proof::send_proof(alice.presentation_handle, alice_connection_by_handle).unwrap();
assert_eq!(2, disclosed_proof::get_state(alice.presentation_handle).unwrap());
assert_eq!(3, disclosed_proof::get_state(alice.presentation_handle).unwrap());
}

faber.verify_presentation();
Expand Down Expand Up @@ -235,7 +235,7 @@ pub mod test {

let alice_connection_by_handle = connection::store_connection(alice.connection.clone()).unwrap();
credential::send_credential_request(alice.credential_handle, alice_connection_by_handle).unwrap();
assert_eq!(2, credential::get_state(alice.credential_handle).unwrap());
assert_eq!(1, credential::get_state(alice.credential_handle).unwrap());
}

faber.send_credential();
Expand All @@ -255,11 +255,11 @@ pub mod test {
let credentials = alice.get_credentials_for_presentation();

disclosed_proof::generate_proof(alice.presentation_handle, credentials.to_string(), String::from("{}")).unwrap();
assert_eq!(3, disclosed_proof::get_state(alice.presentation_handle).unwrap());
assert_eq!(1, disclosed_proof::get_state(alice.presentation_handle).unwrap());

let alice_connection_by_handle = connection::store_connection(alice.connection.clone()).unwrap();
disclosed_proof::send_proof(alice.presentation_handle, alice_connection_by_handle).unwrap();
assert_eq!(2, disclosed_proof::get_state(alice.presentation_handle).unwrap());
assert_eq!(3, disclosed_proof::get_state(alice.presentation_handle).unwrap());
}

faber.verify_presentation();
Expand Down
13 changes: 8 additions & 5 deletions libvcx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ mod tests {
use crate::api_lib::api_handle::issuer_credential;
use crate::api_lib::api_handle::proof;
use crate::api_lib::ProofStateType;
use crate::api_lib::VcxStateType;
use crate::filters;
use crate::settings;
use crate::utils::{
Expand All @@ -69,6 +68,10 @@ mod tests {
};
use crate::utils::devsetup::*;
use crate::utils::devsetup_agent::test::{Alice, Faber, TestAgent};
use crate::aries::handlers::issuance::holder::holder::HolderState;
use crate::aries::handlers::issuance::issuer::issuer::IssuerState;
use crate::aries::handlers::proof_presentation::prover::prover::ProverState;
use crate::aries::handlers::proof_presentation::verifier::verifier::VerifierState;

use super::*;

Expand Down Expand Up @@ -179,7 +182,7 @@ mod tests {
let offers = serde_json::to_string(&offers[0]).unwrap();
info!("send_cred_req :: creating credential from offer");
let credential = credential::credential_create_with_offer("TEST_CREDENTIAL", &offers).unwrap();
assert_eq!(VcxStateType::VcxStateRequestReceived as u32, credential::get_state(credential).unwrap());
assert_eq!(HolderState::OfferReceived as u32, credential::get_state(credential).unwrap());
info!("send_cred_req :: sending credential request");
credential::send_credential_request(credential, connection).unwrap();
thread::sleep(Duration::from_millis(2000));
Expand All @@ -191,7 +194,7 @@ mod tests {
info!("send_credential >>> getting offers");
assert_eq!(issuer_credential::is_revokable(handle_issuer_credential).unwrap(), revokable);
issuer_credential::update_state(handle_issuer_credential, None, issuer_to_consumer).unwrap();
assert_eq!(VcxStateType::VcxStateRequestReceived as u32, issuer_credential::get_state(handle_issuer_credential).unwrap());
assert_eq!(IssuerState::RequestReceived as u32, issuer_credential::get_state(handle_issuer_credential).unwrap());
assert_eq!(issuer_credential::is_revokable(handle_issuer_credential).unwrap(), revokable);

info!("send_credential >>> sending credential");
Expand All @@ -202,7 +205,7 @@ mod tests {
info!("send_credential >>> storing credential");
assert_eq!(credential::is_revokable(handle_holder_credential).unwrap(), revokable);
credential::update_state(handle_holder_credential, None, consumer_to_issuer).unwrap();
assert_eq!(VcxStateType::VcxStateAccepted as u32, credential::get_state(handle_holder_credential).unwrap());
assert_eq!(HolderState::Finished as u32, credential::get_state(handle_holder_credential).unwrap());
assert_eq!(credential::is_revokable(handle_holder_credential).unwrap(), revokable);

if revokable {
Expand Down Expand Up @@ -254,7 +257,7 @@ mod tests {
disclosed_proof::send_proof(proof_handle, connection_handle).unwrap();
info!("generate_and_send_proof :: proof sent");

assert_eq!(VcxStateType::VcxStateOfferSent as u32, disclosed_proof::get_state(proof_handle).unwrap());
assert_eq!(ProverState::PresentationSent as u32, disclosed_proof::get_state(proof_handle).unwrap());
thread::sleep(Duration::from_millis(5000));
}

Expand Down
20 changes: 10 additions & 10 deletions libvcx/src/utils/devsetup_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ pub mod test {
let connection_by_handle = connection::store_connection(self.connection.clone()).unwrap();
issuer_credential::send_credential_offer(self.credential_handle, connection_by_handle, None).unwrap();
issuer_credential::update_state(self.credential_handle, None, connection_by_handle).unwrap();
assert_eq!(2, issuer_credential::get_state(self.credential_handle).unwrap());
assert_eq!(1, issuer_credential::get_state(self.credential_handle).unwrap());
}

pub fn send_credential(&mut self) {
self.activate().unwrap();
let connection_by_handle = connection::store_connection(self.connection.clone()).unwrap();
issuer_credential::update_state(self.credential_handle, None, connection_by_handle).unwrap();
assert_eq!(3, issuer_credential::get_state(self.credential_handle).unwrap());
assert_eq!(2, issuer_credential::get_state(self.credential_handle).unwrap());

issuer_credential::send_credential(self.credential_handle, connection_by_handle).unwrap();
issuer_credential::update_state(self.credential_handle, None, connection_by_handle).unwrap();
Expand All @@ -258,18 +258,18 @@ pub mod test {
pub fn request_presentation(&mut self) {
self.activate().unwrap();
self.presentation_handle = self.create_presentation_request();
assert_eq!(1, proof::get_state(self.presentation_handle).unwrap());
assert_eq!(0, proof::get_state(self.presentation_handle).unwrap());

let connection_by_handle = connection::store_connection(self.connection.clone()).unwrap();
proof::send_proof_request(self.presentation_handle, connection_by_handle, None).unwrap();
proof::update_state(self.presentation_handle, None, connection_by_handle).unwrap();

assert_eq!(2, proof::get_state(self.presentation_handle).unwrap());
assert_eq!(1, proof::get_state(self.presentation_handle).unwrap());
}

pub fn verify_presentation(&mut self) {
self.activate().unwrap();
self.update_proof_state(4, aries::messages::status::Status::Success.code())
self.update_proof_state(2, aries::messages::status::Status::Success.code())
}

pub fn update_proof_state(&mut self, expected_state: u32, expected_status: u32) {
Expand Down Expand Up @@ -363,17 +363,17 @@ pub mod test {
let offer_json = serde_json::to_string(&offer).unwrap();

self.credential_handle = credential::credential_create_with_offer("degree", &offer_json).unwrap();
assert_eq!(3, credential::get_state(self.credential_handle).unwrap());
assert_eq!(0, credential::get_state(self.credential_handle).unwrap());

credential::send_credential_request(self.credential_handle, connection_by_handle).unwrap();
assert_eq!(2, credential::get_state(self.credential_handle).unwrap());
assert_eq!(1, credential::get_state(self.credential_handle).unwrap());
}

pub fn accept_credential(&mut self) {
self.activate().unwrap();
let connection_by_handle = connection::store_connection(self.connection.clone()).unwrap();
credential::update_state(self.credential_handle, None, connection_by_handle).unwrap();
assert_eq!(4, credential::get_state(self.credential_handle).unwrap());
assert_eq!(2, credential::get_state(self.credential_handle).unwrap());
assert_eq!(aries::messages::status::Status::Success.code(), credential::get_credential_status(self.credential_handle).unwrap());
}

Expand Down Expand Up @@ -410,11 +410,11 @@ pub mod test {
let credentials = self.get_credentials_for_presentation();

disclosed_proof::generate_proof(self.presentation_handle, credentials.to_string(), String::from("{}")).unwrap();
assert_eq!(3, disclosed_proof::get_state(self.presentation_handle).unwrap());
assert_eq!(1, disclosed_proof::get_state(self.presentation_handle).unwrap());

let connection_by_handle = connection::store_connection(self.connection.clone()).unwrap();
disclosed_proof::send_proof(self.presentation_handle, connection_by_handle).unwrap();
assert_eq!(2, disclosed_proof::get_state(self.presentation_handle).unwrap());
assert_eq!(3, disclosed_proof::get_state(self.presentation_handle).unwrap());
}

pub fn decline_presentation_request(&mut self) {
Expand Down

0 comments on commit 03cd4e5

Please sign in to comment.