diff --git a/Jenkinsfile.cd b/Jenkinsfile.cd index 8bb32f0fb6..1e572acfa4 100644 --- a/Jenkinsfile.cd +++ b/Jenkinsfile.cd @@ -356,8 +356,15 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { libindyBuildFinished[env_name] = true - echo "${env_name} Libindy Test: Test" testEnv.inside("--network=${network_name}") { + echo "${env_name} Libindy Test: Test Libindy submodules" + + for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) { + testLibindyComponent(component) + } + + echo "${env_name} Libindy Test: Test" + def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\"" sh """ @@ -382,6 +389,14 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { } } +def testLibindyComponent(directory) { + sh """ + cd ${directory} + RUST_BACKTRACE=1 cargo test --release --no-run + RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release + """ +} + def linuxVcxBuild(file, env_name, network_name) { def poolInst try { diff --git a/Jenkinsfile.ci b/Jenkinsfile.ci index e9f0130f5f..2bc2902338 100644 --- a/Jenkinsfile.ci +++ b/Jenkinsfile.ci @@ -480,8 +480,15 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { libindyBuildFinished[env_name] = true - echo "${env_name} Libindy Test: Test" testEnv.inside("--network=${network_name}") { + echo "${env_name} Libindy Test: Test Libindy submodules" + + for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) { + testLibindyComponent(component) + } + + echo "${env_name} Libindy Test: Test" + def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\"" sh """ @@ -506,6 +513,14 @@ def linuxLibindyBuild(file, env_name, network_name, full_testing) { } } +def testLibindyComponent(directory) { + sh """ + cd ${directory} + RUST_BACKTRACE=1 cargo test --no-run + RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test + """ +} + def linuxVcxBuild(file, env_name, network_name) { def poolInst try { diff --git a/experimental/plugins/postgres_storage/src/lib.rs b/experimental/plugins/postgres_storage/src/lib.rs index 8cd71b2f18..bf7589124b 100644 --- a/experimental/plugins/postgres_storage/src/lib.rs +++ b/experimental/plugins/postgres_storage/src/lib.rs @@ -276,7 +276,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error adding a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -311,7 +314,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error updating a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -353,7 +359,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error getting a record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -500,7 +509,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error adding record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -534,7 +546,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error updating record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -569,7 +584,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error deleting record tags. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -599,7 +617,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemNotFound => ErrorCode::WalletItemNotFound, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error deleting record. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -634,7 +655,8 @@ impl PostgresWallet { ErrorCode::Success }, - Err(_err) => { + Err(err) => { + error!("Error getting storage metadata. Error details: {:?}", err); ErrorCode::CommonInvalidState } } @@ -661,7 +683,10 @@ impl PostgresWallet { Err(err) => { match err { WalletStorageError::ItemAlreadyExists => ErrorCode::WalletItemAlreadyExists, - _ => ErrorCode::WalletStorageError + _ => { + error!("Error setting storage metadata. Error details: {:?}", err); + ErrorCode::WalletStorageError + } } } } @@ -703,7 +728,7 @@ impl PostgresWallet { let storage = &*wallet_box; let res = storage.search(&type_.as_bytes(), &query, Some(&options_json)); - + match res { Ok(iter) => { // iter: Box @@ -755,7 +780,7 @@ impl PostgresWallet { let storage = &*wallet_box; let res = storage.get_all(); - + match res { Ok(iter) => { // iter: Box @@ -1023,10 +1048,11 @@ fn _tag_names_from_json(json: &str) -> Result, WalletStorageError> #[cfg(test)] mod tests { use super::*; - use std::env; + use std::{env, thread}; use std::ffi::{CString, CStr}; use std::{slice, ptr}; use wql::storage::ENCRYPTED_KEY_LEN; + use rand::{thread_rng, Rng}; #[test] fn postgres_wallet_crud_works() { @@ -1035,35 +1061,35 @@ mod tests { let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let metadata = _metadata(); + let metadata = _metadata_cstring(); // open wallet - should return error let mut handle: i32 = -1; - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::WalletNotFoundError); - + // create wallet - let err = PostgresWallet::create(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::create(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), metadata.as_ptr()); assert_eq!(err, ErrorCode::Success); // open wallet - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::Success); // ensure we can fetch metadata let mut metadata_handle: i32 = -1; let mut metadata_ptr: *const c_char = ptr::null_mut(); - let err = PostgresWallet::get_storage_metadata(handle, - &mut metadata_ptr, + let err = PostgresWallet::get_storage_metadata(handle, + &mut metadata_ptr, &mut metadata_handle); assert_eq!(err, ErrorCode::Success); let _metadata = unsafe { CStr::from_ptr(metadata_ptr).to_bytes() }; @@ -1080,8 +1106,8 @@ mod tests { let mut metadata_handle2: i32 = -1; let mut metadata_ptr2: *const c_char = ptr::null_mut(); - let err = PostgresWallet::get_storage_metadata(handle, - &mut metadata_ptr2, + let err = PostgresWallet::get_storage_metadata(handle, + &mut metadata_ptr2, &mut metadata_handle2); assert_eq!(err, ErrorCode::Success); let _metadata2 = unsafe { CStr::from_ptr(metadata_ptr2).to_bytes() }; @@ -1096,15 +1122,15 @@ mod tests { assert_eq!(err, ErrorCode::Success); // delete wallet - let err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); // open wallet - should return error - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::WalletNotFoundError); } @@ -1198,7 +1224,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1296,7 +1322,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1373,7 +1399,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1392,7 +1418,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::WalletItemNotFound, err); @@ -1428,7 +1454,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1450,7 +1476,7 @@ mod tests { let err = PostgresWallet::get_record(handle, type1_.as_ptr(), id1.as_ptr(), - get_options.as_ptr() as *const i8, + get_options.as_ptr(), &mut rec_handle); assert_match!(ErrorCode::Success, err); @@ -1516,7 +1542,7 @@ mod tests { let mut search_handle: i32 = -1; let err = PostgresWallet::search_all_records(handle, &mut search_handle); assert_match!(ErrorCode::Success, err); - + let mut rec_count: i32 = 0; let mut search_continue: bool = true; while search_continue { @@ -1611,13 +1637,13 @@ mod tests { println!("query_json {:?}", query_json); let options_json = _search_options(true, true, true, true, true); println!("Options {:?}", options_json); - let err = PostgresWallet::search_records(handle, - type1_.as_ptr(), - query_json.as_ptr(), - options_json.as_ptr() as *const i8, + let err = PostgresWallet::search_records(handle, + type1_.as_ptr(), + query_json.as_ptr(), + options_json.as_ptr() as *const i8, &mut search_handle); assert_match!(ErrorCode::Success, err); - + let mut rec_count: i32 = 0; let mut search_continue: bool = true; while search_continue { @@ -1667,20 +1693,20 @@ mod tests { let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let metadata = _metadata(); + let metadata = _metadata_cstring(); // create wallet - let err = PostgresWallet::create(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::create(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), metadata.as_ptr()); assert_eq!(err, ErrorCode::Success); // open wallet let mut handle: i32 = -1; - let err = PostgresWallet::open(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), - credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::open(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr()), &mut handle); assert_eq!(err, ErrorCode::Success); @@ -1697,30 +1723,39 @@ mod tests { assert_eq!(err, ErrorCode::Success); // delete wallet - let err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); } fn _cleanup() { + let ten_millis = std::time::Duration::from_millis(1); + let now = time::now(); + thread::sleep(ten_millis); + let id = _wallet_id(); let config = _wallet_config(); let credentials = _wallet_credentials(); - let err = PostgresWallet::init(config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let err = PostgresWallet::init(config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); assert_eq!(err, ErrorCode::Success); - let _err = PostgresWallet::delete(id.as_ptr(), - config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), + let _err = PostgresWallet::delete(id.as_ptr(), + config.as_ref().map_or(ptr::null(), |x| x.as_ptr()), credentials.as_ref().map_or(ptr::null(), |x| x.as_ptr())); } + fn _random_string(len: usize) -> String { + thread_rng().gen_ascii_chars().take(len).collect() + } + fn _wallet_id() -> CString { - CString::new("my_walle1").unwrap() + CString::new("walle1").unwrap() } + fn _wallet_config() -> Option { let wallet_scheme = env::var("WALLET_SCHEME"); match wallet_scheme { @@ -1758,7 +1793,7 @@ mod tests { .map_or(Ok(None), |r| r.map(Some)).unwrap() } - fn _metadata() -> Vec { + fn _metadata() -> Vec { return vec![ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, @@ -1771,6 +1806,11 @@ mod tests { ]; } + fn _metadata_cstring() -> CString { + let foo = _metadata(); + CString::new(foo).unwrap() + } + fn _metadata2() -> Vec { return vec![ 2, 3, 4, 5, 6, 7, 8, 9, @@ -1881,12 +1921,13 @@ mod tests { v } - fn _fetch_options(type_: bool, value: bool, tags: bool) -> String { - json!({ + fn _fetch_options(type_: bool, value: bool, tags: bool) -> CString { + let get_options_string = json!({ "retrieveType": type_, "retrieveValue": value, "retrieveTags": tags, - }).to_string() + }).to_string(); + CString::new(get_options_string).unwrap() } fn _search_options(retrieve_records: bool, retrieve_total_count: bool, retrieve_value: bool, retrieve_tags: bool, retrieve_type: bool) -> String { diff --git a/experimental/plugins/postgres_storage/src/postgres_storage.rs b/experimental/plugins/postgres_storage/src/postgres_storage.rs index 9f1d82d27b..d6044c5545 100644 --- a/experimental/plugins/postgres_storage/src/postgres_storage.rs +++ b/experimental/plugins/postgres_storage/src/postgres_storage.rs @@ -956,7 +956,6 @@ impl WalletStorage for PostgresStorage { } Some(tags) } else { None }; - Ok(StorageRecord::new(id.to_vec(), value, type_.map(|val| val.to_vec()), tags)) } diff --git a/libindy/Cargo.lock b/libindy/Cargo.lock index edf713c87d..16a29541f6 100644 --- a/libindy/Cargo.lock +++ b/libindy/Cargo.lock @@ -152,11 +152,6 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "1.2.1" @@ -747,7 +742,6 @@ version = "0.1.0" dependencies = [ "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -788,14 +782,13 @@ dependencies = [ "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indy-wallet" version = "0.1.0" dependencies = [ - "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "indy-api-types 0.1.0", "indy-utils 0.1.0", @@ -809,7 +802,6 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "sodiumoxide 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -852,7 +844,6 @@ version = "1.14.2" dependencies = [ "android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -868,7 +859,6 @@ dependencies = [ "indy-sys 1.14.2", "indy-utils 0.1.0", "indy-wallet 0.1.0", - "int_traits 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -877,11 +867,9 @@ dependencies = [ "named_type 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "named_type_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", - "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1981,7 +1969,6 @@ dependencies = [ "checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" "checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" diff --git a/libindy/Cargo.toml b/libindy/Cargo.toml index 3b8ff1b9f4..0c2eaa6443 100644 --- a/libindy/Cargo.toml +++ b/libindy/Cargo.toml @@ -14,32 +14,19 @@ path = "src/lib.rs" crate-type = ["staticlib", "rlib", "cdylib"] [features] -default = ["bn_openssl", "ed25519_sign_sodium", "ed25519_box_sodium", "sealedbox_sodium", "base58_rust_base58", "base64_rust_base64", "xsalsa20_sodium", "chacha20poly1305_ietf_sodium", "pair_amcl", "hash_openssl", "local_nodes_pool", "revocation_tests", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "memzero_sodium", "randombytes_sodium"] -bn_openssl = ["openssl", "int_traits"] -ed25519_sign_sodium = ["sodiumoxide"] -ed25519_box_sodium = ["sodiumoxide"] -sealedbox_sodium = ["sodiumoxide"] +default = ["base58_rust_base58", "pair_amcl", "local_nodes_pool", "revocation_tests"] base58_rust_base58 = ["rust-base58"] -base64_rust_base64 = ["base64"] -xsalsa20_sodium = ["sodiumoxide"] -chacha20poly1305_ietf_sodium = ["sodiumoxide"] -pwhash_argon2i13_sodium = ["sodiumoxide"] pair_amcl = ["ursa"] -hash_openssl = ["openssl"] local_nodes_pool = [] revocation_tests = [] force_full_interaction_tests = [] sodium_static = [] -hmacsha256_sodium = ["sodiumoxide"] -memzero_sodium = ["sodiumoxide"] -randombytes_sodium = ["sodiumoxide"] only_high_cases = [] # Causes the build to fail on all warnings fatal_warnings = [] [dependencies] -int_traits = { version = "0.1.1", optional = true } env_logger = "0.6.2" etcommon-rlp = "0.2.4" failure = "0.1.5" @@ -48,21 +35,15 @@ libc = "0.2.66" log = "0.4.8" log-derive = "0.3.0" derivative = "1.0.2" -dirs = "2.0.2" -openssl = { version = "0.10", optional = true } backtrace = "=0.3.11" -owning_ref = "0.4" rand = "0.7.0" -rusqlite = "0.20" # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document. rust-base58 = {version = "0.0.4", optional = true} -base64 = {version = "0.10.1", optional = true} serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" sha2 = "0.8" sha3 = "0.8" rmp-serde = "0.13.7" -sodiumoxide = {version = "0.0.16", optional = true} time = "0.1.42" threadpool = "1.7.1" zmq = "0.9.1" @@ -91,14 +72,15 @@ features = ["bn_openssl", "pair_amcl", "serialization", "native_secp256k1", "cl" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.5" -[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] -rusqlite = { version = "0.20", features=["bundled"] } [dev-dependencies] criterion = "0.2" indy = { path = "../wrappers/rust" } indy-sys = { path = "../wrappers/rust/indy-sys" } futures = "0.1.28" +sodiumoxide = {version = "0.0.16"} +openssl = "0.10" +dirs = "2.0.2" [[bench]] name = "wallet" diff --git a/libindy/ci/centos.dockerfile b/libindy/ci/centos.dockerfile index cb759fe42a..65f96c1ed6 100755 --- a/libindy/ci/centos.dockerfile +++ b/libindy/ci/centos.dockerfile @@ -22,12 +22,12 @@ RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - RUN yum -y install nodejs RUN cd /tmp && \ - curl https://download.libsodium.org/libsodium/releases/old/unsupported/libsodium-1.0.14.tar.gz | tar -xz && \ - cd /tmp/libsodium-1.0.14 && \ + curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz | tar -xz && \ + cd /tmp/libsodium-1.0.18 && \ ./configure && \ make && \ make install && \ - rm -rf /tmp/libsodium-1.0.14 + rm -rf /tmp/libsodium-1.0.18 ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib diff --git a/libindy/ci/ubuntu.dockerfile b/libindy/ci/ubuntu.dockerfile index fdc9b7fb60..2d3e942be3 100755 --- a/libindy/ci/ubuntu.dockerfile +++ b/libindy/ci/ubuntu.dockerfile @@ -39,12 +39,12 @@ RUN pip3 install -U \ deb-pkg-tools RUN cd /tmp && \ - curl https://download.libsodium.org/libsodium/releases/old/unsupported/libsodium-1.0.14.tar.gz | tar -xz && \ - cd /tmp/libsodium-1.0.14 && \ - ./configure --disable-shared && \ + curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz | tar -xz && \ + cd /tmp/libsodium-1.0.18 && \ + ./configure && \ make && \ make install && \ - rm -rf /tmp/libsodium-1.0.14 + rm -rf /tmp/libsodium-1.0.18 RUN apt-get update && apt-get install openjdk-8-jdk -y ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 diff --git a/libindy/indy-api-types/Cargo.toml b/libindy/indy-api-types/Cargo.toml index b07fd08829..b2b030abcb 100644 --- a/libindy/indy-api-types/Cargo.toml +++ b/libindy/indy-api-types/Cargo.toml @@ -12,7 +12,6 @@ casting_errors = ["openssl", "rust-base58", "rusqlite", "zmq", "ed25519-dalek", [dependencies] failure = "0.1.5" -lazy_static = "1.3" libc = "0.2.66" log = "0.4.8" openssl = {version = "0.10", optional = true} diff --git a/libindy/indy-api-types/src/lib.rs b/libindy/indy-api-types/src/lib.rs index 403891d263..1c5b2c7831 100644 --- a/libindy/indy-api-types/src/lib.rs +++ b/libindy/indy-api-types/src/lib.rs @@ -1,5 +1,3 @@ -extern crate lazy_static; - #[macro_use] extern crate log; @@ -31,6 +29,7 @@ pub const INVALID_COMMAND_HANDLE : CommandHandle = 0; pub type StorageHandle = i32; pub type SearchHandle = i32; +pub const INVALID_SEARCH_HANDLE : SearchHandle = 0; pub mod domain; diff --git a/libindy/indy-utils/Cargo.toml b/libindy/indy-utils/Cargo.toml index 16dc72338d..a10e026692 100644 --- a/libindy/indy-utils/Cargo.toml +++ b/libindy/indy-utils/Cargo.toml @@ -6,12 +6,17 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["base64_rust_base64", "chacha20poly1305_ietf_sodium", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "hash_openssl"] +default = ["base64_rust_base64", "ed25519_sign_sodium", "ed25519_box_sodium", "sealedbox_sodium", "base64_rust_base64", "xsalsa20_sodium", "chacha20poly1305_ietf_sodium", "hash_openssl", "pwhash_argon2i13_sodium", "hmacsha256_sodium", "randombytes_sodium"] base64_rust_base64 = [] +ed25519_sign_sodium = [] +ed25519_box_sodium = [] +sealedbox_sodium = [] +xsalsa20_sodium = [] chacha20poly1305_ietf_sodium = [] pwhash_argon2i13_sodium = [] hmacsha256_sodium = [] hash_openssl = [] +randombytes_sodium = [] [dependencies] base64 = {version = "0.10.1"} @@ -26,4 +31,8 @@ serde = "1.0.99" serde_json = "1.0.40" serde_derive = "1.0.99" sodiumoxide = {version = "0.0.16"} -time = "0.1.42" +zeroize = "0.9.3" + +[dev-dependencies] +rmp-serde = "0.13.7" +rand = "0.7.0" \ No newline at end of file diff --git a/libindy/indy-utils/src/crypto/base64/rust_base64.rs b/libindy/indy-utils/src/crypto/base64/rust_base64.rs index 01f47a4b30..ec3d0852fc 100644 --- a/libindy/indy-utils/src/crypto/base64/rust_base64.rs +++ b/libindy/indy-utils/src/crypto/base64/rust_base64.rs @@ -13,11 +13,11 @@ pub fn decode(doc: &str) -> Result, IndyError> { } pub fn encode_urlsafe(doc: &[u8]) -> String { - base64::encode_config(doc, base64::URL_SAFE) + base64::encode_config(doc, base64::URL_SAFE) //TODO switch to URL_SAFE_NO_PAD } pub fn decode_urlsafe(doc: &str) -> Result, IndyError> { - base64::decode_config(doc, base64::URL_SAFE) + base64::decode_config(doc, base64::URL_SAFE_NO_PAD) .context("Invalid base64URL_SAFE sequence") .context(IndyErrorKind::InvalidStructure) .map_err(|err| err.into()) @@ -54,4 +54,19 @@ mod tests { assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..]); } -} \ No newline at end of file + + #[test] // aries-396 + fn encode_base64_urlsafe_and_urlsafe_no_pad_compatible() { + let data = "Hello World"; + { + let encoded = base64::encode_config(data, base64::URL_SAFE); + let decoded_data = base64::decode_config(&encoded, base64::URL_SAFE_NO_PAD).unwrap(); + assert_eq!(data.as_bytes().to_vec(), decoded_data); + } + { + let encoded = base64::encode_config(data, base64::URL_SAFE_NO_PAD); + let decoded_data = base64::decode_config(&encoded, base64::URL_SAFE).unwrap(); + assert_eq!(data.as_bytes().to_vec(), decoded_data); + } + } +} diff --git a/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs b/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs index 93aa0ad800..0cef9c71f4 100644 --- a/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs +++ b/libindy/indy-utils/src/crypto/chacha20poly1305_ietf/sodium.rs @@ -239,7 +239,7 @@ mod tests { extern crate rmp_serde; use super::*; - use crate::utils::crypto::randombytes::randombytes; + use crate::crypto::randombytes::randombytes; #[test] fn derivation_argon2i_mod_produces_expected_result() { diff --git a/libindy/src/utils/crypto/ed25519_box/sodium.rs b/libindy/indy-utils/src/crypto/ed25519_box/sodium.rs similarity index 96% rename from libindy/src/utils/crypto/ed25519_box/sodium.rs rename to libindy/indy-utils/src/crypto/ed25519_box/sodium.rs index b15d543bce..c6738c94f8 100644 --- a/libindy/src/utils/crypto/ed25519_box/sodium.rs +++ b/libindy/indy-utils/src/crypto/ed25519_box/sodium.rs @@ -39,8 +39,8 @@ pub fn gen_nonce() -> Nonce { #[cfg(test)] mod tests { use super::*; - use crate::utils::crypto::ed25519_sign; - use crate::utils::crypto::randombytes::randombytes; + use crate::crypto::ed25519_sign; + use crate::crypto::randombytes::randombytes; #[test] fn encrypt_decrypt_works() { diff --git a/libindy/src/utils/crypto/ed25519_sign/sodium.rs b/libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs similarity index 99% rename from libindy/src/utils/crypto/ed25519_sign/sodium.rs rename to libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs index 97ab80b8bd..fced4fb488 100644 --- a/libindy/src/utils/crypto/ed25519_sign/sodium.rs +++ b/libindy/indy-utils/src/crypto/ed25519_sign/sodium.rs @@ -78,7 +78,7 @@ pub fn vk_to_curve25519(pk: &PublicKey) -> Result Ind #[cfg(test)] mod tests { - use indy_wallet::wallet::EncryptedValue; - use indy_wallet::wallet::Keys; - use crate::utils::crypto::hmacsha256; + use crate::wallet::EncryptedValue; + use crate::wallet::Keys; + use indy_utils::crypto::hmacsha256; use super::*; diff --git a/libindy/indy-wallet/src/export_import.rs b/libindy/indy-wallet/src/export_import.rs index 9202768a84..c73fe0a87c 100644 --- a/libindy/indy-wallet/src/export_import.rs +++ b/libindy/indy-wallet/src/export_import.rs @@ -245,13 +245,13 @@ mod tests { use serde_json; - use indy_api_types::domain::wallet::{Metadata, MetadataArgon}; - use indy_wallet::encryption; - use indy_wallet::storage::default::SQLiteStorageType; - use indy_wallet::storage::WalletStorageType; - use indy_wallet::wallet::{Keys, Wallet}; - use crate::utils::crypto::pwhash_argon2i13; - use crate::utils::test; + use crate::{Metadata, MetadataArgon}; + use crate::encryption; + use crate::storage::default::SQLiteStorageType; + use crate::storage::WalletStorageType; + use crate::wallet::{Keys, Wallet}; + use indy_utils::crypto::pwhash_argon2i13; + use indy_utils::test; use super::*; diff --git a/libindy/indy-wallet/src/lib.rs b/libindy/indy-wallet/src/lib.rs index 52fa71843b..f9e76d9557 100644 --- a/libindy/indy-wallet/src/lib.rs +++ b/libindy/indy-wallet/src/lib.rs @@ -11,8 +11,6 @@ extern crate serde; #[macro_use] extern crate serde_derive; -extern crate serde_json; - use std::cell::RefCell; use std::collections::HashMap; use std::fs; @@ -781,6 +779,14 @@ impl Default for SearchOptions { } } +#[cfg(test)] +#[macro_use] +extern crate lazy_static; + +#[cfg(test)] +#[macro_use] +extern crate serde_json; + #[cfg(test)] mod tests { use std::collections::HashMap; @@ -790,9 +796,10 @@ mod tests { use indy_api_types::INVALID_WALLET_HANDLE; use indy_api_types::domain::wallet::KeyDerivationMethod; - use crate::utils::environment; + use indy_utils::environment; use indy_utils::inmem_wallet::InmemWallet; - use crate::utils::test; + use indy_utils::test; + use indy_utils::next_wallet_handle; use super::*; diff --git a/libindy/indy-wallet/src/storage/default/mod.rs b/libindy/indy-wallet/src/storage/default/mod.rs index 42abe0b74b..2d90a6d1a4 100644 --- a/libindy/indy-wallet/src/storage/default/mod.rs +++ b/libindy/indy-wallet/src/storage/default/mod.rs @@ -1,5 +1,4 @@ extern crate owning_ref; -extern crate sodiumoxide; use std; use std::fs; @@ -744,7 +743,7 @@ impl WalletStorageType for SQLiteStorageType { #[cfg(test)] mod tests { - use crate::utils::test; + use indy_utils::test; use super::*; use super::super::Tag; diff --git a/libindy/indy-wallet/src/storage/plugged/mod.rs b/libindy/indy-wallet/src/storage/plugged/mod.rs index b8ab2983a4..de509ab49f 100644 --- a/libindy/indy-wallet/src/storage/plugged/mod.rs +++ b/libindy/indy-wallet/src/storage/plugged/mod.rs @@ -6,7 +6,7 @@ use std::ptr; use libc::c_char; use serde_json; -use indy_api_types::ErrorCode; +use indy_api_types::{ErrorCode, SearchHandle, INVALID_SEARCH_HANDLE}; use indy_api_types::wallet::*; use indy_api_types::errors::prelude::*; use crate::language; @@ -57,7 +57,7 @@ impl Drop for ResourceGuard { #[derive(PartialEq, Debug)] struct PluggedStorageIterator { storage_handle: i32, - search_handle: i32, + search_handle: SearchHandle, options: SearchOptions, fetch_search_next_record_handler: WalletFetchSearchNextRecord, get_search_total_count_handler: WalletGetSearchTotalCount, @@ -70,7 +70,7 @@ struct PluggedStorageIterator { } impl PluggedStorageIterator { - fn new(storage: &PluggedStorage, search_handle: i32, options: SearchOptions) -> Self { + fn new(storage: &PluggedStorage, search_handle: SearchHandle, options: SearchOptions) -> Self { Self { storage_handle: storage.handle, search_handle, @@ -554,7 +554,7 @@ impl WalletStorage for PluggedStorage { } fn get_all(&self) -> IndyResult> { - let mut search_handle: i32 = -1; + let mut search_handle: SearchHandle = INVALID_SEARCH_HANDLE; let err = (self.search_all_records_handler)(self.handle, &mut search_handle); diff --git a/libindy/indy-wallet/src/wallet.rs b/libindy/indy-wallet/src/wallet.rs index 093b44c0f2..8688ec4df4 100644 --- a/libindy/indy-wallet/src/wallet.rs +++ b/libindy/indy-wallet/src/wallet.rs @@ -222,13 +222,13 @@ mod tests { use std::rc::Rc; use std::collections::HashMap; - use indy_api_types::domain::wallet::{Metadata, MetadataArgon}; - use indy_wallet::encryption; - use indy_wallet::wallet::Wallet; - use indy_wallet::storage::WalletStorageType; - use indy_wallet::storage::default::SQLiteStorageType; - use indy_wallet::language::*; - use crate::utils::test; + use crate::{Metadata, MetadataArgon}; + use crate::encryption; + use crate::wallet::Wallet; + use crate::storage::WalletStorageType; + use crate::storage::default::SQLiteStorageType; + use crate::language::*; + use indy_utils::test; macro_rules! jsonstr { ($($x:tt)+) => { diff --git a/libindy/src/api/anoncreds.rs b/libindy/src/api/anoncreds.rs index e08eb93b13..8af9465afe 100644 --- a/libindy/src/api/anoncreds.rs +++ b/libindy/src/api/anoncreds.rs @@ -2250,13 +2250,20 @@ pub extern fn indy_verifier_verify_proof(command_handle: CommandHandle, res } -/// Create revocation state for a credential in the particular time moment. +/// Create revocation state for a credential that corresponds to a particular time. +/// +/// Note that revocation delta must cover the whole registry existence time. +/// You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later with applying a new +/// revocation delta with `indy_update_revocation_state` function. +/// This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. /// /// #Params /// command_handle: command handle to map callback to user context /// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`) /// rev_reg_def_json: revocation registry definition json related to `rev_reg_id` in a credential -/// rev_reg_delta_json: revocation registry definition delta json +/// rev_reg_delta_json: revocation registry delta which covers the whole registry existence time /// timestamp: time represented as a total number of seconds from Unix Epoch. /// cred_rev_id: user credential revocation id in revocation registry (match to `cred_rev_id` in a credential) /// cb: Callback that takes command result as parameter @@ -2312,15 +2319,20 @@ pub extern fn indy_create_revocation_state(command_handle: CommandHandle, res } -/// Create new revocation state for a credential based on existed state -/// at the particular time moment (to reduce calculation time). +/// Create a new revocation state for a credential based on a revocation state created before. +/// Note that provided revocation delta must cover the registry gap from based state creation until the specified time +/// (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). +/// +/// This function reduces the calculation time. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. /// /// #Params /// command_handle: command handle to map callback to user context /// blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails (returned by `indy_open_blob_storage_reader`) /// rev_state_json: revocation registry state json /// rev_reg_def_json: revocation registry definition json related to `rev_reg_id` in a credential -/// rev_reg_delta_json: revocation registry definition delta json +/// rev_reg_delta_json: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp /// timestamp: time represented as a total number of seconds from Unix Epoch /// cred_rev_id: user credential revocation id in revocation registry (match to `cred_rev_id` in a credential) /// cb: Callback that takes command result as parameter diff --git a/libindy/src/commands/anoncreds/prover.rs b/libindy/src/commands/anoncreds/prover.rs index 8b3ed93fe3..34cb894c75 100644 --- a/libindy/src/commands/anoncreds/prover.rs +++ b/libindy/src/commands/anoncreds/prover.rs @@ -30,7 +30,7 @@ use indy_utils::sequence; use crate::utils::wql::Query; use super::tails::SDKTailsAccessor; -use indy_api_types::WalletHandle; +use indy_api_types::{WalletHandle, SearchHandle}; use crate::commands::BoxedCallbackStringStringSend; pub enum ProverCommand { @@ -152,8 +152,8 @@ pub struct ProverCommandExecutor { wallet_service: Rc, crypto_service: Rc, blob_storage_service: Rc, - searches: RefCell>>, - searches_for_proof_requests: RefCell>>>, + searches: RefCell>>, + searches_for_proof_requests: RefCell>>>, } impl ProverCommandExecutor { @@ -480,7 +480,7 @@ impl ProverCommandExecutor { } fn fetch_credentials(&self, - search_handle: i32, + search_handle: SearchHandle, count: usize, ) -> IndyResult { trace!("fetch_credentials >>> search_handle: {:?}, count: {:?}", search_handle, count); diff --git a/libindy/src/commands/crypto.rs b/libindy/src/commands/crypto.rs index 6ff64b1381..d7ffa08ccf 100644 --- a/libindy/src/commands/crypto.rs +++ b/libindy/src/commands/crypto.rs @@ -8,8 +8,8 @@ use indy_wallet::{RecordOptions, WalletService}; use std::rc::Rc; use std::str; -use crate::utils::crypto::base64; -use crate::utils::crypto::chacha20poly1305_ietf; +use indy_utils::crypto::base64; +use indy_utils::crypto::chacha20poly1305_ietf; use crate::domain::crypto::combo_box::ComboBox; use indy_api_types::WalletHandle; diff --git a/libindy/src/commands/non_secrets.rs b/libindy/src/commands/non_secrets.rs index 7d0b499f6f..dbc360ad78 100644 --- a/libindy/src/commands/non_secrets.rs +++ b/libindy/src/commands/non_secrets.rs @@ -6,7 +6,7 @@ use indy_api_types::domain::wallet::Tags; use indy_api_types::errors::prelude::*; use indy_wallet::{RecordOptions, SearchOptions, WalletRecord, WalletSearch, WalletService}; use indy_utils::sequence; -use indy_api_types::WalletHandle; +use indy_api_types::{WalletHandle, SearchHandle}; pub enum NonSecretsCommand { @@ -49,18 +49,18 @@ pub enum NonSecretsCommand { String, // type String, // query json String, // options json - Box) + Send>), + Box) + Send>), FetchSearchNextRecords(WalletHandle, - i32, // wallet search handle + SearchHandle, // wallet search handle usize, // count Box) + Send>), - CloseSearch(i32, // wallet search handle + CloseSearch(SearchHandle, // wallet search handle Box) + Send>), } pub struct NonSecretsCommandExecutor { wallet_service: Rc, - searches: RefCell>>, + searches: RefCell>>, } impl NonSecretsCommandExecutor { @@ -241,7 +241,7 @@ impl NonSecretsCommandExecutor { wallet_handle: WalletHandle, type_: &str, query_json: &str, - options_json: &str) -> IndyResult { + options_json: &str) -> IndyResult { trace!("open_search >>> wallet_handle: {:?}, type_: {:?}, query_json: {:?}, options_json: {:?}", wallet_handle, type_, query_json, options_json); self._check_type(type_)?; @@ -262,7 +262,7 @@ impl NonSecretsCommandExecutor { fn fetch_search_next_records(&self, wallet_handle: WalletHandle, - wallet_search_handle: i32, + wallet_search_handle: SearchHandle, count: usize) -> IndyResult { trace!("fetch_search_next_records >>> wallet_handle: {:?}, wallet_search_handle: {:?}, count: {:?}", wallet_handle, wallet_search_handle, count); @@ -291,7 +291,7 @@ impl NonSecretsCommandExecutor { } fn close_search(&self, - wallet_search_handle: i32) -> IndyResult<()> { + wallet_search_handle: SearchHandle) -> IndyResult<()> { trace!("close_search >>> wallet_search_handle: {:?}", wallet_search_handle); match self.searches.borrow_mut().remove(&wallet_search_handle) { diff --git a/libindy/src/commands/wallet.rs b/libindy/src/commands/wallet.rs index 73f73a6c56..6521e4b7e1 100644 --- a/libindy/src/commands/wallet.rs +++ b/libindy/src/commands/wallet.rs @@ -8,8 +8,8 @@ use indy_api_types::domain::wallet::{Config, Credentials, ExportConfig, KeyConfi use indy_api_types::errors::prelude::*; use crate::services::crypto::CryptoService; use indy_wallet::{KeyDerivationData, WalletService, Metadata}; -use crate::utils::crypto::{chacha20poly1305_ietf, randombytes}; -use crate::utils::crypto::chacha20poly1305_ietf::Key as MasterKey; +use indy_utils::crypto::{chacha20poly1305_ietf, randombytes}; +use indy_utils::crypto::chacha20poly1305_ietf::Key as MasterKey; use indy_api_types::{WalletHandle, CallbackHandle}; use rust_base58::ToBase58; diff --git a/libindy/src/lib.rs b/libindy/src/lib.rs index 5341e5de4a..c4d6fb1478 100644 --- a/libindy/src/lib.rs +++ b/libindy/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(feature = "fatal_warnings", deny(warnings))] -extern crate base64; extern crate byteorder; extern crate failure; @@ -30,12 +29,10 @@ extern crate rlp; extern crate time; extern crate libc; extern crate rand; -extern crate rusqlite; extern crate uuid; #[macro_use] extern crate derivative; -extern crate sodiumoxide; extern crate core; extern crate hex; @@ -55,6 +52,8 @@ extern crate indy_api_types; #[macro_use] extern crate indy_utils; +extern crate indy_wallet; + // Note that to use macroses from util inside of other modules it must be loaded first! #[macro_use] mod utils; diff --git a/libindy/src/services/crypto/ed25519.rs b/libindy/src/services/crypto/ed25519.rs index 8d44c0063a..b1bbd053a4 100644 --- a/libindy/src/services/crypto/ed25519.rs +++ b/libindy/src/services/crypto/ed25519.rs @@ -1,8 +1,8 @@ use indy_api_types::errors::IndyError; use super::CryptoType; -use crate::utils::crypto::ed25519_box; -use crate::utils::crypto::ed25519_sign; -use crate::utils::crypto::sealedbox; +use indy_utils::crypto::ed25519_box; +use indy_utils::crypto::ed25519_sign; +use indy_utils::crypto::sealedbox; pub struct ED25519CryptoType {} diff --git a/libindy/src/services/crypto/mod.rs b/libindy/src/services/crypto/mod.rs index d82873b164..97ad449ecb 100644 --- a/libindy/src/services/crypto/mod.rs +++ b/libindy/src/services/crypto/mod.rs @@ -7,11 +7,11 @@ use crate::domain::crypto::combo_box::ComboBox; use crate::domain::crypto::did::{Did, DidValue, MyDidInfo, TheirDid, TheirDidInfo}; use crate::domain::crypto::key::{Key, KeyInfo}; use indy_api_types::errors::prelude::*; -use crate::utils::crypto::base64; -use crate::utils::crypto::ed25519_box; -use crate::utils::crypto::chacha20poly1305_ietf; -use crate::utils::crypto::chacha20poly1305_ietf::gen_nonce_and_encrypt_detached; -use crate::utils::crypto::ed25519_sign; +use indy_utils::crypto::base64; +use indy_utils::crypto::ed25519_box; +use indy_utils::crypto::chacha20poly1305_ietf; +use indy_utils::crypto::chacha20poly1305_ietf::gen_nonce_and_encrypt_detached; +use indy_utils::crypto::ed25519_sign; use crate::utils::crypto::verkey_builder::{build_full_verkey, split_verkey, verkey_get_cryptoname}; use self::ed25519::ED25519CryptoType; @@ -446,7 +446,7 @@ impl CryptoService { #[cfg(test)] mod tests { use crate::domain::crypto::did::MyDidInfo; - use crate::utils::crypto::chacha20poly1305_ietf::gen_key; + use indy_utils::crypto::chacha20poly1305_ietf::gen_key; use super::*; diff --git a/libindy/src/services/mod.rs b/libindy/src/services/mod.rs index 3d068ab5ab..ff1648b68c 100644 --- a/libindy/src/services/mod.rs +++ b/libindy/src/services/mod.rs @@ -3,5 +3,4 @@ pub mod blob_storage; pub mod crypto; pub mod ledger; pub mod payments; -pub mod pool; -pub use indy_wallet; \ No newline at end of file +pub mod pool; \ No newline at end of file diff --git a/libindy/src/services/pool/mod.rs b/libindy/src/services/pool/mod.rs index 7e25165b7b..f5540569cf 100644 --- a/libindy/src/services/pool/mod.rs +++ b/libindy/src/services/pool/mod.rs @@ -605,10 +605,8 @@ mod tests { } pub mod nodes_emulator { - extern crate sodiumoxide; - use rust_base58::{ToBase58, FromBase58}; - use crate::utils::crypto::ed25519_sign; + use indy_utils::crypto::ed25519_sign; use super::*; @@ -686,8 +684,7 @@ mod tests { } pub fn start(gt: &mut NodeTransactionV1) -> zmq::Socket { - let (vk, sk) = sodiumoxide::crypto::sign::ed25519::gen_keypair(); - let (vk, sk) = (ed25519_sign::PublicKey::from_slice(&vk[..]).unwrap(), ed25519_sign::SecretKey::from_slice(&sk[..]).unwrap()); + let (vk, sk) = ed25519_sign::create_key_pair_for_signature(None).unwrap(); let pkc = ed25519_sign::vk_to_curve25519(&vk).expect("Invalid pkc"); let skc = ed25519_sign::sk_to_curve25519(&sk).expect("Invalid skc"); let ctx = zmq::Context::new(); diff --git a/libindy/src/services/pool/networker.rs b/libindy/src/services/pool/networker.rs index d9f4b7a7b4..74f6278bf5 100644 --- a/libindy/src/services/pool/networker.rs +++ b/libindy/src/services/pool/networker.rs @@ -9,6 +9,7 @@ use indy_api_types::errors::prelude::*; use crate::services::pool::events::*; use crate::services::pool::types::*; use indy_utils::sequence; +use indy_utils::crypto::base64; use super::time::Duration; @@ -391,7 +392,7 @@ pub mod networker_tests { use crate::domain::pool::{MAX_REQ_PER_POOL_CON, POOL_ACK_TIMEOUT, POOL_CON_ACTIVE_TO, POOL_REPLY_TIMEOUT}; use crate::services::pool::tests::nodes_emulator; - use crate::utils::crypto::ed25519_sign; + use indy_utils::crypto::ed25519_sign; use super::*; use rust_base58::base58::FromBase58; diff --git a/libindy/src/services/pool/pool.rs b/libindy/src/services/pool/pool.rs index 00e7c7b4db..9ebdb857bf 100644 --- a/libindy/src/services/pool/pool.rs +++ b/libindy/src/services/pool/pool.rs @@ -23,7 +23,7 @@ use crate::services::pool::networker::{Networker, ZMQNetworker}; use crate::services::pool::request_handler::{RequestHandler, RequestHandlerImpl}; use rust_base58::{FromBase58, ToBase58}; use crate::services::pool::types::{LedgerStatus, RemoteNode}; -use crate::utils::crypto::ed25519_sign; +use indy_utils::crypto::ed25519_sign; use super::ursa::bls::VerKey; use super::zmq; diff --git a/libindy/src/services/pool/state_proof/mod.rs b/libindy/src/services/pool/state_proof/mod.rs index 292140727b..5861596983 100644 --- a/libindy/src/services/pool/state_proof/mod.rs +++ b/libindy/src/services/pool/state_proof/mod.rs @@ -6,7 +6,7 @@ use std::ffi::{CStr, CString}; use indy_utils::crypto::hash::{Hash}; use rust_base58::ToBase58; -use base64; +use indy_utils::crypto::base64; use rlp::UntrustedRlp; use serde_json; use serde_json::Value as SJsonValue; @@ -406,7 +406,7 @@ fn _parse_reply_for_sp(json_msg: &SJsonValue, data: Option<&str>, parsed_data: & let proof = if let Some(path) = parsed_data["auditPath"].as_array() { let path_str = json!(path).to_string(); trace!("TransactionHandler::parse_reply_for_builtin_sp: proof: {:?}", path); - base64::encode(&path_str) + base64::encode(path_str.as_bytes()) } else { return Err("No proof".to_string()); }; @@ -894,7 +894,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -909,7 +909,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -924,7 +924,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "G9QooEDKSmEtLGNyTwafQiPfGHMqw3A3Fjcj2eLRG4G1".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -939,7 +939,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 9)); @@ -954,7 +954,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("3"), Some(r#"{"4":"4"}"#.to_string()))]; + let kvs = vec![(base64::encode("3".as_bytes()), Some(r#"{"4":"4"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -969,7 +969,7 @@ mod tests { "25KLEkkyCEPSBj4qMFE3AcH87mFocyJEuPJ5xzPGwDgz" ] ).to_string(); - let kvs = vec![(base64::encode("4"), Some(r#"{"3":"3"}"#.to_string()))]; + let kvs = vec![(base64::encode("4".as_bytes()), Some(r#"{"3":"3"}"#.to_string()))]; let node_bytes = &nodes; let root_hash = "CrA5sqYe3ruf2uY7d8re7ePmyHqptHqANtMZcfZd4BvK".from_base58().unwrap(); assert!(!_verify_merkle_tree(node_bytes.as_bytes(), root_hash.as_slice(), kvs.as_slice(), 5)); @@ -1479,7 +1479,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1493,7 +1493,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], + kvs: vec![(base64::encode("2".as_bytes()), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } @@ -1512,7 +1512,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1526,7 +1526,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], + kvs: vec![(base64::encode("2".as_bytes()), Some(json!({"txn":{"test1": "test2", "seqNo": 2}}).to_string()))], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } @@ -1566,7 +1566,7 @@ mod tests { } }); - let nodes_str = base64::encode(&json!(["1", "2"]).to_string()); + let nodes_str = base64::encode(json!(["1", "2"]).to_string().as_bytes()); let mut parsed_sps = super::parse_generic_reply_for_proof_checking(json_msg, "", @@ -1580,7 +1580,7 @@ mod tests { assert_eq!(parsed_sp.proof_nodes, nodes_str); assert_eq!(parsed_sp.kvs_to_verify, KeyValuesInSP::Simple(KeyValueSimpleData { - kvs: vec![(base64::encode("2"), None)], + kvs: vec![(base64::encode("2".as_bytes()), None)], verification_type: KeyValueSimpleDataVerificationType::MerkleTree(2), })); } diff --git a/libindy/src/services/pool/state_proof/node.rs b/libindy/src/services/pool/state_proof/node.rs index f8129e7508..a29a44ef81 100644 --- a/libindy/src/services/pool/state_proof/node.rs +++ b/libindy/src/services/pool/state_proof/node.rs @@ -407,6 +407,7 @@ impl Node { #[cfg(test)] mod tests { use super::*; + use indy_utils::crypto::base64; #[test] fn node_deserialize_works_for_emtpy() { @@ -419,4 +420,4 @@ mod tests { assert_eq!(base64::encode(&rlp::encode_list(&vec![Node::Blank])), "wYA="); } -} \ No newline at end of file +} diff --git a/libindy/src/utils/crypto/mod.rs b/libindy/src/utils/crypto/mod.rs index aab98ddf21..ba0a6b8dfa 100644 --- a/libindy/src/utils/crypto/mod.rs +++ b/libindy/src/utils/crypto/mod.rs @@ -1,29 +1,2 @@ -#[cfg(feature = "ed25519_sign_sodium")] -#[path = "ed25519_sign/sodium.rs"] -pub mod ed25519_sign; - -#[cfg(feature = "ed25519_box_sodium")] -#[path = "ed25519_box/sodium.rs"] -// TODO: The name is misleading as the operations do not happen over ed25519 curve -pub mod ed25519_box; - -pub use indy_utils::crypto::base64; - -#[allow(dead_code)] /* FIXME Do we really need this module? */ -#[cfg(feature = "xsalsa20_sodium")] -#[path = "xsalsa20/sodium.rs"] -pub mod xsalsa20; - -pub use indy_utils::crypto::chacha20poly1305_ietf; - -pub mod signature_serializer; - pub mod verkey_builder; - -#[cfg(feature = "sealedbox_sodium")] -#[path = "sealedbox/sodium.rs"] -pub mod sealedbox; - -#[cfg(feature = "randombytes_sodium")] -#[path = "randombytes/sodium.rs"] -pub mod randombytes; +pub mod signature_serializer; diff --git a/libindy/tests/crypto.rs b/libindy/tests/crypto.rs index ae541da73f..5e196dfaa7 100644 --- a/libindy/tests/crypto.rs +++ b/libindy/tests/crypto.rs @@ -246,7 +246,7 @@ mod high_cases { pub struct UnpackMessage { pub message: String, pub sender_verkey: String, - pub recipient_verkey: String + pub recipient_verkey: String, } #[test] @@ -292,7 +292,7 @@ mod high_cases { #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub struct UnpackMessage { pub message: String, - pub recipient_verkey: String + pub recipient_verkey: String, } #[test] @@ -682,3 +682,30 @@ mod load { time_diff_max, agent_cnt * operations_cnt, time_sum_diff, total_duration); } } + +#[test] // aries-396 +fn crypto_unpack_data_with_and_without_padding_works() { + let setup_trustee = Setup::trustee(); + + let actual_message = "Hello World"; + + // With padding + { + let jwe = json!({ "protected": "eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiIxamlhNk4zOUhYQVZvQzUzT2xpVE14T0ZobjVKVE1jLXlwOGVXcjVERndJM1psN01HNW5IcFF2ejNMUVJjMUpvIiwiaGVhZGVyIjp7ImtpZCI6IkdKMVN6b1d6YXZRWWZOTDlYa2FKZHJRZWpmenRONFhxZHNpVjRjdDNMWEtMIiwiaXYiOiJGTS1MUktQV1hEQjRGdVVvc1RDQWxYcHR5M2ZCWVZpTCIsInNlbmRlciI6IjQ4Q2l5UXZTWWNmcEdCbzQtSTlkeGpmOW8yamZsQ1ZYVzY0TnFETEVDSFVPVXNnY2ZDLTFWaHQyMzNHZmNqTWYyVWxiNDZzd2pDVjJoUGFCUlNOMDB5YTNCVzBETC11V3FQMXd3NEVET0dBdk1HQUNzeThHY0w5NEhRcz0ifX1dfQ==", "iv": "Q6Nv06ZdUXQ53woe", "ciphertext": "rFsCeJO8mHLwVU4=", "tag": "wt4oAZ74LCW40xRqfdc6Bg==" }); + let jwe = serde_json::to_vec(&jwe).unwrap(); + + let res = crypto::unpack_message(setup_trustee.wallet_handle, &jwe).unwrap(); + let res = serde_json::from_slice::<::serde_json::Value>(res.as_slice()).unwrap(); + assert_eq!(actual_message, res["message"].as_str().unwrap()); + } + + // Without padding + { + let jwe = json!({ "protected": "eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiJMZENfMzZzRHBFeXI5dGlKOHZLVENhMUFkcExXYWtoUzMxbWtsdk9oQlF3QnFKSVpvV0FrWlZzazRVYUg2VDJXIiwiaGVhZGVyIjp7ImtpZCI6IkdKMVN6b1d6YXZRWWZOTDlYa2FKZHJRZWpmenRONFhxZHNpVjRjdDNMWEtMIiwiaXYiOiJjZjY0LUlHRUh4R09MWXRtRlVSU3F3NWQ2U05fN0xxTCIsInNlbmRlciI6Il9ITDlWUDIxZmtiX2R3QmdTLS1OaVRJY2FjZVVTTGR3UDFtSFRURmJEWEk0MkFLblZDd0tHcXY0bmxHTk5qSHVVampPRUV1cGZYR3drWjZBTGJiNGFtTzJsbHpNQzZLYm9BTVNob19UckpaTVdXbGN2dnljc3VrMlRxYyJ9fV19", "iv": "fzGusjZNVbCo17dT", "ciphertext": "4xrn1rPkpDx4eEg", "tag": "ff3cppEUYi-6yC_ZvWhjoQ" }); + let jwe = serde_json::to_vec(&jwe).unwrap(); + + let res = crypto::unpack_message(setup_trustee.wallet_handle, &jwe).unwrap(); + let res = serde_json::from_slice::<::serde_json::Value>(res.as_slice()).unwrap(); + assert_eq!(actual_message, res["message"].as_str().unwrap()); + } +} \ No newline at end of file diff --git a/libindy/tests/demo.rs b/libindy/tests/demo.rs index 6dc491c24a..0baacc7654 100644 --- a/libindy/tests/demo.rs +++ b/libindy/tests/demo.rs @@ -751,7 +751,8 @@ fn crypto_demo_works() { let (verify_receiver, verify_command_handle, verify_callback) = callback::_closure_to_cb_ec_bool(); let (close_wallet_receiver, close_wallet_command_handle, close_wallet_callback) = callback::_closure_to_cb_ec(); - let wallet_config = json!({"id": "wallet_1"}).to_string(); + let wallet_name = "wallet_crypto_demo_works"; + let wallet_config = json!({"id": wallet_name}).to_string(); // 1. Create Wallet let err = @@ -843,5 +844,5 @@ fn crypto_demo_works() { let res = close_wallet_receiver.recv_timeout(timeout::medium_timeout()).unwrap(); assert_eq!(ErrorCode::from(res), ErrorCode::Success); - utils::test::cleanup_storage("wallet_1"); + utils::test::cleanup_storage(wallet_name); } diff --git a/libindy/tests/utils/mod.rs b/libindy/tests/utils/mod.rs index 08a49fc086..aa0e3bdc14 100644 --- a/libindy/tests/utils/mod.rs +++ b/libindy/tests/utils/mod.rs @@ -93,6 +93,7 @@ macro_rules! inject_indy_dependencies { extern crate regex; extern crate time; extern crate libc; + extern crate dirs; } } diff --git a/vcx/libvcx/Cargo.lock b/vcx/libvcx/Cargo.lock index 11d6ead67a..aadb41a9f5 100644 --- a/vcx/libvcx/Cargo.lock +++ b/vcx/libvcx/Cargo.lock @@ -36,25 +36,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "antidote" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "arc-swap" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "argon2rs" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "arrayvec" version = "0.4.10" @@ -121,15 +102,6 @@ name = "bitflags" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "build_const" version = "0.2.1" @@ -177,11 +149,6 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "constant_time_eq" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cookie" version = "0.11.1" @@ -282,16 +249,6 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "dtoa" version = "0.4.4" @@ -353,7 +310,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -593,7 +549,6 @@ dependencies = [ "android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -604,23 +559,18 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -628,11 +578,6 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "lock_api" version = "0.1.5" @@ -648,44 +593,6 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log-panics" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log4rs" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -722,15 +629,6 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "miniz-sys" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "miniz_oxide" version = "0.2.1" @@ -933,14 +831,6 @@ dependencies = [ "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "owning_ref" version = "0.4.0" @@ -1202,17 +1092,6 @@ dependencies = [ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_users" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" version = "1.1.6" @@ -1292,15 +1171,6 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rmpv" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rust-base58" version = "0.0.4" @@ -1341,11 +1211,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scopeguard" version = "0.3.3" @@ -1390,15 +1255,6 @@ name = "serde" version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde-value" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_derive" version = "1.0.104" @@ -1430,17 +1286,6 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_yaml" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "siphasher" version = "0.2.3" @@ -1513,18 +1358,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tempfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tempfile" version = "3.0.7" @@ -1557,16 +1390,6 @@ dependencies = [ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "thread-id" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.6" @@ -1715,11 +1538,6 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "try-lock" version = "0.2.2" @@ -1733,14 +1551,6 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "typemap" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ucd-util" version = "0.1.3" @@ -1793,14 +1603,6 @@ name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unsafe-any" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "url" version = "1.7.2" @@ -1899,23 +1701,12 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "yaml-rust" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] "checksum MacTypes-sys 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7dbbe033994ae2198a18517c7132d952a29fb1db44249a1234779da7c50f4698" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" "checksum android_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86983875e7c3a202e31471cc6d60fcc18f30e194f1729cfff3bfb43d646ffced" -"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" -"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" -"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" @@ -1924,7 +1715,6 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c4a342b450b268e1be8036311e2c613d7f8a7ed31214dff1cc3b60852a3168d" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" @@ -1932,7 +1722,6 @@ dependencies = [ "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0" "checksum cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0d2f2ecb21dce00e2453268370312978af9b8024020c7a37ae2cc6dbbe64685" "checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" @@ -1943,7 +1732,6 @@ dependencies = [ "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" -"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" @@ -1975,18 +1763,13 @@ dependencies = [ "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" -"checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" -"checksum log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "100052474df98158c0738a7d3f4249c99978490178b5f9f68cd835ac57adbd1b" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" -"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649" "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" @@ -2008,7 +1791,6 @@ dependencies = [ "checksum openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)" = "a51f452b82d622fc8dd973d7266e9055ac64af25b957d9ced3989142dc61cb6b" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f" -"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" @@ -2039,32 +1821,27 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddcfd2c13c6af0f9c45a1086be3b9c68af79e4430b42790759e2d34cce2a6c60" "checksum rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a3d45d7afc9b132b34a2479648863aa95c5c88e98b32285326a6ebadc80ec5c9" "checksum rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" -"checksum rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29af0205707de955a396a1d3c657677c65f791ebabb63c0596c0b2fec0bf6325" "checksum rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b313b91fcdc6719ad41fa2dad2b7e810b03833fae4bf911950e15529a5f04439" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" -"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum security-framework 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "697d3f3c23a618272ead9e1fb259c1411102b31c6af8b93f1d64cca9c3b0e8e0" "checksum security-framework-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "40d95f3d7da09612affe897f320d78264f0d2320f3e8eea27d12bd1bd94445e2" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" @@ -2075,11 +1852,9 @@ dependencies = [ "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" -"checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cec6c34409089be085de9403ba2010b80e36938c9ca992c4f67f407bb13db0b1" @@ -2093,10 +1868,8 @@ dependencies = [ "checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" @@ -2105,7 +1878,6 @@ dependencies = [ "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" @@ -2120,4 +1892,3 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" diff --git a/vcx/libvcx/Cargo.toml b/vcx/libvcx/Cargo.toml index a263c62532..859d327f69 100644 --- a/vcx/libvcx/Cargo.toml +++ b/vcx/libvcx/Cargo.toml @@ -27,7 +27,6 @@ ci = [] [dependencies] env_logger = "0.5.10" log = "0.4" -log4rs = "0.8.0" chrono = "0.4" time = "0.1.36" lazy_static = "1.3" @@ -35,21 +34,17 @@ libc = "=0.2.66" rand = "0.3" serde = "1.0.97" serde_json = "1.0.40" -json = "*" serde_derive = "1.0.97" url = "1.5.1" reqwest = "0.9.5" regex = "1.1.0" rust-base58 = "0.0.4" -rmpv = "0.4.0" -rmp = "0.8" rmp-serde = "0.13.7" base64 = "0.8.0" openssl = "0.10" num-traits = "0.2.0" indy = { version = "1.14.2", path = "../../wrappers/rust/" } indy-sys = { version = "1.14.2", path = "../../wrappers/rust/indy-sys/" } -log-panics = "2.0.0" tokio-threadpool = "0.1.6" futures = "0.1.23" libloading = "0.5.0" @@ -68,10 +63,6 @@ toml = "0.4" serde_json = "1.0" serde_derive = "1.0" -[dev-dependencies] -tempfile = "2.2" -dirs = "1.0.4" - [package.metadata.deb] maintainer = "Evernym, Inc." copyright = "2018, Evernym Inc." diff --git a/vcx/libvcx/src/api/connection.rs b/vcx/libvcx/src/api/connection.rs index 3282c64883..b75e42e5af 100644 --- a/vcx/libvcx/src/api/connection.rs +++ b/vcx/libvcx/src/api/connection.rs @@ -328,7 +328,7 @@ pub extern fn vcx_connection_connect(command_handle: CommandHandle, let msg = CStringUtils::string_to_cstring(x); cb(command_handle, error::SUCCESS.code_num, msg.as_ptr()); } - Err(e) => { + Err(_) => { warn!("vcx_connection_connect_cb(command_handle: {}, connection_handle: {}, rc: {}, details: {}), source_id: {:?}", command_handle, connection_handle, error::SUCCESS.message, "null", source_id); // TODO: why Success????? cb(command_handle, error::SUCCESS.code_num, ptr::null_mut()); @@ -971,7 +971,7 @@ pub extern fn vcx_connection_release(connection_handle: u32) -> u32 { let source_id = get_source_id(connection_handle).unwrap_or_default(); match release(connection_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_connection_release(connection_handle: {}, rc: {}), source_id: {:?}", connection_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -1181,7 +1181,7 @@ mod tests { let cb = return_types_u32::Return_U32_U32::new().unwrap(); connect(handle, None).unwrap(); httpclient::set_next_u8_response(GET_MESSAGES_RESPONSE.to_vec()); - let rc = vcx_connection_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_connection_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), VcxStateType::VcxStateAccepted as u32); let cb = return_types_u32::Return_U32_U32::new().unwrap(); let rc = vcx_connection_get_state(cb.command_handle, handle, Some(cb.get_callback())); @@ -1212,7 +1212,7 @@ mod tests { cb.receive(Some(Duration::from_secs(10))).unwrap(); } - extern "C" fn test_sign_cb(command_handle: CommandHandle, error: u32, signature: *const u8, signature_length: u32) { + extern "C" fn test_sign_cb(_command_handle: CommandHandle, error: u32, _signature: *const u8, _signature_length: u32) { assert_eq!(error, error::SUCCESS.code_num); } @@ -1230,7 +1230,7 @@ mod tests { thread::sleep(Duration::from_secs(2)); } - extern "C" fn test_verify_cb(command_handle: CommandHandle, error: u32, valid: bool) { + extern "C" fn test_verify_cb(_command_handle: CommandHandle, _error: u32, valid: bool) { assert_eq!(valid, true); } diff --git a/vcx/libvcx/src/api/credential.rs b/vcx/libvcx/src/api/credential.rs index f5b87fae27..06ddc38766 100644 --- a/vcx/libvcx/src/api/credential.rs +++ b/vcx/libvcx/src/api/credential.rs @@ -318,7 +318,7 @@ pub extern fn vcx_credential_create_with_msgid(command_handle: CommandHandle, pub extern fn vcx_credential_send_request(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - payment_handle: u32, + _payment_handle: u32, cb: Option) -> u32 { info!("vcx_credential_send_request >>>"); @@ -373,7 +373,7 @@ pub extern fn vcx_credential_send_request(command_handle: CommandHandle, pub extern fn vcx_credential_get_request_msg(command_handle: CommandHandle, credential_handle: u32, connection_handle: u32, - payment_handle: u32, + _payment_handle: u32, cb: Option) -> u32 { info!("vcx_credential_get_request_msg >>>"); @@ -500,7 +500,7 @@ pub extern fn vcx_credential_update_state(command_handle: CommandHandle, } } - let state = match credential::get_state(credential_handle) { + match credential::get_state(credential_handle) { Ok(s) => { trace!("vcx_credential_update_state_cb(command_handle: {}, rc: {}, state: {}), source_id: {:?}", command_handle, error::SUCCESS.message, s, source_id); @@ -560,7 +560,7 @@ pub extern fn vcx_credential_update_state_with_message(command_handle: CommandHa } } - let state = match credential::get_state(credential_handle) { + match credential::get_state(credential_handle) { Ok(s) => { trace!("vcx_credential_update_state_with_message_cb(command_handle: {}, rc: {}, state: {}), source_id: {:?}", command_handle, error::SUCCESS.message, s, source_id); @@ -736,7 +736,7 @@ pub extern fn vcx_credential_release(handle: u32) -> u32 { let source_id = credential::get_source_id(handle).unwrap_or_default(); match credential::release(handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_credential_release(handle: {}, rc: {}), source_id: {:?}", handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -952,7 +952,6 @@ mod tests { init!("true"); let handle = credential::from_string(FULL_CREDENTIAL_SERIALIZED).unwrap(); let bad_handle = 1123; - let command_handle = 1111; let cb = return_types_u32::Return_U32_STR::new().unwrap(); assert_eq!(vcx_get_credential(cb.command_handle, handle, Some(cb.get_callback())), error::SUCCESS.code_num); cb.receive(Some(Duration::from_secs(10))).unwrap().unwrap(); diff --git a/vcx/libvcx/src/api/credential_def.rs b/vcx/libvcx/src/api/credential_def.rs index 27a9db087f..4996b0785f 100644 --- a/vcx/libvcx/src/api/credential_def.rs +++ b/vcx/libvcx/src/api/credential_def.rs @@ -44,7 +44,7 @@ pub extern fn vcx_credentialdef_create(command_handle: CommandHandle, issuer_did: *const c_char, tag: *const c_char, revocation_details: *const c_char, - payment_handle: u32, + _payment_handle: u32, cb: Option) -> u32 { info!("vcx_credentialdef_create >>>"); @@ -415,7 +415,7 @@ pub extern fn vcx_credentialdef_release(credentialdef_handle: u32) -> u32 { let source_id = credential_def::get_source_id(credentialdef_handle).unwrap_or_default(); match credential_def::release(credentialdef_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_credentialdef_release(credentialdef_handle: {}, rc: {}), source_id: {}", credentialdef_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -675,7 +675,7 @@ mod tests { "tag".to_string(), "{}".to_string()).unwrap(); let cb = return_types_u32::Return_U32_STR::new().unwrap(); - let rc = vcx_credentialdef_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); cb.receive(Some(Duration::from_secs(10))).unwrap(); } @@ -693,7 +693,7 @@ mod tests { CString::new("{}").unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let cred_def_transaction = cred_def_transaction.unwrap(); let cred_def_transaction: serde_json::Value = serde_json::from_str(&cred_def_transaction).unwrap(); let expected_cred_def_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -716,7 +716,7 @@ mod tests { CString::new(credential_def::tests::revocation_details(true).to_string()).unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, cred_def_transaction, rev_reg_def_transaction, rev_reg_delta_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let cred_def_transaction = cred_def_transaction.unwrap(); let cred_def_transaction: serde_json::Value = serde_json::from_str(&cred_def_transaction).unwrap(); let expected_cred_def_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -728,7 +728,6 @@ mod tests { #[test] fn test_vcx_cred_def_get_state() { init!("true"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (handle, _, _, _) = credential_def::prepare_credentialdef_for_endorser("testid".to_string(), "Test Credential Def".to_string(), "6vkhW3L28AophhA68SSzRS".to_string(), @@ -738,17 +737,17 @@ mod tests { "V4SGRU86Z58d6TV7PBUe6f".to_string()).unwrap(); { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Built as u32) } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32); } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_credentialdef_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32) } } diff --git a/vcx/libvcx/src/api/disclosed_proof.rs b/vcx/libvcx/src/api/disclosed_proof.rs index e9d8c29e6f..a8b3f6ee17 100644 --- a/vcx/libvcx/src/api/disclosed_proof.rs +++ b/vcx/libvcx/src/api/disclosed_proof.rs @@ -209,8 +209,8 @@ pub extern fn vcx_disclosed_proof_send_proof(command_handle: CommandHandle, command_handle, proof_handle, connection_handle, source_id); spawn(move || { - let err = match disclosed_proof::send_proof(proof_handle, connection_handle) { - Ok(x) => { + match disclosed_proof::send_proof(proof_handle, connection_handle) { + Ok(_) => { trace!("vcx_disclosed_proof_send_proof_cb(command_handle: {}, rc: {}) source_id: {}", command_handle, error::SUCCESS.message, source_id); cb(command_handle, error::SUCCESS.code_num); @@ -819,7 +819,7 @@ pub extern fn vcx_disclosed_proof_release(handle: u32) -> u32 { let source_id = disclosed_proof::get_source_id(handle).unwrap_or_default(); match disclosed_proof::release(handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_disclosed_proof_release(handle: {}, rc: {}), source_id: {:?}", handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -888,7 +888,6 @@ mod tests { #[test] fn test_vcx_disclosed_proof_release() { init!("true"); - let cb = return_types_u32::Return_U32_STR::new().unwrap(); let handle = disclosed_proof::create_proof("1", ::utils::constants::PROOF_REQUEST_JSON).unwrap(); let unknown_handle = handle + 1; let err = vcx_disclosed_proof_release(unknown_handle); @@ -980,7 +979,7 @@ mod tests { handle, Some(cb.get_callback())), error::SUCCESS.code_num); - let credentials = cb.receive(None).unwrap().unwrap(); + let _credentials = cb.receive(None).unwrap().unwrap(); } #[test] diff --git a/vcx/libvcx/src/api/issuer_credential.rs b/vcx/libvcx/src/api/issuer_credential.rs index ee27a7631b..30d3d4c096 100644 --- a/vcx/libvcx/src/api/issuer_credential.rs +++ b/vcx/libvcx/src/api/issuer_credential.rs @@ -678,7 +678,7 @@ pub extern fn vcx_issuer_credential_release(credential_handle: u32) -> u32 { info!("vcx_issuer_credential_release >>>"); let source_id = issuer_credential::get_source_id(credential_handle).unwrap_or_default(); match issuer_credential::release(credential_handle) { - Ok(_) => { + Ok(()) => { trace!("(vcx_issuer_credential_release credential_handle: {}, rc: {}), source_id: {}", credential_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -781,7 +781,7 @@ pub extern fn vcx_issuer_revoke_credential(command_handle: CommandHandle, spawn(move || { let err = match issuer_credential::revoke_credential(credential_handle) { - Ok(_) => { + Ok(()) => { info!("vcx_issuer_revoke_credential_cb(command_handle: {}, credential_handle: {}, rc: {}) source_id: {}", command_handle, credential_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -820,7 +820,6 @@ mod tests { static DEFAULT_CREDENTIAL_NAME: &str = "Credential Name Default"; static DEFAULT_DID: &str = "8XFh8yBzrpJQmNyZzgoTqB"; static DEFAULT_ATTR: &str = "{\"attr\":\"value\"}"; - static DEFAULT_SCHEMA_SEQ_NO: u32 = 32; fn issuer_credential_state_accepted() -> String { json!({ @@ -1000,7 +999,6 @@ mod tests { fn test_vcx_issuer_send_a_credential() { init!("true"); settings::set_config_value(settings::CONFIG_INSTITUTION_DID, DEFAULT_DID); - let test_name = "test_vcx_issuer_send_a_credential"; let handle = issuer_credential::from_string(&issuer_credential_state_accepted()).unwrap(); // create connection @@ -1021,7 +1019,6 @@ mod tests { fn test_vcx_issuer_get_credential_msg() { init!("true"); settings::set_config_value(settings::CONFIG_INSTITUTION_DID, DEFAULT_DID); - let test_name = "test_vcx_issuer_get_credential_msg"; let handle = issuer_credential::from_string(&issuer_credential_state_accepted()).unwrap(); // create connection diff --git a/vcx/libvcx/src/api/logger.rs b/vcx/libvcx/src/api/logger.rs index 8b1e659b06..725f263b2c 100644 --- a/vcx/libvcx/src/api/logger.rs +++ b/vcx/libvcx/src/api/logger.rs @@ -25,7 +25,7 @@ pub extern fn vcx_set_default_logger(pattern: *const c_char) -> u32 { trace!("vcx_set_default_logger(pattern: {:?})", pattern); match LibvcxDefaultLogger::init(pattern) { - Ok(_) => { + Ok(()) => { debug!("Logger Successfully Initialized"); SUCCESS.code_num } @@ -61,7 +61,7 @@ pub extern fn vcx_set_logger(context: *const CVoid, let res = LibvcxLogger::init(context, enabled, log, flush); match res { - Ok(_) => { + Ok(()) => { debug!("Logger Successfully Initialized"); SUCCESS.code_num } diff --git a/vcx/libvcx/src/api/proof.rs b/vcx/libvcx/src/api/proof.rs index 1ba9e1a2b7..6e1d138e28 100644 --- a/vcx/libvcx/src/api/proof.rs +++ b/vcx/libvcx/src/api/proof.rs @@ -434,7 +434,7 @@ pub extern fn vcx_proof_release(proof_handle: u32) -> u32 { let source_id = proof::get_source_id(proof_handle).unwrap_or_default(); match proof::release(proof_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_proof_release(proof_handle: {}, rc: {}), source_id: {}", proof_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -717,7 +717,6 @@ mod tests { fn test_vcx_proof_deserialize_succeeds() { init!("true"); let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let original = r#"{"nonce":"123456","version":"1.0","handle":1,"msg_uid":"","ref_msg_id":"","name":"Name Data","prover_vk":"","agent_did":"","agent_vk":"","remote_did":"","remote_vk":"","prover_did":"8XFh8yBzrpJQmNyZzgoTqB","requested_attrs":"{\"attrs\":[{\"name\":\"person name\"},{\"schema_seq_no\":1,\"name\":\"address_1\"},{\"schema_seq_no\":2,\"issuer_did\":\"ISSUER_DID2\",\"name\":\"address_2\"},{\"schema_seq_no\":1,\"name\":\"city\"},{\"schema_seq_no\":1,\"name\":\"state\"},{\"schema_seq_no\":1,\"name\":\"zip\"}]}","requested_predicates":"{\"attr_name\":\"age\",\"p_type\":\"GE\",\"value\":18,\"schema_seq_no\":1,\"issuer_did\":\"DID1\"}","source_id":"source id","state":2,"proof_state":0,"proof":null,"proof_request":null,"revocation_interval":{}}"#; assert_eq!(vcx_proof_deserialize(cb.command_handle, CString::new(PROOF_OFFER_SENT).unwrap().into_raw(), Some(cb.get_callback())), @@ -769,7 +768,7 @@ mod tests { CString::new(PROOF_RESPONSE_STR).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let state = cb.receive(Some(Duration::from_secs(10))).unwrap(); + let _state = cb.receive(Some(Duration::from_secs(10))).unwrap(); assert_eq!(proof::get_state(proof_handle).unwrap(),VcxStateType::VcxStateAccepted as u32); } diff --git a/vcx/libvcx/src/api/schema.rs b/vcx/libvcx/src/api/schema.rs index 71aa283098..12dfc04f88 100644 --- a/vcx/libvcx/src/api/schema.rs +++ b/vcx/libvcx/src/api/schema.rs @@ -36,7 +36,7 @@ pub extern fn vcx_schema_create(command_handle: CommandHandle, schema_name: *const c_char, version: *const c_char, schema_data: *const c_char, - payment_handle: u32, + _payment_handle: u32, cb: Option) -> u32 { info!("vcx_schema_create >>>"); @@ -254,7 +254,7 @@ pub extern fn vcx_schema_release(schema_handle: u32) -> u32 { let source_id = schema::get_source_id(schema_handle).unwrap_or_default(); match schema::release(schema_handle) { - Ok(_) => { + Ok(()) => { trace!("vcx_schema_release(schema_handle: {}, rc: {}), source_id: {}", schema_handle, error::SUCCESS.message, source_id); error::SUCCESS.code_num @@ -572,7 +572,7 @@ mod tests { 0, Some(cb.get_callback())), error::SUCCESS.code_num); - let handle = cb.receive(Some(Duration::from_secs(5))).unwrap(); + let _handle = cb.receive(Some(Duration::from_secs(5))).unwrap(); } #[cfg(feature = "pool_tests")] @@ -587,7 +587,7 @@ mod tests { CString::new(schema_id).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (err, attrs) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_err, attrs) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let mut result_vec = vec!(attrs.clone().unwrap()); let mut expected_vec = vec!(DEFAULT_SCHEMA_ATTRS); assert_eq!(result_vec.sort(), expected_vec.sort()); @@ -648,7 +648,7 @@ mod tests { CString::new("Test Source ID").unwrap().into_raw(), CString::new(SCHEMA_ID).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, schema_data_as_string) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, schema_data_as_string) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let schema_data_as_string = schema_data_as_string.unwrap(); let schema_as_json: serde_json::Value = serde_json::from_str(&schema_data_as_string).unwrap(); assert_eq!(schema_as_json["data"].to_string(), data); @@ -660,7 +660,7 @@ mod tests { let cb = return_types_u32::Return_U32_STR::new().unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let handle = schema::create_and_publish_schema("testid", did, "name".to_string(), "1.0".to_string(), "[\"name\":\"male\"]".to_string()).unwrap(); - let rc = vcx_schema_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_payment_txn(cb.command_handle, handle, Some(cb.get_callback())); let txn = cb.receive(Some(Duration::from_secs(2))).unwrap(); assert!(txn.is_some()); } @@ -715,7 +715,7 @@ mod tests { CString::new("[att1, att2]").unwrap().into_raw(), CString::new("V4SGRU86Z58d6TV7PBUe6f").unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let (handle, schema_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); + let (_handle, schema_transaction) = cb.receive(Some(Duration::from_secs(2))).unwrap(); let schema_transaction = schema_transaction.unwrap(); let schema_transaction: serde_json::Value = serde_json::from_str(&schema_transaction).unwrap(); let expected_schema_transaction: serde_json::Value = serde_json::from_str(::utils::constants::REQUEST_WITH_ENDORSER).unwrap(); @@ -729,17 +729,17 @@ mod tests { let (handle, _) = schema::prepare_schema_for_endorser("testid", did, "name".to_string(), "1.0".to_string(), "[\"name\":\"male\"]".to_string(), "V4SGRU86Z58d6TV7PBUe6f".to_string()).unwrap(); { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Built as u32) } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_update_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_update_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32); } { let cb = return_types_u32::Return_U32_U32::new().unwrap(); - let rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); + let _rc = vcx_schema_get_state(cb.command_handle, handle, Some(cb.get_callback())); assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), ::api::PublicEntityStateType::Published as u32) } } diff --git a/vcx/libvcx/src/api/utils.rs b/vcx/libvcx/src/api/utils.rs index 29fde9b0b5..d897aec826 100644 --- a/vcx/libvcx/src/api/utils.rs +++ b/vcx/libvcx/src/api/utils.rs @@ -131,7 +131,7 @@ pub extern fn vcx_agent_update_info(command_handle: CommandHandle, spawn(move || { match messages::agent_utils::update_agent_info(&agent_info.id, &agent_info.value) { - Ok(x) => { + Ok(()) => { trace!("vcx_agent_update_info_cb(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); cb(command_handle, error::SUCCESS.code_num); @@ -354,7 +354,7 @@ pub extern fn vcx_messages_update_status(command_handle: CommandHandle, spawn(move || { match ::messages::update_message::update_agency_messages(&message_status, &msg_json) { - Ok(_) => { + Ok(()) => { trace!("vcx_messages_set_status_cb(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -465,7 +465,7 @@ pub extern fn vcx_endorse_transaction(command_handle: CommandHandle, spawn(move || { match ::utils::libindy::ledger::endorse_transaction(&transaction) { - Ok(x) => { + Ok(()) => { trace!("vcx_endorse_transaction(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -563,7 +563,7 @@ mod tests { let c_json = CString::new(json_string).unwrap().into_raw(); let cb = return_types_u32::Return_U32::new().unwrap(); - let result = vcx_agent_update_info(cb.command_handle, c_json, Some(cb.get_callback())); + let _result = vcx_agent_update_info(cb.command_handle, c_json, Some(cb.get_callback())); cb.receive(Some(Duration::from_secs(10))).unwrap(); } diff --git a/vcx/libvcx/src/api/vcx.rs b/vcx/libvcx/src/api/vcx.rs index 343233bb58..b7a03cc6f4 100644 --- a/vcx/libvcx/src/api/vcx.rs +++ b/vcx/libvcx/src/api/vcx.rs @@ -85,7 +85,7 @@ pub extern fn vcx_init(command_handle: CommandHandle, settings::set_defaults(); } else { match settings::process_config_file(&config_path) { - Err(e) => { + Err(_) => { return VcxError::from_msg(VcxErrorKind::InvalidConfiguration, "Cannot initialize with given config path.").into(); } Ok(_) => { @@ -132,7 +132,7 @@ fn _finish_init(command_handle: CommandHandle, cb: extern fn(xcommand_handle: Co spawn(move || { if settings::get_config_value(settings::CONFIG_GENESIS_PATH).is_ok() { match ::utils::libindy::init_pool() { - Ok(_) => (), + Ok(()) => (), Err(e) => { error!("Init Pool Error {}.", e); cb(command_handle, e.into()); @@ -229,12 +229,12 @@ pub extern fn vcx_shutdown(delete: bool) -> u32 { trace!("vcx_shutdown(delete: {})", delete); match wallet::close_wallet() { - Ok(_) => {} + Ok(()) => {} Err(_) => {} }; match pool::close() { - Ok(_) => {} + Ok(()) => {} Err(_) => {} }; @@ -256,12 +256,12 @@ pub extern fn vcx_shutdown(delete: bool) -> u32 { let wallet_type = settings::get_config_value(settings::CONFIG_WALLET_TYPE).ok(); match wallet::delete_wallet(&wallet_name, wallet_type.as_ref().map(String::as_str), None, None) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; match pool::delete(&pool_name) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } @@ -394,7 +394,7 @@ pub extern fn vcx_set_active_txn_author_agreement_meta(text: *const c_char, text, version, hash, acc_mech_type, time_of_acceptance); match ::utils::author_agreement::set_txn_author_agreement(text, version, hash, acc_mech_type, time_of_acceptance) { - Ok(x) => error::SUCCESS.code_num, + Ok(()) => error::SUCCESS.code_num, Err(err) => err.into() } } @@ -472,7 +472,8 @@ mod tests { use api::connection::vcx_connection_create; use indy::{WalletHandle}; - fn create_config_util(logging: Option<&str>) -> String { + #[cfg(any(feature = "agency", feature = "pool_tests"))] + fn create_config_util(_logging: Option<&str>) -> String { json!({"agency_did" : "72x8p4HubxzUK1dwxcc5FU", "remote_to_sdk_did" : "UJGjM6Cea2YVixjWwHN9wq", "sdk_to_remote_did" : "AB3JM851T4EQmhh8CdagSP", @@ -640,7 +641,7 @@ mod tests { CString::new(content).unwrap().into_raw(), Some(cb.get_callback())), error::SUCCESS.code_num); - let err = cb.receive(Some(Duration::from_secs(10))); + let _err = cb.receive(Some(Duration::from_secs(10))); // Assert default wallet name assert_eq!(settings::get_config_value(settings::CONFIG_WALLET_NAME).unwrap(), settings::DEFAULT_WALLET_NAME); } @@ -859,7 +860,7 @@ mod tests { error::INVALID_OPTION.code_num); match get_pool_handle() { - Ok(h) => { pool::close().unwrap(); } + Ok(_h) => { pool::close().unwrap(); } Err(_) => {} }; } @@ -998,9 +999,9 @@ mod tests { #[test] fn get_current_error_works_for_async_error() { - extern fn cb(storage_handle: i32, - err: u32, - config: *const c_char) { + extern fn cb(_storage_handle: i32, + _err: u32, + _config: *const c_char) { let mut error_json_p: *const c_char = ptr::null(); vcx_get_current_error(&mut error_json_p); assert!(CStringUtils::c_str_to_string(error_json_p).unwrap().is_some()); @@ -1052,6 +1053,7 @@ mod tests { assert_eq!(::utils::constants::DEFAULT_AUTHOR_AGREEMENT, agreement.unwrap()); } + #[cfg(feature = "pool_tests")] fn get_settings() -> String { json!({ settings::CONFIG_AGENCY_DID: settings::get_config_value(settings::CONFIG_AGENCY_DID).unwrap(), diff --git a/vcx/libvcx/src/api/wallet.rs b/vcx/libvcx/src/api/wallet.rs index a542386447..3618f084e6 100644 --- a/vcx/libvcx/src/api/wallet.rs +++ b/vcx/libvcx/src/api/wallet.rs @@ -262,7 +262,7 @@ pub extern fn vcx_wallet_add_record(command_handle: CommandHandle, spawn(move || { match wallet::add_record(&type_, &id, &value, Some(&tags_json)) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_add_record(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -317,7 +317,7 @@ pub extern fn vcx_wallet_update_record_value(command_handle: CommandHandle, spawn(move || { match wallet::update_record_value(&type_, &id, &value) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_update_record_value(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -550,7 +550,7 @@ pub extern fn vcx_wallet_delete_record(command_handle: CommandHandle, spawn(move || { match wallet::delete_record(&type_, &id) { - Ok(x) => { + Ok(()) => { trace!("vcx_wallet_delete_record(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); @@ -608,7 +608,7 @@ pub extern fn vcx_wallet_send_tokens(command_handle: CommandHandle, spawn(move || { match pay_a_payee(tokens, &recipient) { - Ok((payment, msg)) => { + Ok((_payment, msg)) => { trace!("vcx_wallet_send_tokens_cb(command_handle: {}, rc: {}, receipt: {})", command_handle, error::SUCCESS.message, msg); let msg = CStringUtils::string_to_cstring(msg); @@ -658,9 +658,9 @@ pub extern fn vcx_wallet_send_tokens(command_handle: CommandHandle, /// Error code as a u32 #[no_mangle] pub extern fn vcx_wallet_open_search(command_handle: CommandHandle, - type_: *const c_char, - query_json: *const c_char, - options_json: *const c_char, + _type_: *const c_char, + _query_json: *const c_char, + _options_json: *const c_char, cb: Option) -> u32 { info!("vcx_wallet_open_search >>>"); @@ -699,7 +699,7 @@ pub extern fn vcx_wallet_open_search(command_handle: CommandHandle, #[no_mangle] pub extern fn vcx_wallet_search_next_records(command_handle: CommandHandle, wallet_search_handle: i32, - count: usize, + _count: usize, cb: Option) -> u32 { info!("vcx_wallet_search_next_records >>>"); @@ -784,7 +784,7 @@ pub extern fn vcx_wallet_export(command_handle: CommandHandle, let path = Path::new(&path); trace!("vcx_wallet_export(command_handle: {}, path: {:?}, backup_key: ****)", command_handle, path); match export(get_wallet_handle(), &path, &backup_key) { - Ok(_) => { + Ok(()) => { let return_code = error::SUCCESS.code_num; trace!("vcx_wallet_export(command_handle: {}, rc: {})", command_handle, return_code); cb(command_handle, return_code); @@ -832,7 +832,7 @@ pub extern fn vcx_wallet_import(command_handle: CommandHandle, thread::spawn(move || { trace!("vcx_wallet_import(command_handle: {}, config: ****)", command_handle); match import(&config) { - Ok(_) => { + Ok(()) => { trace!("vcx_wallet_import(command_handle: {}, rc: {})", command_handle, error::SUCCESS.message); cb(command_handle, error::SUCCESS.code_num); } @@ -967,7 +967,6 @@ pub mod tests { let sig = "signature"; let sig_len = sig.len(); let sig_raw = CString::new(sig).unwrap(); - let res = true; assert_eq!(vcx_wallet_verify_with_address(cb.command_handle, CString::new("address").unwrap().into_raw(), msg_raw.as_ptr() as *const u8, @@ -1100,7 +1099,6 @@ pub mod tests { init!("false"); let xtype = CStringUtils::string_to_cstring("record_type".to_string()); let id = CStringUtils::string_to_cstring("123".to_string()); - let value = CStringUtils::string_to_cstring("Record Value".to_string()); let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -1160,12 +1158,6 @@ pub mod tests { let id = CStringUtils::string_to_cstring("123".to_string()); let value = CStringUtils::string_to_cstring("Record Value".to_string()); let tags = CStringUtils::string_to_cstring("{}".to_string()); - let options = json!({ - "retrieveType": true, - "retrieveValue": true, - "retrieveTags": false - }).to_string(); - let options = CStringUtils::string_to_cstring(options); // Add record let cb = return_types_u32::Return_U32::new().unwrap(); @@ -1244,12 +1236,12 @@ pub mod tests { #[test] fn test_wallet_import_export() { - use utils::devsetup::tests::setup_wallet_env; use std::env; use std::fs; use std::path::Path; use std::time::Duration; use settings; + use utils::devsetup::tests::setup_wallet_env; settings::set_defaults(); teardown!("false"); @@ -1262,7 +1254,7 @@ pub mod tests { if Path::new(&dir).exists() { fs::remove_file(Path::new(&dir)).unwrap(); } - let handle = setup_wallet_env(&wallet_name).unwrap(); + let _handle = setup_wallet_env(&wallet_name).unwrap(); let dir_c_str = CString::new(dir.to_str().unwrap()).unwrap(); let backup_key_c_str = CString::new(backup_key).unwrap(); @@ -1289,8 +1281,6 @@ pub mod tests { Some(cb.get_callback())), error::SUCCESS.code_num); cb.receive(Some(Duration::from_secs(50))).unwrap(); - let handle = setup_wallet_env(&wallet_name).unwrap(); - delete_wallet(&wallet_name, None, None, None).unwrap(); fs::remove_file(Path::new(&dir)).unwrap(); assert!(!Path::new(&dir).exists()); diff --git a/vcx/libvcx/src/connection.rs b/vcx/libvcx/src/connection.rs index 71ceb8ed05..465971461d 100644 --- a/vcx/libvcx/src/connection.rs +++ b/vcx/libvcx/src/connection.rs @@ -219,10 +219,6 @@ impl Connection { fn get_source_id(&self) -> &String { &self.source_id } - fn ready_to_connect(&self) -> bool { - self.state != VcxStateType::VcxStateNone && self.state != VcxStateType::VcxStateAccepted - } - fn create_agent_pairwise(&mut self) -> VcxResult { debug!("creating pairwise keys on agent for connection {}", self.source_id); @@ -257,7 +253,7 @@ impl Connection { Ok(error::SUCCESS.code_num) } - pub fn update_state(&mut self, message: Option) -> VcxResult { + pub fn update_state(&mut self, _message: Option) -> VcxResult { debug!("updating state for connection {}", self.source_id); if self.state == VcxStateType::VcxStateInitialized || self.state == VcxStateType::VcxStateAccepted { @@ -349,7 +345,7 @@ pub fn set_agent_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_agent_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -376,7 +372,7 @@ pub fn set_pw_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_pw_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -394,7 +390,7 @@ pub fn set_their_pw_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_their_pw_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -403,7 +399,7 @@ pub fn set_their_public_did(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { Connections::V1(ref mut connection) => Ok(connection.set_their_public_did(did)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -412,7 +408,7 @@ pub fn get_their_public_did(handle: u32) -> VcxResult> { CONNECTION_MAP.get(handle, |connection| { match connection { Connections::V1(ref connection) => Ok(connection.get_their_public_did()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -430,7 +426,7 @@ pub fn set_their_pw_verkey(handle: u32, did: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_their_pw_verkey(did)), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -439,7 +435,7 @@ pub fn get_uuid(handle: u32) -> VcxResult { CONNECTION_MAP.get(handle, |cxn| { match cxn { Connections::V1(ref connection) => Ok(connection.get_uuid().to_string()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -448,7 +444,7 @@ pub fn set_uuid(handle: u32, uuid: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_uuid(uuid)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -458,7 +454,7 @@ pub fn get_endpoint(handle: u32) -> VcxResult { CONNECTION_MAP.get(handle, |cxn| { match cxn { Connections::V1(ref connection) => Ok(connection.get_endpoint().to_string()), - Connections::V3(ref connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::NoEndpoint))) } @@ -467,7 +463,7 @@ pub fn set_endpoint(handle: u32, endpoint: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_endpoint(endpoint)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -485,7 +481,7 @@ pub fn set_agent_verkey(handle: u32, verkey: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_agent_verkey(verkey).clone()), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -503,7 +499,7 @@ pub fn set_pw_verkey(handle: u32, verkey: &str) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_pw_verkey(verkey).clone()), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -523,7 +519,7 @@ pub fn set_state(handle: u32, state: VcxStateType) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |cxn| { match cxn { Connections::V1(ref mut connection) => Ok(connection.set_state(state)), - Connections::V3(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) + Connections::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -589,7 +585,7 @@ pub fn create_connection_with_invite(source_id: &str, details: &str) -> VcxResul let invite_details: InviteDetail = match serde_json::from_value(details.clone()) { Ok(x) => x, - Err(x) => { + Err(_) => { // Try converting to abbreviated let details = unabbrv_event_detail(details)?; serde_json::from_value(details) @@ -635,7 +631,7 @@ pub fn parse_acceptance_details(message: &Message) -> VcxResult { Ok(response.sender_detail) } MessagePayload::V2(payload) => { - let payload = Payloads::decrypt_payload_v2(&my_vk, &payload)?; + let payload = Payloads::decrypt_payload_v2(&payload)?; let response: AcceptanceDetails = serde_json::from_str(&payload.msg) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot deserialize AcceptanceDetails: {}", err)))?; @@ -770,7 +766,7 @@ pub fn get_invite_details(handle: u32, abbreviated: bool) -> VcxResult { Connections::V1(ref connection) => { match abbreviated { false => { - serde_json::to_string(&connection.invite_detail) + serde_json::to_string(&connection.get_invite_detail()) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidInviteDetail, format!("Cannot serialize InviteDetail: {}", err))) } true => { @@ -796,7 +792,7 @@ pub fn set_invite_details(handle: u32, invite_detail: &InviteDetail) -> VcxResul connection.set_invite_detail(invite_detail.clone()); Ok(()) } - Connections::V3(ref mut connection) => { + Connections::V3(_) => { Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)) } } @@ -960,7 +956,7 @@ pub fn decode_message(handle: u32, message: Message) -> VcxResult { pub fn send_message(handle: u32, message: A2AMessage) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.send_message(&message) } }) @@ -973,7 +969,7 @@ pub fn send_message_to_self_endpoint(message: A2AMessage, did_doc: &DidDoc) -> V pub fn add_pending_messages(handle: u32, messages: HashMap) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.add_pending_messages(messages.clone()) } }) @@ -982,7 +978,7 @@ pub fn add_pending_messages(handle: u32, messages: HashMap) - pub fn remove_pending_message(handle: u32, id: &MessageId) -> VcxResult<()> { CONNECTION_MAP.get_mut(handle, |connection| { match connection { - Connections::V1(ref mut connection) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle)), Connections::V3(ref mut connection) => connection.remove_pending_message(id.clone()) } }) @@ -991,8 +987,8 @@ pub fn remove_pending_message(handle: u32, id: &MessageId) -> VcxResult<()> { pub fn is_v3_connection(connection_handle: u32) -> VcxResult { CONNECTION_MAP.get(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Ok(false), - Connections::V3(ref connection) => Ok(true) + Connections::V1(_) => Ok(false), + Connections::V3(_) => Ok(true) } }).or(Err(VcxError::from(VcxErrorKind::InvalidConnectionHandle))) } @@ -1000,7 +996,7 @@ pub fn is_v3_connection(connection_handle: u32) -> VcxResult { pub fn send_ping(connection_handle: u32, comment: Option) -> VcxResult<()> { CONNECTION_MAP.get_mut(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), Connections::V3(ref mut connection) => connection.send_ping(comment.clone()) } }) @@ -1009,7 +1005,7 @@ pub fn send_ping(connection_handle: u32, comment: Option) -> VcxResult<( pub fn send_discovery_features(connection_handle: u32, query: Option, comment: Option) -> VcxResult<()> { CONNECTION_MAP.get_mut(connection_handle, |connection| { match connection { - Connections::V1(ref connection) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), + Connections::V1(_) => Err(VcxError::from(VcxErrorKind::ActionNotSupported)), Connections::V3(ref mut connection) => connection.send_discovery_features(query.clone(), comment.clone()) } }) @@ -1024,7 +1020,6 @@ pub mod tests { use std::time::Duration; use utils::constants::INVITE_DETAIL_STRING; use super::*; - use rand::Rng; pub fn build_test_connection() -> u32 { let handle = create_connection("alice").unwrap(); @@ -1206,8 +1201,6 @@ pub mod tests { #[test] fn test_parse_acceptance_details() { init!("true"); - let test_name = "test_parse_acceptance_details"; - let handle = rand::thread_rng().gen::(); let response = Message { status_code: MessageStatusCode::Accepted, @@ -1220,23 +1213,6 @@ pub mod tests { decrypted_payload: None, }; - let c = Connection { - source_id: test_name.to_string(), - pw_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), - pw_verkey: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), - state: VcxStateType::VcxStateOfferSent, - uuid: String::new(), - endpoint: String::new(), - invite_detail: None, - invite_url: None, - agent_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), - agent_vk: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), - their_pw_did: String::new(), - their_pw_verkey: String::new(), - public_did: None, - their_public_did: None, - }; - parse_acceptance_details(&response).unwrap(); // test that it fails diff --git a/vcx/libvcx/src/credential.rs b/vcx/libvcx/src/credential.rs index 5b1551da9a..181bf118c1 100644 --- a/vcx/libvcx/src/credential.rs +++ b/vcx/libvcx/src/credential.rs @@ -7,7 +7,7 @@ use api::VcxStateType; use issuer_credential::{CredentialOffer, CredentialMessage, PaymentInfo}; use credential_request::CredentialRequest; use messages; -use messages::{GeneralMessage, RemoteMessageType, ObjectWithVersion}; +use messages::{GeneralMessage, RemoteMessageType}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::get_message; @@ -18,7 +18,6 @@ use utils::libindy::anoncreds::{libindy_prover_create_credential_req, libindy_pr use utils::libindy::anoncreds; use utils::libindy::payments::{pay_a_payee, PaymentTxn}; use utils::error; -use utils::constants::DEFAULT_SERIALIZE_VERSION; use error::prelude::*; use std::convert::TryInto; @@ -166,7 +165,6 @@ impl Credential { self.their_vk, self.my_vk); - let local_their_did = self.their_did.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_their_vk = self.their_vk.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_agent_did = self.agent_did.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; let local_agent_vk = self.agent_vk.as_ref().ok_or(VcxError::from(VcxErrorKind::InvalidCredentialHandle))?; @@ -349,13 +347,9 @@ impl Credential { Ok(self.payment_info.clone()) } - fn to_string(&self) -> VcxResult { - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize Credential")) - } - + #[cfg(test)] fn from_str(data: &str) -> VcxResult { + use messages::ObjectWithVersion; ObjectWithVersion::deserialize(data) .map(|obj: ObjectWithVersion| obj.data) .map_err(|err| err.extend("Cannot deserialize Credential")) @@ -459,7 +453,7 @@ pub fn get_payment_txn(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.get_payment_txn(), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) } }).or(Err(VcxError::from(VcxErrorKind::NoPaymentInformation))) } @@ -471,7 +465,7 @@ pub fn get_credential_offer(handle: u32) -> VcxResult { debug!("getting credential offer {}", obj.source_id); obj.get_credential_offer() } - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement } }) } @@ -480,7 +474,7 @@ pub fn get_credential_id(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => Ok(obj.get_credential_id()), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) } }) } @@ -502,7 +496,7 @@ pub fn generate_credential_request_msg(handle: u32, connection_handle: u32) -> V obj.set_state(VcxStateType::VcxStateOfferSent); req } - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)) // TODO: implement } }).map_err(handle_err) } @@ -531,7 +525,7 @@ pub fn get_credential_offer_msg(connection_handle: u32, msg_id: &str) -> VcxResu return serde_json::to_string(&vec![credential_offer]). map_err(|err| { - VcxError::from_msg(VcxErrorKind::InvalidState, "Cannot serialize Offers") + VcxError::from_msg(VcxErrorKind::InvalidState, format!("Cannot serialize Offers: {:?}", err)) }); } @@ -578,7 +572,7 @@ pub fn get_credential_offer_messages(connection_handle: u32) -> VcxResult VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => Ok(obj.is_payment_required()), - Credentials::V3(ref obj) => Ok(false), + Credentials::V3(_) => Ok(false), } }).map_err(handle_err) } @@ -703,7 +697,7 @@ pub fn submit_payment(handle: u32) -> VcxResult<(PaymentTxn, String)> { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.submit_payment(), - Credentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), + Credentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), } }).map_err(handle_err) } @@ -712,7 +706,7 @@ pub fn get_payment_information(handle: u32) -> VcxResult> { HANDLE_MAP.get(handle, |obj| { match obj { Credentials::V1(ref obj) => obj.get_payment_info(), - Credentials::V3(ref obj) => Ok(None), + Credentials::V3(_) => Ok(None), } }).map_err(handle_err) } @@ -720,7 +714,7 @@ pub fn get_payment_information(handle: u32) -> VcxResult> { pub fn get_credential_status(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { - Credentials::V1(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), + Credentials::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidCredentialHandle)), Credentials::V3(ref obj) => obj.get_credential_status(), } }) @@ -820,7 +814,7 @@ pub mod tests { assert_eq!(get_state(c_h).unwrap(), VcxStateType::VcxStateAccepted as u32); assert_eq!(get_credential_id(c_h).unwrap(), "cred_id"); // this is set in test mode assert!(get_credential(c_h).unwrap().len() > 100); - let serialized = to_string(c_h).unwrap(); + let _serialized = to_string(c_h).unwrap(); } #[test] @@ -845,7 +839,7 @@ pub mod tests { let connection_h = connection::tests::build_test_connection(); let offer = get_credential_offer_messages(connection_h).unwrap(); let o: serde_json::Value = serde_json::from_str(&offer).unwrap(); - let credential_offer: CredentialOffer = serde_json::from_str(&o[0][0].to_string()).unwrap(); + let _credential_offer: CredentialOffer = serde_json::from_str(&o[0][0].to_string()).unwrap(); assert!(offer.len() > 50); } @@ -889,9 +883,9 @@ pub mod tests { fn test_get_credential() { init!("true"); let handle = from_string(::utils::constants::DEFAULT_SERIALIZED_CREDENTIAL).unwrap(); - let offer_string = get_credential_offer(handle).unwrap(); + let _offer_string = get_credential_offer(handle).unwrap(); let handle = from_string(::utils::constants::FULL_CREDENTIAL_SERIALIZED).unwrap(); - let cred_string = get_credential(handle).unwrap(); + let _cred_string = get_credential(handle).unwrap(); } #[test] @@ -913,6 +907,6 @@ pub mod tests { let offer_string = get_credential_offer(handle).unwrap(); let offer_value: serde_json::Value = serde_json::from_str(&offer_string).unwrap(); - let offer_struct: CredentialOffer = serde_json::from_value(offer_value["credential_offer"].clone()).unwrap(); + let _offer_struct: CredentialOffer = serde_json::from_value(offer_value["credential_offer"].clone()).unwrap(); } } diff --git a/vcx/libvcx/src/credential_def.rs b/vcx/libvcx/src/credential_def.rs index 390c29d4ce..7dc238863f 100644 --- a/vcx/libvcx/src/credential_def.rs +++ b/vcx/libvcx/src/credential_def.rs @@ -439,7 +439,6 @@ pub mod tests { let wallet_name = "test_create_revocable_fails_with_no_tails_file"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -458,7 +457,6 @@ pub mod tests { let wallet_name = "test_create_revocable_cred_def"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -484,7 +482,6 @@ pub mod tests { fn test_create_credential_def_real() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -504,7 +501,7 @@ pub mod tests { fn test_create_credential_def_no_fees_real() { init!("ledger"); - let rc = create_cred_def_real(false); + let _rc = create_cred_def_real(false); } #[cfg(feature = "pool_tests")] @@ -514,7 +511,7 @@ pub mod tests { let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let my_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let handle = create_and_publish_credentialdef("1".to_string(), + let _handle = create_and_publish_credentialdef("1".to_string(), "name".to_string(), my_did.clone(), schema_id.clone(), @@ -588,7 +585,7 @@ pub mod tests { use utils::libindy::payments::add_new_did; init!("ledger_zero_fees"); - let (schema_handle, schema_id, did, revocation_details) = prepare_create_cred_def_data(false); + let (_, schema_id, did, revocation_details) = prepare_create_cred_def_data(false); let (endorser_did, _) = add_new_did(Some("ENDORSER")); @@ -613,7 +610,7 @@ pub mod tests { use utils::libindy::payments::add_new_did; init!("ledger"); - let (schema_handle, schema_id, did, revocation_details) = prepare_create_cred_def_data(true); + let (_, schema_id, did, revocation_details) = prepare_create_cred_def_data(true); let (endorser_did, _) = add_new_did(Some("ENDORSER")); diff --git a/vcx/libvcx/src/credential_request.rs b/vcx/libvcx/src/credential_request.rs index d6f85f3b62..2f33aee5f3 100644 --- a/vcx/libvcx/src/credential_request.rs +++ b/vcx/libvcx/src/credential_request.rs @@ -35,8 +35,6 @@ mod tests { use serde_json; use utils::constants::{CREDENTIAL_REQ_STRING, CRED_REQ, CRED_REQ_META}; - static TEMP_ISSUER_DID: &'static str = "4reqXeZVm7JZAffAoaNLsb"; - fn create_credential_req() -> CredentialRequest { ::settings::set_defaults(); let issuer_did = ::settings::get_config_value(::settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -59,7 +57,6 @@ mod tests { #[test] fn test_deserialize() { - let issuer_did = String::from("4reqXeZVm7JZAffAoaNLsb"); let req: CredentialRequest = serde_json::from_str(CREDENTIAL_REQ_STRING).unwrap(); assert_eq!(&req.libindy_cred_req, CRED_REQ); } diff --git a/vcx/libvcx/src/disclosed_proof.rs b/vcx/libvcx/src/disclosed_proof.rs index c5465d7c15..5b466cdb7d 100644 --- a/vcx/libvcx/src/disclosed_proof.rs +++ b/vcx/libvcx/src/disclosed_proof.rs @@ -8,7 +8,7 @@ use object_cache::ObjectCache; use api::VcxStateType; use connection; use messages; -use messages::{GeneralMessage, RemoteMessageType, ObjectWithVersion}; +use messages::{GeneralMessage, RemoteMessageType}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::proofs::proof_message::ProofMessage; @@ -17,7 +17,7 @@ use messages::get_message::Message; use error::prelude::*; use settings; use utils::{httpclient, error}; -use utils::constants::{DEFAULT_SERIALIZE_VERSION, CREDS_FROM_PROOF_REQ, DEFAULT_GENERATED_PROOF}; +use utils::constants::{CREDS_FROM_PROOF_REQ, DEFAULT_GENERATED_PROOF}; use utils::libindy::cache::{get_rev_reg_cache, set_rev_reg_cache, RevRegCache, RevState}; use utils::libindy::anoncreds; use utils::libindy::anoncreds::{get_rev_reg_def_json, get_rev_reg_delta_json}; @@ -326,7 +326,7 @@ impl DisclosedProof { // do same for predicates and self_attested if let Value::Object(ref mut map) = rtn["requested_attributes"] { for ref cred_info in credentials_identifiers { - if let Some(ref attr) = proof_req.requested_attributes.get(&cred_info.requested_attr) { + if let Some(_) = proof_req.requested_attributes.get(&cred_info.requested_attr) { let insert_val = json!({"cred_id": cred_info.referent, "revealed": true, "timestamp": cred_info.timestamp}); map.insert(cred_info.requested_attr.to_owned(), insert_val); } @@ -335,7 +335,7 @@ impl DisclosedProof { if let Value::Object(ref mut map) = rtn["requested_predicates"] { for ref cred_info in credentials_identifiers { - if let Some(ref attr) = proof_req.requested_predicates.get(&cred_info.requested_attr) { + if let Some(_) = proof_req.requested_predicates.get(&cred_info.requested_attr) { let insert_val = json!({"cred_id": cred_info.referent, "timestamp": cred_info.timestamp}); map.insert(cred_info.requested_attr.to_owned(), insert_val); } @@ -459,19 +459,6 @@ impl DisclosedProof { fn set_source_id(&mut self, id: &str) { self.source_id = id.to_string(); } fn get_source_id(&self) -> &String { &self.source_id } - - fn to_string(&self) -> VcxResult { - trace!("DisclosedProof::to_string >>>"); - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize DisclosedProof")) - } - fn from_str(data: &str) -> VcxResult { - trace!("DisclosedProof::from_str >>> data: {}", secret!(&data)); - ObjectWithVersion::deserialize(data) - .map(|obj: ObjectWithVersion| obj.data) - .map_err(|err| err.extend("Cannot deserialize DisclosedProof")) - } } //******************************************** @@ -602,7 +589,7 @@ pub fn generate_proof(handle: u32, credentials: String, self_attested_attrs: Str pub fn decline_presentation_request(handle: u32, connection_handle: u32, reason: Option, proposal: Option) -> VcxResult { HANDLE_MAP.get_mut(handle, |obj| { match obj { - DisclosedProofs::V1(obj) => { + DisclosedProofs::V1(_) => { Err(VcxError::from(VcxErrorKind::ActionNotSupported)) }, DisclosedProofs::V3(ref mut obj) => { @@ -674,7 +661,7 @@ pub fn get_proof_request_messages(connection_handle: u32, match_name: Option<&st return serde_json::to_string(&msgs). map_err(|err| { - VcxError::from_msg(VcxErrorKind::InvalidState, "Cannot serialize ProofRequestMessage") + VcxError::from_msg(VcxErrorKind::InvalidState, format!("Cannot serialize ProofRequestMessage: {:?}", err)) }); } @@ -736,7 +723,7 @@ pub fn get_source_id(handle: u32) -> VcxResult { pub fn get_presentation_status(handle: u32) -> VcxResult { HANDLE_MAP.get(handle, |obj| { match obj { - DisclosedProofs::V1(obj) => Err(VcxError::from(VcxErrorKind::InvalidDisclosedProofHandle)), + DisclosedProofs::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidDisclosedProofHandle)), DisclosedProofs::V3(ref obj) => Ok(obj.presentation_status()) } }) @@ -817,7 +804,7 @@ mod tests { let serialized = to_string(handle).unwrap(); let j: Value = serde_json::from_str(&serialized).unwrap(); assert_eq!(j["version"], "1.0"); - DisclosedProof::from_str(&serialized).unwrap(); + from_string(&serialized).unwrap(); } #[test] @@ -829,7 +816,6 @@ mod tests { fn test_find_schemas() { init!("true"); - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_schemas_json(&Vec::new()).unwrap(), "{}".to_string()); let cred1 = CredInfo { @@ -876,7 +862,6 @@ mod tests { tails_file: None, timestamp: None, }]; - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_schemas_json(&credential_ids).unwrap_err().kind(), VcxErrorKind::InvalidSchema); } @@ -907,7 +892,6 @@ mod tests { }; let creds = vec![cred1, cred2]; - let proof: DisclosedProof = Default::default(); let credential_def = DisclosedProof::build_cred_def_json(&creds).unwrap(); assert!(credential_def.len() > 0); assert!(credential_def.contains(r#""id":"2hoqvcwupRTUNkXn6ArYzs:3:CL:2471","schemaId":"2471""#)); @@ -928,7 +912,6 @@ mod tests { tails_file: None, timestamp: None, }]; - let proof: DisclosedProof = Default::default(); assert_eq!(DisclosedProof::build_cred_def_json(&credential_ids).unwrap_err().kind(), VcxErrorKind::InvalidProofCredentialData); } @@ -975,7 +958,6 @@ mod tests { "requested_predicates":{} }); - let proof: DisclosedProof = Default::default(); let proof_req = json!({ "nonce": "123432421212", "name": "proof_req_1", @@ -1095,7 +1077,6 @@ mod tests { #[test] fn test_retrieve_credentials_fails_with_no_proof_req() { init!("false"); - let proof: DisclosedProof = Default::default(); assert_eq!(proof.retrieve_credentials().unwrap_err().kind(), VcxErrorKind::NotReady); } @@ -1281,7 +1262,7 @@ mod tests { fn test_generate_proof() { init!("ledger"); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, _, cred_def_id, _, _, _, _, cred_id, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); + ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let mut proof_req = ProofRequestMessage::create(); let to = time::get_time().sec; let indy_proof_req = json!({ @@ -1335,8 +1316,6 @@ mod tests { #[test] fn test_generate_self_attested_proof() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let mut proof_req = ProofRequestMessage::create(); let indy_proof_req = json!({ "nonce":"123432421212", @@ -1374,7 +1353,7 @@ mod tests { fn test_generate_proof_with_predicates() { init!("ledger"); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, _, cred_def_id, _, _, _, _, cred_id, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); + ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let mut proof_req = ProofRequestMessage::create(); let to = time::get_time().sec; let indy_proof_req = json!({ @@ -1501,7 +1480,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache.rev_state, None); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1552,7 +1530,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1607,7 +1584,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); @@ -1662,7 +1638,6 @@ mod tests { let cache = get_rev_reg_cache(&rev_reg_id); assert_eq!(cache, cached_data); - let (_, rev_reg_def_json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); let states = build_rev_states_json(vec![cred2].as_mut()).unwrap(); assert!(states.contains(&rev_reg_id)); diff --git a/vcx/libvcx/src/issuer_credential.rs b/vcx/libvcx/src/issuer_credential.rs index 84059fd0e7..352b57db62 100644 --- a/vcx/libvcx/src/issuer_credential.rs +++ b/vcx/libvcx/src/issuer_credential.rs @@ -5,14 +5,14 @@ use api::VcxStateType; use v3; use messages; use settings; -use messages::{RemoteMessageType, MessageStatusCode, GeneralMessage, ObjectWithVersion}; +use messages::{RemoteMessageType, MessageStatusCode, GeneralMessage}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use connection; use credential_request::CredentialRequest; use utils::error; use utils::libindy::{payments, anoncreds}; -use utils::constants::{CRED_MSG, DEFAULT_SERIALIZE_VERSION}; +use utils::constants::{CRED_MSG}; use utils::openssl::encode; use utils::libindy::payments::PaymentTxn; use utils::qualifier::Qualifier; @@ -34,8 +34,6 @@ enum IssuerCredentials { V3(Issuer), } -static CREDENTIAL_OFFER_ID_KEY: &str = "claim_offer_id"; - #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct IssuerCredential { source_id: String, @@ -129,7 +127,7 @@ impl PaymentInfo { pub fn to_string(&self) -> VcxResult { serde_json::to_string(&self) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot serialize payment info"))) + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Cannot serialize payment info: {:?}", err))) } } @@ -140,7 +138,7 @@ impl IssuerCredential { Ok(error::SUCCESS.code_num) } - pub fn generate_credential_offer_msg(&mut self, connection_handle: u32) -> VcxResult<(String, String)> { + pub fn generate_credential_offer_msg(&mut self, _connection_handle: u32) -> VcxResult<(String, String)> { let mut payload = Vec::new(); let connection_name = settings::get_config_value(settings::CONFIG_INSTITUTION_NAME)?; @@ -301,7 +299,7 @@ impl IssuerCredential { let (payload, thread) = Payloads::decrypt(&self.issued_vk, &message) .map_err(|err| VcxError::from_msg(VcxErrorKind::Common(err.into()), "Cannot decrypt CredentialOffer payload"))?; - if let Some(tr) = thread { + if let Some(_) = thread { let remote_did = self.remote_did.as_str(); self.thread.as_mut().map(|thread| thread.increment_receiver(&remote_did)); } @@ -335,7 +333,6 @@ impl IssuerCredential { self.state as u32 } fn get_offer_uid(&self) -> &String { &self.msg_uid } - fn set_offer_uid(&mut self, uid: &str) { self.msg_uid = uid.to_owned(); } fn get_credential_attributes(&self) -> &String { &self.credential_attributes } fn get_source_id(&self) -> &String { &self.source_id } @@ -372,7 +369,7 @@ impl IssuerCredential { msg_type: PayloadKinds::Cred.name().to_string(), libindy_cred: cred, rev_reg_def_json: self.rev_reg_def_json.clone().unwrap_or(String::new()), - cred_def_id: self.cred_def_id.clone(), + cred_def_id, cred_revoc_id, revoc_reg_delta_json, }) @@ -469,17 +466,14 @@ impl IssuerCredential { } } + #[cfg(test)] pub fn to_string(&self) -> VcxResult { + use messages::ObjectWithVersion; + use utils::constants::DEFAULT_SERIALIZE_VERSION; ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) .serialize() .map_err(|err| err.extend("Cannot serialize credential")) } - - fn from_str(data: &str) -> VcxResult { - ObjectWithVersion::deserialize(data) - .map(|obj: ObjectWithVersion| obj.data) - .map_err(|err| err.extend("Cannot deserialize IssuerCredential")) - } } /** @@ -556,7 +550,7 @@ pub fn get_encoded_attributes(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => obj.create_attributes_encodings(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) } }) } @@ -565,7 +559,7 @@ pub fn get_offer_uid(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => Ok(obj.get_offer_uid().to_string()), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)) } }) } @@ -574,7 +568,7 @@ pub fn get_payment_txn(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => obj.get_payment_txn(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NoPaymentInformation)) } }) } @@ -646,7 +640,7 @@ pub fn update_state(handle: u32, message: Option) -> VcxResult { IssuerCredentials::V1(ref mut obj) => { match obj.update_state(message.clone()) { Ok(x) => Ok(x), - Err(x) => Ok(obj.get_state()), + Err(_) => Ok(obj.get_state()), } } IssuerCredentials::V3(ref mut obj) => { @@ -669,7 +663,7 @@ pub fn get_state(handle: u32) -> VcxResult { pub fn get_credential_status(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { - IssuerCredentials::V1(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), + IssuerCredentials::V1(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), IssuerCredentials::V3(ref obj) => obj.get_credential_status(), } }) @@ -706,7 +700,7 @@ pub fn generate_credential_offer_msg(handle: u32, connection_handle: u32) -> Vcx ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.generate_credential_offer_msg(connection_handle), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement } }) } @@ -729,7 +723,7 @@ pub fn generate_credential_msg(handle: u32, connection_handle: u32) -> VcxResult ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.generate_credential_msg(connection_handle), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidIssuerCredentialHandle)), // TODO: implement } }) } @@ -752,14 +746,14 @@ pub fn revoke_credential(handle: u32) -> VcxResult<()> { ISSUER_CREDENTIAL_MAP.get_mut(handle, |obj| { match obj { IssuerCredentials::V1(ref mut obj) => obj.revoke_cred(), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement } }) } pub fn convert_to_map(s: &str) -> VcxResult> { serde_json::from_str(s) - .map_err(|err| { + .map_err(|_| { warn!("{}", error::INVALID_ATTRIBUTES_STRUCTURE.message); VcxError::from_msg(VcxErrorKind::InvalidAttributesStructure, error::INVALID_ATTRIBUTES_STRUCTURE.message) }) @@ -769,7 +763,7 @@ pub fn get_credential_attributes(handle: u32) -> VcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |obj| { match obj { IssuerCredentials::V1(ref obj) => Ok(obj.get_credential_attributes().to_string()), - IssuerCredentials::V3(ref obj) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement + IssuerCredentials::V3(_) => Err(VcxError::from(VcxErrorKind::NotReady)), // TODO: implement } }) } @@ -802,14 +796,6 @@ pub mod tests { static DEFAULT_CREDENTIAL_NAME: &str = "Credential"; static DEFAULT_CREDENTIAL_ID: &str = "defaultCredentialId"; - static SCHEMA: &str = r#"{{ - "seqNo":32, - "data":{{ - "name":"gvt", - "version":"1.0", - "attr_names":["address1","address2","city","state", "zip"] - }} - }}"#; static CREDENTIAL_DATA: &str = r#"{"address2":["101 Wilson Lane"], @@ -819,12 +805,7 @@ pub mod tests { "address1":["101 Tela Lane"] }"#; - static X_CREDENTIAL_JSON: &str = - r#"{"claim":{"address1":["101 Tela Lane","63690509275174663089934667471948380740244018358024875547775652380902762701972"],"address2":["101 Wilson Lane","68086943237164982734333428280784300550565381723532936263016368251445461241953"],"city":["SLC","101327353979588246869873249766058188995681113722618593621043638294296500696424"],"state":["UT","93856629670657830351991220989031130499313559332549427637940645777813964461231"],"zip":["87121","87121"]},"issuer_did":"NcYxiDXkpYi6ov5FcYDi1e","schema_seq_no":15,"signature":{"non_revocation_claim":null,"primary_claim":{"a":"","e":"","m2":"","v":""}}}"#; - - pub fn util_put_credential_def_in_issuer_wallet(schema_seq_num: u32, wallet_handle: i32) { - let stored_xcredential = String::from(""); - + pub fn util_put_credential_def_in_issuer_wallet(_schema_seq_num: u32, _wallet_handle: i32) { let issuer_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let tag = "test_tag"; let config = "{support_revocation: false}"; @@ -868,7 +849,6 @@ pub mod tests { } pub fn create_pending_issuer_credential() -> IssuerCredential { - let connection_handle = build_test_connection(); let credential_req: CredentialRequest = serde_json::from_str(CREDENTIAL_REQ_STRING).unwrap(); let (credential_offer, _) = ::credential::parse_json_offer(CREDENTIAL_OFFER_JSON).unwrap(); let credential: IssuerCredential = IssuerCredential { @@ -903,20 +883,6 @@ pub mod tests { credential } - fn normalize_credentials(c1: &str, c2: &str) -> (serde_json::Value, serde_json::Value) { - let mut v1: serde_json::Value = serde_json::from_str(c1.clone()).unwrap(); - let mut v2: serde_json::Value = serde_json::from_str(c2.clone()).unwrap(); - v1["signature"]["primary_claim"]["a"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["e"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["v"] = serde_json::to_value("".to_owned()).unwrap(); - v1["signature"]["primary_claim"]["m2"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["a"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["e"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["v"] = serde_json::to_value("".to_owned()).unwrap(); - v2["signature"]["primary_claim"]["m2"] = serde_json::to_value("".to_owned()).unwrap(); - (v1, v2) - } - pub fn create_full_issuer_credential() -> (IssuerCredential, ::credential::Credential) { let issuer_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(true); @@ -1004,8 +970,6 @@ pub mod tests { init!("true"); let connection_handle = build_test_connection(); - let credential_id = DEFAULT_CREDENTIAL_ID; - let handle = issuer_credential_create(::credential_def::tests::create_cred_def_fake(), "1".to_string(), "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), @@ -1023,7 +987,7 @@ pub mod tests { #[test] fn test_generate_cred_offer() { init!("ledger"); - let issuer = create_full_issuer_credential().0.generate_credential_offer(&settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap()).unwrap(); + let _issuer = create_full_issuer_credential().0.generate_credential_offer(&settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap()).unwrap(); } #[test] @@ -1031,8 +995,6 @@ pub mod tests { init!("true"); let connection_handle = build_test_connection(); - let credential_id = DEFAULT_CREDENTIAL_ID; - let handle = issuer_credential_create(::credential_def::tests::create_cred_def_fake(), "1".to_string(), "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), @@ -1211,7 +1173,7 @@ pub mod tests { r#"{"name":["frank"],"gpa":["4.0"]}"#.to_string(), 1).unwrap(); - let encoded_attributes = self::get_encoded_attributes(issuer_credential_handle).unwrap(); + let _encoded_attributes = self::get_encoded_attributes(issuer_credential_handle).unwrap(); } #[test] @@ -1299,27 +1261,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = @@ -1333,28 +1295,17 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - - let address2: &Value = &results["address2"]; - assert_eq!(encode("101 Wilson Lane").unwrap(), address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!(encode("UT").unwrap(), state["encoded"]); - assert_eq!("UT", state["raw"]); - - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); + assert_eq!(expected, results); } #[test] fn test_encode_with_one_attribute_success() { let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2":["101 Wilson Lane"]}"#; @@ -1371,28 +1322,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); - + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2":"101 Wilson Lane", @@ -1405,28 +1355,17 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - - let address2: &Value = &results["address2"]; - assert_eq!(encode("101 Wilson Lane").unwrap(), address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!(encode("UT").unwrap(), state["encoded"]); - assert_eq!("UT", state["raw"]); - - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); + assert_eq!(expected, results); } #[test] fn test_encode_with_new_format_one_attribute_success() { let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + } + }); static TEST_CREDENTIAL_DATA: &str = r#"{"address2": "101 Wilson Lane"}"#; @@ -1443,27 +1382,27 @@ pub mod tests { // for reference....expectation is encode_attributes returns this: let expected = json!({ -"address2": { -"encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", -"raw": "101 Wilson Lane" -}, -"zip": { -"encoded": "87121", -"raw": "87121" -}, -"city": { -"encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", -"raw": "SLC" -}, -"address1": { -"encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", -"raw": "101 Tela Lane" -}, -"state": { -"encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", -"raw": "UT" -} -}); + "address2": { + "encoded": "68086943237164982734333428280784300550565381723532936263016368251445461241953", + "raw": "101 Wilson Lane" + }, + "zip": { + "encoded": "87121", + "raw": "87121" + }, + "city": { + "encoded": "101327353979588246869873249766058188995681113722618593621043638294296500696424", + "raw": "SLC" + }, + "address1": { + "encoded": "63690509275174663089934667471948380740244018358024875547775652380902762701972", + "raw": "101 Tela Lane" + }, + "state": { + "encoded": "93856629670657830351991220989031130499313559332549427637940645777813964461231", + "raw": "UT" + } + }); static TEST_CREDENTIAL_DATA: &str = @@ -1477,18 +1416,8 @@ pub mod tests { let results_json = encode_attributes(TEST_CREDENTIAL_DATA).unwrap(); let results: Value = serde_json::from_str(&results_json).unwrap(); - let address2: &Value = &results["address2"]; - - assert_eq!("68086943237164982734333428280784300550565381723532936263016368251445461241953", address2["encoded"]); - assert_eq!("101 Wilson Lane", address2["raw"]); - - let state: &Value = &results["state"]; - assert_eq!("93856629670657830351991220989031130499313559332549427637940645777813964461231", state["encoded"]); - assert_eq!("UT", state["raw"]); + assert_eq!(expected, results); - let zip: &Value = &results["zip"]; - assert_eq!("87121", zip["encoded"]); - assert_eq!("87121", zip["raw"]); } #[test] diff --git a/vcx/libvcx/src/lib.rs b/vcx/libvcx/src/lib.rs index 21b905f3ae..16631b1f37 100644 --- a/vcx/libvcx/src/lib.rs +++ b/vcx/libvcx/src/lib.rs @@ -1,6 +1,4 @@ #![cfg_attr(feature = "fatal_warnings", deny(warnings))] -#![allow(unused_variables)] -#![allow(dead_code)] #![crate_name = "vcx"] //this is needed for some large json macro invocations #![recursion_limit = "128"] @@ -14,7 +12,6 @@ extern crate futures; #[macro_use] extern crate log; -extern crate log4rs; extern crate libc; @@ -68,6 +65,7 @@ pub mod disclosed_proof; pub mod v3; #[allow(unused_imports)] +#[allow(dead_code)] #[cfg(test)] mod tests { @@ -282,7 +280,7 @@ mod tests { attrs_list.as_array_mut().unwrap().push(json!(format!("key{}",i))); } let attrs_list = attrs_list.to_string(); - let (schema_id, schema_json, cred_def_id, cred_def_json, cred_def_handle, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, false); + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def_handle, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, false); let mut credential_data = json!({}); for i in 1..number_of_attributes { credential_data[format!("key{}", i)] = json!([format!("value{}",i)]); @@ -342,7 +340,6 @@ mod tests { #[cfg(feature = "pool_tests")] #[test] fn test_real_proof_with_revocation() { - let number_of_attributes = 10; init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (faber, alice) = ::connection::tests::create_connected_connections(); @@ -350,7 +347,7 @@ mod tests { // CREATE SCHEMA AND CRED DEF println!("creating schema/credential_def and paying fees"); let attrs_list = json!(["address1", "address2", "city", "state", "zip"]).to_string(); - let (schema_id, schema_json, cred_def_id, cred_def_json, cred_def_handle, rev_reg_id) = + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def_handle, rev_reg_id) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(&attrs_list, true); // AS INSTITUTION SEND CREDENTIAL OFFER @@ -381,7 +378,7 @@ mod tests { proof::update_state(proof_req_handle, None).unwrap(); assert_eq!(proof::get_proof_state(proof_req_handle).unwrap(), ProofStateType::ProofValidated as u32); println!("proof validated!"); - let wallet = ::utils::libindy::payments::get_wallet_token_info().unwrap(); + let _wallet = ::utils::libindy::payments::get_wallet_token_info().unwrap(); // AS INSTITUTION REVOKE CRED revoke_credential(credential_offer, rev_reg_id); diff --git a/vcx/libvcx/src/messages/create_key.rs b/vcx/libvcx/src/messages/create_key.rs index 0ebda33f9a..e9f85d4d5e 100644 --- a/vcx/libvcx/src/messages/create_key.rs +++ b/vcx/libvcx/src/messages/create_key.rs @@ -117,7 +117,6 @@ mod tests { #[test] fn test_create_key_set_values() { - let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; let for_did = "11235yBzrpJQmNyZzgoTqB"; let for_verkey = "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; @@ -130,9 +129,9 @@ mod tests { fn test_create_key_set_values_and_serialize() { init!("false"); - let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); + let (_agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/get_message.rs b/vcx/libvcx/src/messages/get_message.rs index 0125302847..a134435f9d 100644 --- a/vcx/libvcx/src/messages/get_message.rs +++ b/vcx/libvcx/src/messages/get_message.rs @@ -288,13 +288,13 @@ impl Message { let decrypted_payload = match payload { MessagePayload::V1(payload) => Payloads::decrypt_payload_v1(&vk, &payload) .map(Payloads::PayloadV1), - MessagePayload::V2(payload) => Payloads::decrypt_payload_v2(&vk, &payload) + MessagePayload::V2(payload) => Payloads::decrypt_payload_v2(&payload) .map(Payloads::PayloadV2) }; if let Ok(decrypted_payload) = decrypted_payload { new_message.decrypted_payload = ::serde_json::to_string(&decrypted_payload).ok(); - } else if let Ok(decrypted_payload) = self._decrypt_v3_message(vk) { + } else if let Ok(decrypted_payload) = self._decrypt_v3_message() { new_message.decrypted_payload = ::serde_json::to_string(&json!(decrypted_payload)).ok() } else { new_message.decrypted_payload = ::serde_json::to_string(&json!(null)).ok(); @@ -304,14 +304,14 @@ impl Message { new_message } - fn _decrypt_v3_message(&self, vk: &str) -> VcxResult<::messages::payload::PayloadV1> { + fn _decrypt_v3_message(&self) -> VcxResult<::messages::payload::PayloadV1> { use v3::messages::a2a::A2AMessage; use v3::utils::encryption_envelope::EncryptionEnvelope; use ::issuer_credential::{CredentialOffer, CredentialMessage}; use ::messages::payload::{PayloadTypes, PayloadV1, PayloadKinds}; use std::convert::TryInto; - let a2a_message = EncryptionEnvelope::open(vk, self.payload()?)?; + let a2a_message = EncryptionEnvelope::open(self.payload()?)?; let (kind, msg) = match a2a_message { A2AMessage::PresentationRequest(presentation_request) => { @@ -438,7 +438,6 @@ mod tests { fn test_parse_get_connection_messages_response() { init!("true"); - let json: serde_json::Value = rmp_serde::from_slice(GET_ALL_MESSAGES_RESPONSE).unwrap(); let result = GetMessagesBuilder::parse_download_messages_response(GET_ALL_MESSAGES_RESPONSE.to_vec()).unwrap(); assert_eq!(result.len(), 1) } @@ -452,12 +451,6 @@ mod tests { last_updated_date_time: "2017-12-14T03:35:20.444Z[UTC]".to_string(), }; - let delivery_details2 = DeliveryDetails { - to: "3Xk9vxK9jeiqVaCPrEQ8bg".to_string(), - status_code: "MDS-101".to_string(), - last_updated_date_time: "2017-12-14T03:35:20.500Z[UTC]".to_string(), - }; - let msg1 = Message { status_code: MessageStatusCode::Accepted, payload: Some(MessagePayload::V1(vec![-9, 108, 97, 105, 109, 45, 100, 97, 116, 97])), @@ -491,7 +484,7 @@ mod tests { let bundle = Bundled::create(data).encode().unwrap(); let message = crypto::prep_msg(&my_vk, &verkey, &bundle[..]).unwrap(); - let result = GetMessagesBuilder::create().parse_response(message).unwrap(); + let _result = GetMessagesBuilder::create().parse_response(message).unwrap(); } #[cfg(feature = "agency")] @@ -503,7 +496,7 @@ mod tests { init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(false); let credential_data = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#; diff --git a/vcx/libvcx/src/messages/invite.rs b/vcx/libvcx/src/messages/invite.rs index 44dec38c5f..7ba2098454 100644 --- a/vcx/libvcx/src/messages/invite.rs +++ b/vcx/libvcx/src/messages/invite.rs @@ -535,8 +535,8 @@ mod tests { init!("false"); let (user_did, user_vk) = create_and_store_my_did(None).unwrap(); let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); - let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/mod.rs b/vcx/libvcx/src/messages/mod.rs index 023cc3fc6a..0d9ee3f63f 100644 --- a/vcx/libvcx/src/messages/mod.rs +++ b/vcx/libvcx/src/messages/mod.rs @@ -858,7 +858,7 @@ impl Bundled { pub fn try_i8_bundle(data: Vec) -> VcxResult>> { let bundle: Bundled> = rmp_serde::from_slice(&data[..]) - .map_err(|err| { + .map_err(|_| { warn!("could not deserialize bundle with i8, will try u8"); VcxError::from_msg(VcxErrorKind::InvalidMessagePack, "Could not deserialize bundle with i8") })?; diff --git a/vcx/libvcx/src/messages/payload.rs b/vcx/libvcx/src/messages/payload.rs index a3a0f438e4..03adf4b608 100644 --- a/vcx/libvcx/src/messages/payload.rs +++ b/vcx/libvcx/src/messages/payload.rs @@ -87,7 +87,7 @@ impl Payloads { Ok((payload.msg, None)) } MessagePayload::V2(payload) => { - let payload = Payloads::decrypt_payload_v2(my_vk, payload)?; + let payload = Payloads::decrypt_payload_v2(payload)?; Ok((payload.msg, Some(payload.thread))) } } @@ -102,7 +102,7 @@ impl Payloads { Ok(my_payload) } - pub fn decrypt_payload_v2(my_vk: &str, payload: &::serde_json::Value) -> VcxResult { + pub fn decrypt_payload_v2(payload: &::serde_json::Value) -> VcxResult { let payload = ::serde_json::to_vec(&payload) .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidState, err))?; diff --git a/vcx/libvcx/src/messages/proofs/proof_message.rs b/vcx/libvcx/src/messages/proofs/proof_message.rs index 1ae33ea013..46a878b140 100644 --- a/vcx/libvcx/src/messages/proofs/proof_message.rs +++ b/vcx/libvcx/src/messages/proofs/proof_message.rs @@ -80,10 +80,6 @@ pub mod tests { use super::*; use ::utils::constants::{SCHEMA_ID, CRED_DEF_ID, REV_REG_ID}; - static TEMP_REQUESTER_DID: &'static str = "GxtnGN6ypZYgEqcftSQFnC"; - static MSG_FROM_API: &str = r#"{"proofs":{"claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4":{"proof":{"primary_proof":{"eq_proof":{"revealed_attrs":{"sex":"5944657099558967239210949258394887428692050081607692519917050011144233115103","name":"1139481716457488690172217916278103335"},"a_prime":"55115757663642844902979276276581544287881791112969892277372135316353511833640150801244335663890109536491278379177551666081054765286807563008348637104046950934828407012194403360724040287698135607556244297972578864339500981366412262454282194811242239615009347165118318516694216754501345324782597475927199400880006212632553233049354866295429520527445980181939247828351677971991914388778860092824318440481574181300185829423762990910739241691289976584754979812272223819007422499654272590946235912914032826994670588466080422906806402660885408376207875827950805200378568062518210110828954480363081643567615791016011737856977","e":"34976147138641338975844073241645969211530343885520088294714132974884138611036204288689212378023649179372520412699253155486970203797562324","v":"961473607552945346906354315658276499450491951690969023699851664262072769313929148332129868528140265952852653009499943891795293148107502144091334703992581737220352761140064276811372868396353572957613845323343723271098601244774874235526135299483412285009916812621185291842845156342501611029106982811773616231232684804116984093651972537804480090649736612551759833591251845595059217608938213987633789344584340351801507541774726753840600143685051258161251666953243698589585559347435011414292427590918153421953579895479604685390401357681887618798200391305919594609949167659780330698000168295871428737686822637913218269005987492318466661186509308179489615192663542904993253626728197630057096161118638090776180812895097232529119979970798938360220605280817954648588493778338816318524451785027916181454650102696493927306340658666852294316562458212054696739343800993703515542777264448535624584845146378512183572107830260813929222999","m":{},"m1":"75548120024969192086664289521241751069844239013520403238642886571169851979005373784309432586593371476370934469326730539754613694936161784687213609047455188306625204249706249661640538349287762196100659095340756990269587317065862046598569445591945049204366911309949910119711238973099702616527117177036784698661","m2":"287944186286321709724396773443214682376883853676549188669693055373059354657799325692443906346632814001611911026063358134413175852024773765930829079850890920811398176944587192618"},"ge_proofs":[{"u":{"1":"1","0":"0","3":"3","2":"4"},"r":{"1":"1","0":"2","DELTA":"3","3":"4","2":"5"},"mj":"6","alpha":"7","t":{"1":"8","3":"3","0":"2","DELTA":"1","2":"2"},"predicate":{"attr_name":"age","p_type":"GE","value":18,"schema_seq_no":14,"issuer_did":"33UDR9R7fjwELRvH9JT6HH"}}]},"non_revoc_proof":null},"schema_seq_no":103,"issuer_did":"V4SGRU86Z58d6TV7PBUe6f"}},"aggregated_proof":{"c_hash":"63330487197040957750863022608534150304998351350639315143102570772502292901825","c_list":[[1,180,153,212,162,132,5,189,14,181,140,112,236,109,182,76,91,6,161,215,62,207,205,135,86,211,49,197,215,198,104,201,14,22,48,6,112,170,31,191,110,118,121,15,62,114,126,249,221,107,114,161,163,234,19,233,150,236,182,217,195,6,218,217,193,6,94,160,33,23,103,147,109,221,81,38,138,20,225,141,68,37,142,10,225,79,164,119,168,250,188,186,47,229,165,8,237,230,14,35,53,176,97,28,82,105,87,210,117,16,154,222,66,11,96,172,90,13,239,190,29,71,11,88,53,36,219,139,67,21,136,58,161,164,97,106,56,230,55,157,59,35,187,235,154,194,111,93,168,135,67,15,97,136,38,169,87,142,32,255,50,247,111,83,44,88,251,99,6,226,182,170,146,229,118,164,118,228,235,51,137,168,135,50,1,14,1,201,72,175,102,241,149,117,88,83,84,37,205,130,26,155,124,158,211,89,112,33,46,24,94,93,202,8,127,172,214,178,6,156,79,188,132,223,239,127,200,158,95,247,139,101,51,162,168,175,74,1,67,201,94,108,192,14,130,109,217,248,193,10,142,37,95,231,227,251,209]]},"requested_proof":{"revealed_attrs":{"attr2_uuid":["claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4","male","5944657099558967239210949258394887428692050081607692519917050011144233115103"],"attr1_uuid":["claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4","Alex","1139481716457488690172217916278103335"]},"unrevealed_attrs":{},"self_attested_attrs":{"self_attr":"self_value"},"predicates":{"predicate_id":"claim::71b6070f-14ba-45fa-876d-1fe8491fe5d4"}},"remoteDid":"KP8AaEBc368CMK1PqZaEzX","userPairwiseDid":"PofTCeegEXT7S2aAePhM6a"}"#; - static TEST_ATTRS: &str = r#"[{"schema_seq_no":14,"issuer_did":"33UDR9R7fjwELRvH9JT6HH","credential_uuid":"claim::f33cc7c8-924f-4541-aeff-29a9aed9c46b","proof_attrs":[{"name":"state","value":"UT","revealed":true}]},{"schema_seq_no":15,"issuer_did":"4fUDR9R7fjwELRvH9JT6HH","credential_uuid":"claim::f22cc7c8-924f-4541-aeff-29a9aed9c46b","proof_attrs":[{"name":"state","value":"UT","revealed":true}]}]"#; - pub fn create_default_proof() -> ProofMessage { let mut proof = ProofMessage::new(); proof.libindy_proof = ::utils::constants::INDY_PROOF_JSON.to_string(); diff --git a/vcx/libvcx/src/messages/proofs/proof_request.rs b/vcx/libvcx/src/messages/proofs/proof_request.rs index 9959603711..19e1ad392a 100644 --- a/vcx/libvcx/src/messages/proofs/proof_request.rs +++ b/vcx/libvcx/src/messages/proofs/proof_request.rs @@ -199,7 +199,7 @@ impl ProofRequestMessage { } names.join(",") } - (Some(name), Some(names)) => { + (Some(_), Some(_)) => { return Err(VcxError::from_msg(VcxErrorKind::InvalidProofRequest, format!("Proof Request validation failed: there is empty requested attribute: {:?}", attrs))); } @@ -340,7 +340,7 @@ impl ProofRequestData { pub fn set_requested_attributes(mut self, requested_attrs: String) -> VcxResult { let requested_attributes: Vec = ::serde_json::from_str(&requested_attrs) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}", requested_attrs)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}, err: {:?}", requested_attrs, err)))?; self.requested_attributes = requested_attributes .into_iter() @@ -352,7 +352,7 @@ impl ProofRequestData { pub fn set_requested_predicates(mut self, requested_predicates: String) -> VcxResult { let requested_predicates: Vec = ::serde_json::from_str(&requested_predicates) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}", requested_predicates)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Requested Attributes: {:?}, err: {:?}", requested_predicates, err)))?; self.requested_predicates = requested_predicates .into_iter() @@ -364,7 +364,7 @@ impl ProofRequestData { pub fn set_not_revoked_interval(mut self, non_revoc_interval: String) -> VcxResult { let non_revoc_interval: NonRevokedInterval = ::serde_json::from_str(&non_revoc_interval) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Revocation Interval: {:?}", non_revoc_interval)))?; + .map_err(|_| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("Invalid Revocation Interval: {:?}", non_revoc_interval)))?; self.non_revoked = match (non_revoc_interval.from, non_revoc_interval.to) { (None, None) => None, @@ -447,7 +447,6 @@ mod tests { let data_name = "Test"; let nonce = "123432421212"; let data_version = "3.75"; - let attrs = ""; let version = "1.3"; let tid = 89; let mid = 98; @@ -528,6 +527,6 @@ mod tests { #[test] fn test_indy_proof_req_parses_correctly() { - let proof_req: ProofRequestData = serde_json::from_str(::utils::constants::INDY_PROOF_REQ_JSON).unwrap(); + let _proof_req: ProofRequestData = serde_json::from_str(::utils::constants::INDY_PROOF_REQ_JSON).unwrap(); } } \ No newline at end of file diff --git a/vcx/libvcx/src/messages/send_message.rs b/vcx/libvcx/src/messages/send_message.rs index 55ebcf3fe3..66017da363 100644 --- a/vcx/libvcx/src/messages/send_message.rs +++ b/vcx/libvcx/src/messages/send_message.rs @@ -255,7 +255,7 @@ mod tests { }; /* just check that it doesn't panic */ - let packed = message.prepare_request().unwrap(); + let _packed = message.prepare_request().unwrap(); } #[test] @@ -287,7 +287,6 @@ mod tests { let uid = response.get_msg_uid().unwrap(); assert_eq!(test_val, uid); - let test_val = "devin"; let response = SendResponse { uid: None, uids: vec![], @@ -302,8 +301,7 @@ mod tests { #[test] fn test_send_generic_message() { init!("agency"); - let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); match send_generic_message(alice, "this is the message", &json!({"msg_type":"type", "msg_title": "title", "ref_msg_id":null}).to_string()) { Ok(x) => println!("message id: {}", x), @@ -320,7 +318,6 @@ mod tests { #[test] fn test_send_message_and_download_response() { init!("agency"); - let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (faber, alice) = ::connection::tests::create_connected_connections(); let msg_id = send_generic_message(alice, "this is the message", &json!({"msg_type":"type", "msg_title": "title", "ref_msg_id":null}).to_string()).unwrap(); diff --git a/vcx/libvcx/src/messages/update_connection.rs b/vcx/libvcx/src/messages/update_connection.rs index 2e63082e0c..f2c9e3109c 100644 --- a/vcx/libvcx/src/messages/update_connection.rs +++ b/vcx/libvcx/src/messages/update_connection.rs @@ -93,19 +93,11 @@ impl DeleteConnectionBuilder { let mut response = parse_response_from_agency(response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateConnectionResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateConnectionResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateConnectionResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateConnectionResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateConnectionResponse")) } } - - fn print_info(&self) { - println!("\n****\n**** message pack: Delete Connection"); - println!("self.status_code {:?}", &self.status_code); - println!("self.to_vk: {}", &self.to_vk); - println!("self.agent_did: {}", &self.agent_did); - println!("self.agent_vk: {}", &self.agent_vk); - } } pub fn send_delete_connection_message(pw_did: &str, pw_verkey: &str, agent_did: &str, agent_vk: &str) -> VcxResult<()> { diff --git a/vcx/libvcx/src/messages/update_message.rs b/vcx/libvcx/src/messages/update_message.rs index 49703549e4..65e3d35689 100644 --- a/vcx/libvcx/src/messages/update_message.rs +++ b/vcx/libvcx/src/messages/update_message.rs @@ -105,8 +105,8 @@ impl UpdateMessageStatusByConnectionsBuilder { let mut response = parse_response_from_agency(response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateMessageStatusByConnectionsResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateMessageStatusByConnectionsResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateMessageStatusByConnectionsResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateMessageStatusByConnectionsResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateMessageStatusByConnectionsResponse")) } } @@ -154,7 +154,7 @@ mod tests { use std::time::Duration; init!("agency"); let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, alice) = ::connection::tests::create_connected_connections(); let (_, cred_def_handle) = ::credential_def::tests::create_cred_def_real(false); diff --git a/vcx/libvcx/src/messages/update_profile.rs b/vcx/libvcx/src/messages/update_profile.rs index 7c3d9f5955..65941509cb 100644 --- a/vcx/libvcx/src/messages/update_profile.rs +++ b/vcx/libvcx/src/messages/update_profile.rs @@ -123,8 +123,8 @@ impl UpdateProfileDataBuilder { let mut response = parse_response_from_agency(&response)?; match response.remove(0) { - A2AMessage::Version1(A2AMessageV1::UpdateConfigsResponse(res)) => Ok(()), - A2AMessage::Version2(A2AMessageV2::UpdateConfigsResponse(res)) => Ok(()), + A2AMessage::Version1(A2AMessageV1::UpdateConfigsResponse(_)) => Ok(()), + A2AMessage::Version2(A2AMessageV2::UpdateConfigsResponse(_)) => Ok(()), _ => Err(VcxError::from_msg(VcxErrorKind::InvalidHttpResponse, "Message does not match any variant of UpdateConfigsResponse")) } } @@ -142,7 +142,7 @@ mod tests { let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; let name = "name"; let url = "https://random.com"; - let msg = update_data() + let _msg = update_data() .to(to_did).unwrap() .name(&name).unwrap() .logo_url(&url).unwrap() @@ -153,8 +153,8 @@ mod tests { fn test_update_data_set_values_and_post() { init!("false"); let (agent_did, agent_vk) = create_and_store_my_did(Some(MY2_SEED)).unwrap(); - let (my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); - let (agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); + let (_my_did, my_vk) = create_and_store_my_did(Some(MY1_SEED)).unwrap(); + let (_agency_did, agency_vk) = create_and_store_my_did(Some(MY3_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_AGENCY_VERKEY, &agency_vk); settings::set_config_value(settings::CONFIG_REMOTE_TO_SDK_VERKEY, &agent_vk); diff --git a/vcx/libvcx/src/messages/validation.rs b/vcx/libvcx/src/messages/validation.rs index 6f94990f15..c153cbb78c 100644 --- a/vcx/libvcx/src/messages/validation.rs +++ b/vcx/libvcx/src/messages/validation.rs @@ -55,7 +55,7 @@ pub fn validate_url(url: &str) -> VcxResult { pub fn validate_actors(actors: &str) -> VcxResult> { ::serde_json::from_str(&actors) - .map_err(|err| VcxError::from(VcxErrorKind::InvalidOption)) + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidOption, format!("Invalid actors: {:?}", err))) } pub fn validate_phone_number(p_num: &str) -> VcxResult { @@ -70,7 +70,7 @@ mod tests { fn test_did_is_b58_and_valid_length() { let to_did = "8XFh8yBzrpJQmNyZzgoTqB"; match validate_did(&to_did) { - Err(x) => panic!("Should be valid did"), + Err(_) => panic!("Should be valid did"), Ok(x) => assert_eq!(x, to_did.to_string()) } } @@ -80,7 +80,7 @@ mod tests { let to_did = "8XFh8yBzrpJQmNyZzgoT"; match validate_did(&to_did) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::InvalidDid), - Ok(x) => panic!("Should be invalid did"), + Ok(_) => panic!("Should be invalid did"), } } @@ -89,7 +89,7 @@ mod tests { let to_did = "8*Fh8yBzrpJQmNyZzgoTqB"; match validate_did(&to_did) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::NotBase58), - Ok(x) => panic!("Should be invalid did"), + Ok(_) => panic!("Should be invalid did"), } } @@ -97,7 +97,7 @@ mod tests { fn test_verkey_is_b58_and_valid_length() { let verkey = "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; match validate_verkey(&verkey) { - Err(x) => panic!("Should be valid verkey"), + Err(_) => panic!("Should be valid verkey"), Ok(x) => assert_eq!(x, verkey) } } @@ -107,7 +107,7 @@ mod tests { let verkey = "8XFh8yBzrpJQmNyZzgoT"; match validate_verkey(&verkey) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::InvalidVerkey), - Ok(x) => panic!("Should be invalid verkey"), + Ok(_) => panic!("Should be invalid verkey"), } } @@ -116,7 +116,7 @@ mod tests { let verkey = "*kVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A"; match validate_verkey(&verkey) { Err(x) => assert_eq!(x.kind(), VcxErrorKind::NotBase58), - Ok(x) => panic!("Should be invalid verkey"), + Ok(_) => panic!("Should be invalid verkey"), } } } \ No newline at end of file diff --git a/vcx/libvcx/src/object_cache/mod.rs b/vcx/libvcx/src/object_cache/mod.rs index b403e8496f..2a7accad08 100644 --- a/vcx/libvcx/src/object_cache/mod.rs +++ b/vcx/libvcx/src/object_cache/mod.rs @@ -45,7 +45,7 @@ impl ObjectCache { match store.get(&handle) { Some(m) => match m.lock() { Ok(obj) => closure(obj.deref()), - Err(err) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error + Err(_) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error }, None => Err(VcxError::from_msg(VcxErrorKind::InvalidHandle, format!("Object not found for handle: {}", handle))) } @@ -57,7 +57,7 @@ impl ObjectCache { match store.get_mut(&handle) { Some(m) => match m.lock() { Ok(mut obj) => closure(obj.deref_mut()), - Err(err) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error + Err(_) => Err(VcxError::from_msg(VcxErrorKind::Common(10), "Unable to lock Object Store")) //TODO better error }, None => Err(VcxError::from_msg(VcxErrorKind::InvalidHandle, format!("Object not found for handle: {}", handle))) } @@ -108,7 +108,7 @@ mod tests { #[test] fn create_test() { - let c: ObjectCache = Default::default(); + let _c: ObjectCache = Default::default(); } #[test] @@ -124,13 +124,14 @@ mod tests { fn to_string_test() { let test: ObjectCache = Default::default(); let handle = test.add(2222).unwrap(); - let string: String = test.get(handle, |obj| { + let string: String = test.get(handle, |_| { Ok(String::from("TEST")) }).unwrap(); assert_eq!("TEST", string); } + #[test] fn mut_object_test() { let test: ObjectCache = Default::default(); let handle = test.add(String::from("TEST")).unwrap(); @@ -144,6 +145,6 @@ mod tests { Ok(obj.clone()) }).unwrap(); - assert_eq!("test", string); + assert_eq!("TEST", string); } } diff --git a/vcx/libvcx/src/proof.rs b/vcx/libvcx/src/proof.rs index e8b2eaea63..cf9af24d47 100644 --- a/vcx/libvcx/src/proof.rs +++ b/vcx/libvcx/src/proof.rs @@ -8,14 +8,13 @@ use connection; use api::{VcxStateType, ProofStateType}; use messages; use messages::proofs::proof_message::{ProofMessage, CredInfo}; -use messages::{RemoteMessageType, ObjectWithVersion, GeneralMessage}; +use messages::{RemoteMessageType, GeneralMessage}; use messages::payload::{Payloads, PayloadKinds}; use messages::thread::Thread; use messages::proofs::proof_request::{ProofRequestMessage, ProofRequestVersion}; use utils::error; use utils::constants::*; use utils::libindy::anoncreds; -use utils::constants::DEFAULT_SERIALIZE_VERSION; use object_cache::ObjectCache; use error::prelude::*; use utils::openssl::encode; @@ -213,10 +212,6 @@ impl Proof { } fn proof_validation(&mut self) -> VcxResult { - let proof_msg = self.proof - .clone() - .ok_or(VcxError::from(VcxErrorKind::InvalidProof))?; - let proof_json = self.build_proof_json()?; let proof_req_json = self.build_proof_req_json()?; @@ -355,7 +350,7 @@ impl Proof { let (payload, thread) = Payloads::decrypt(&self.prover_vk, &message)?; - if let Some(tr) = thread { + if let Some(_) = thread { let remote_did = self.remote_did.as_str(); self.thread.as_mut().map(|thread| thread.increment_receiver(&remote_did)); } @@ -367,14 +362,14 @@ impl Proof { debug!("proof: {}", payload); self.proof = match parse_proof_payload(&payload) { - Err(err) => return Ok(self.get_state()), + Err(_) => return Ok(self.get_state()), Ok(x) => Some(x), }; self.state = VcxStateType::VcxStateAccepted; match self.proof_validation() { - Ok(x) => { + Ok(_) => { if self.proof_state != ProofStateType::ProofInvalid { debug!("Proof format was validated for proof {}", self.source_id); self.proof_state = ProofStateType::ProofValidated; @@ -406,15 +401,11 @@ impl Proof { fn get_proof_uuid(&self) -> &String { &self.msg_uid } - fn get_source_id(&self) -> &String { &self.source_id } - - fn to_string(&self) -> VcxResult { - ObjectWithVersion::new(DEFAULT_SERIALIZE_VERSION, self.to_owned()) - .serialize() - .map_err(|err| err.extend("Cannot serialize Proof")) - } + fn get_source_id(&self) -> String { self.source_id.to_string() } + #[cfg(test)] fn from_str(data: &str) -> VcxResult { + use messages::ObjectWithVersion; ObjectWithVersion::deserialize(data) .map(|obj: ObjectWithVersion| obj.data) .map_err(|err| err.extend("Cannot deserialize Proof")) @@ -528,8 +519,10 @@ pub fn to_string(handle: u32) -> VcxResult { pub fn get_source_id(handle: u32) -> VcxResult { PROOF_MAP.get(handle, |obj| { - serde_json::to_string(obj) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidState, format!("cannot serialize Proofs object: {:?}", err))) + match obj { + Proofs::V1(ref obj) => Ok(obj.get_source_id()), + Proofs::V3(ref obj) => Ok(obj.get_source_id()) + } }) } @@ -567,7 +560,7 @@ pub fn get_proof_uuid(handle: u32) -> VcxResult { PROOF_MAP.get(handle, |obj| { match obj { Proofs::V1(ref obj) => Ok(obj.get_proof_uuid().clone()), - Proofs::V3(ref obj) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)) + Proofs::V3(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)) } }) } @@ -603,15 +596,6 @@ mod tests { use utils::httpclient; use connection::tests::build_test_connection; use utils::libindy::{pool, set_libindy_rc}; - use indy_sys::CommandHandle; - - static PROOF_MSG: &str = r#"{"msg_type":"proof","version":"0.1","to_did":"BnRXf8yDMUwGyZVDkSENeq","from_did":"GxtnGN6ypZYgEqcftSQFnC","proof_request_id":"cCanHnpFAD","proofs":{"claim::e5fec91f-d03d-4513-813c-ab6db5715d55":{"proof":{"primary_proof":{"eq_proof":{"revealed_attrs":{"state":"96473275571522321025213415717206189191162"},"a_prime":"22605045280481376895214546474258256134055560453004805058368015338423404000586901936329279496160366852115900235316791489357953785379851822281248296428005020302405076144264617943389810572564188437603815231794326272302243703078443007359698858400857606408856314183672828086906560155576666631125808137726233827430076624897399072853872527464581329767287002222137559918765406079546649258389065217669558333867707240780369514832185660287640444094973804045885379406641474693993903268791773620198293469768106363470543892730424494655747935463337367735239405840517696064464669905860189004121807576749786474060694597244797343224031","e":"70192089123105616042684481760592174224585053817450673797400202710878562748001698340846985261463026529360990669802293480312441048965520897","v":"1148619141217957986496757711054111791862691178309410923416837802801708689012670430650138736456223586898110113348220116209094530854607083005898964558239710027534227973983322542548800291320747321452329327824406430787211689678096549398458892087551551587767498991043777397791000822007896620414888602588897806008609113730393639807814070738699614969916095861363383223421727858670289337712185089527052065958362840287749622133424503902085247641830693297082507827948006947829401008622239294382186995101394791468192083810475776455445579931271665980788474331866572497866962452476638881287668931141052552771328556458489781734943404258692308937784221642452132005267809852656378394530342203469943982066011466088478895643800295937901139711103301249691253510784029114718919483272055970725860849610885050165709968510696738864528287788491998027072378656038991754015693216663830793243584350961586874315757599094357535856429087122365865868729","m":{"address2":"11774234640096848605908744857306447015748098256395922562149769943967941106193320512788344020652220849708117081570187385467979956319507248530701654682748372348387275979419669108338","city":"4853213962270369118453000522408430296589146124488849630769837449684434138367659379663124155088827069418193027370932024893343033367076071757003149452226758383807126385017161888440","address1":"12970590675851114145396120869959510754345567924518524026685086869487243290925032320159287997675756075512889990901552679591155319959039145119122576164798225386578339739435869622811","zip":"8333721522340131864419931745588776943042067606218561135102011966361165456174036379901390244538991611895455576519950813910672825465382312504250936740379785802177629077591444977329"},"m1":"92853615502250003546205004470333326341901175168428906399291824325990659330595200000112546157141090642053863739870044907457400076448073272490169488870502566172795456430489790324815765612798273406119873266684053517977802902202155082987833343670942161987285661291655743810590661447300059024966135828466539810035","m2":"14442362430453309930284822850357071315613831915865367971974791350454381198894252834180803515368579729220423713315556807632571621646127926114010380486713602821529657583905131582938"},"ge_proofs":[]},"non_revoc_proof":null},"schema_seq_no":15,"issuer_did":"4fUDR9R7fjwELRvH9JT6HH"}},"aggregated_proof":{"c_hash":"68430476900085482958838239880418115228681348197588159723604944078288347793331","c_list":[[179,17,2,242,194,227,92,203,28,32,255,113,112,20,5,243,9,111,220,111,21,210,116,12,167,119,253,181,37,40,143,215,140,42,179,97,75,229,96,94,54,248,206,3,48,14,61,219,160,122,139,227,166,183,37,43,197,200,28,220,217,10,65,42,6,195,124,44,164,65,114,206,51,231,254,156,170,141,21,153,50,251,237,65,147,97,243,17,157,116,213,201,80,119,106,70,88,60,55,36,33,160,135,106,60,212,191,235,116,57,78,177,61,86,44,226,205,100,134,118,93,6,26,58,220,66,232,166,202,62,90,174,231,207,19,239,233,223,70,191,199,100,157,62,139,176,28,184,9,70,116,199,142,237,198,183,12,32,53,84,207,202,77,56,97,177,154,169,223,201,212,163,212,101,184,255,215,167,16,163,136,44,25,123,49,15,229,41,149,133,159,86,106,208,234,73,207,154,194,162,141,63,159,145,94,47,174,51,225,91,243,2,221,202,59,11,212,243,197,208,116,42,242,131,221,137,16,169,203,215,239,78,254,150,42,169,202,132,172,106,179,130,178,130,147,24,173,213,151,251,242,44,54,47,208,223]]},"requested_proof":{"revealed_attrs":{"sdf":["claim::e5fec91f-d03d-4513-813c-ab6db5715d55","UT","96473275571522321025213415717206189191162"]},"unrevealed_attrs":{},"self_attested_attrs":{},"predicates":{}}}"#; - - extern "C" fn create_cb(command_handle: CommandHandle, err: u32, connection_handle: u32) { - assert_eq!(err, 0); - assert!(connection_handle > 0); - println!("successfully called create_cb") - } fn create_boxed_proof() -> Box { Box::new(Proof { @@ -775,8 +759,6 @@ mod tests { fn test_update_state_with_pending_proof() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -811,8 +793,6 @@ mod tests { fn test_update_state_with_message() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -844,8 +824,6 @@ mod tests { fn test_get_proof_returns_proof_when_proof_state_invalid() { init!("true"); - let connection_handle = build_test_connection(); - let mut proof = Box::new(Proof { source_id: "12".to_string(), msg_uid: String::from("1234"), @@ -886,8 +864,6 @@ mod tests { #[test] fn test_build_credential_defs_json_with_multiple_credentials() { init!("true"); - let proof = create_boxed_proof(); - let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -911,7 +887,6 @@ mod tests { #[test] fn test_build_schemas_json_with_multiple_schemas() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -935,7 +910,6 @@ mod tests { #[test] fn test_build_rev_reg_defs_json() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -959,7 +933,6 @@ mod tests { #[test] fn test_build_rev_reg_json() { init!("true"); - let proof = create_boxed_proof(); let cred1 = CredInfo { schema_id: "schema_key1".to_string(), cred_def_id: "cred_def_key1".to_string(), @@ -1081,9 +1054,7 @@ mod tests { fn test_get_proof_request_status_can_be_retried() { init!("true"); - let connection_handle = build_test_connection(); - - let new_handle = 1; + let _new_handle = 1; let mut proof = create_boxed_proof(); @@ -1144,8 +1115,7 @@ mod tests { #[test] fn test_proof_verification() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, proof_req, proof) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, proof_req, proof) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); proof_req_obj.proof_request_data = serde_json::from_str(&proof_req).unwrap(); @@ -1169,7 +1139,6 @@ mod tests { #[test] fn test_self_attested_proof_verification() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); let (proof_req, proof) = ::utils::libindy::anoncreds::tests::create_self_attested_proof(); let mut proof_req_obj = ProofRequestMessage::create(); @@ -1208,8 +1177,7 @@ mod tests { "requested_predicates": {}, }).to_string(); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, _, proof) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, _, proof) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); proof_req_obj.proof_request_data = serde_json::from_str(&proof_req).unwrap(); @@ -1242,8 +1210,7 @@ mod tests { #[test] fn test_proof_validate_attribute() { init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schemas, cred_defs, proof_req, proof_json) = ::utils::libindy::anoncreds::tests::create_proof(); + let (_, _, proof_req, proof_json) = ::utils::libindy::anoncreds::tests::create_proof(); let mut proof_req_obj = ProofRequestMessage::create(); @@ -1258,7 +1225,7 @@ mod tests { proof_msg.libindy_proof = proof_json.clone(); proof.proof = Some(proof_msg); - let rc = proof.proof_validation().unwrap(); + let _rc = proof.proof_validation().unwrap(); assert_eq!(proof.proof_state, ProofStateType::ProofValidated); } diff --git a/vcx/libvcx/src/schema.rs b/vcx/libvcx/src/schema.rs index 6c26587349..ea7e58350c 100644 --- a/vcx/libvcx/src/schema.rs +++ b/vcx/libvcx/src/schema.rs @@ -3,7 +3,6 @@ use serde_json; use std::string::ToString; use api::PublicEntityStateType; -use settings; use utils::libindy::anoncreds; use utils::libindy::ledger; use utils::libindy::payments::PaymentTxn; @@ -60,7 +59,7 @@ impl CreateSchema { } fn update_state(&mut self) -> VcxResult { - if let Ok(res) = anoncreds::get_schema_json(&self.schema_id) { + if anoncreds::get_schema_json(&self.schema_id).is_ok() { self.state = PublicEntityStateType::Published } Ok(self.state as u32) @@ -78,11 +77,11 @@ pub fn create_and_publish_schema(source_id: &str, debug!("creating schema with source_id: {}, name: {}, issuer_did: {}", source_id, name, issuer_did); let (schema_id, schema) = anoncreds::create_schema(&name, &version, &data)?; - let payment_txn = anoncreds::publish_schema(&name, &schema)?; + let payment_txn = anoncreds::publish_schema(&schema)?; debug!("created schema on ledger with id: {}", schema_id); - let schema_handle = _store_schema(source_id, issuer_did, name, version, schema_id, data, payment_txn, PublicEntityStateType::Published)?; + let schema_handle = _store_schema(source_id, name, version, schema_id, data, payment_txn, PublicEntityStateType::Published)?; Ok(schema_handle) } @@ -97,18 +96,17 @@ pub fn prepare_schema_for_endorser(source_id: &str, debug!("preparing schema for endorser with source_id: {}, name: {}, issuer_did: {}", source_id, name, issuer_did); let (schema_id, schema) = anoncreds::create_schema(&name, &version, &data)?; - let schema_request = anoncreds::build_schema_request(&name, &schema)?; + let schema_request = anoncreds::build_schema_request(&schema)?; let schema_request = ledger::set_endorser(&schema_request, &endorser)?; debug!("prepared schema for endorser with id: {}", schema_id); - let schema_handle = _store_schema(source_id, issuer_did, name, version, schema_id, data, None, PublicEntityStateType::Built)?; + let schema_handle = _store_schema(source_id, name, version, schema_id, data, None, PublicEntityStateType::Built)?; Ok((schema_handle, schema_request)) } fn _store_schema(source_id: &str, - issuer_did: String, name: String, version: String, schema_id: String, @@ -132,8 +130,6 @@ fn _store_schema(source_id: &str, pub fn get_schema_attrs(source_id: String, schema_id: String) -> VcxResult<(u32, String)> { trace!("get_schema_attrs >>> source_id: {}, schema_id: {}", source_id, schema_id); - let submitter_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID)?; - let (schema_id, schema_data_json) = anoncreds::get_schema_json(&schema_id) .map_err(|err| err.map(VcxErrorKind::InvalidSchemaSeqNo, "Schema not found"))?; @@ -215,6 +211,7 @@ pub fn get_state(handle: u32) -> VcxResult { #[cfg(test)] pub mod tests { extern crate rand; + use settings; use super::*; #[allow(unused_imports)] @@ -258,7 +255,7 @@ pub mod tests { let value: serde_json::Value = serde_json::from_str(&schema_str).unwrap(); assert_eq!(value["version"], "1.0"); let data = value["data"].clone(); - let schema: CreateSchema = serde_json::from_str(&data.to_string()).unwrap(); + let _schema: CreateSchema = serde_json::from_str(&data.to_string()).unwrap(); } #[test] @@ -322,7 +319,7 @@ pub mod tests { assert!(payment.len() > 50); assert!(handle > 0); - let schema_id = get_schema_id(handle).unwrap(); + let _schema_id = get_schema_id(handle).unwrap(); } #[cfg(feature = "pool_tests")] @@ -333,7 +330,7 @@ pub mod tests { let handle = create_schema_real(); assert!(handle > 0); - let schema_id = get_schema_id(handle).unwrap(); + let _schema_id = get_schema_id(handle).unwrap(); } #[cfg(feature = "pool_tests")] diff --git a/vcx/libvcx/src/settings.rs b/vcx/libvcx/src/settings.rs index 0895241d0b..d0b35048ea 100644 --- a/vcx/libvcx/src/settings.rs +++ b/vcx/libvcx/src/settings.rs @@ -157,11 +157,6 @@ pub fn validate_config(config: &HashMap) -> VcxResult { Ok(error::SUCCESS.code_num) } -fn validate_wallet_key(key: &str) -> VcxResult { - if key == UNINITIALIZED_WALLET_KEY { return Err(VcxError::from(VcxErrorKind::MissingWalletKey)); } - Ok(error::SUCCESS.code_num) -} - fn validate_optional_config_val(val: Option<&String>, err: VcxErrorKind, closure: F) -> VcxResult where F: Fn(&str) -> Result { if val.is_none() { return Ok(error::SUCCESS.code_num); } @@ -189,7 +184,7 @@ pub fn test_indy_mode_enabled() -> bool { pub fn get_threadpool_size() -> usize { let size = match get_config_value(CONFIG_THREADPOOL_SIZE) { Ok(x) => x.parse::().unwrap_or(DEFAULT_THREADPOOL_SIZE), - Err(x) => DEFAULT_THREADPOOL_SIZE, + Err(_) => DEFAULT_THREADPOOL_SIZE, }; if size > MAX_THREADPOOL_SIZE { @@ -281,7 +276,7 @@ pub fn set_config_value(key: &str, value: &str) { .insert(key.to_string(), value.to_string()); } -pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, storage_config: Option<&str>) -> String { +pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, _storage_config: Option<&str>) -> String { // TODO: _storage_config must be used let mut config = json!({ "id": wallet_name, "storage_type": wallet_type @@ -293,7 +288,7 @@ pub fn get_wallet_config(wallet_name: &str, wallet_type: Option<&str>, storage_c config.to_string() } -pub fn get_wallet_credentials(storage_creds: Option<&str>) -> String { +pub fn get_wallet_credentials(_storage_creds: Option<&str>) -> String { // TODO: storage_creds must be used? let key = get_config_value(CONFIG_WALLET_KEY).unwrap_or(UNINITIALIZED_WALLET_KEY.to_string()); let mut credentials = json!({"key": key}); @@ -328,7 +323,7 @@ pub fn get_actors() -> Vec { get_config_value(ACTORS) .and_then(|actors| ::serde_json::from_str(&actors) - .map_err(|err| VcxError::from(VcxErrorKind::InvalidOption)) + .map_err(|_| VcxError::from(VcxErrorKind::InvalidOption)) ).unwrap_or_else(|_| Actors::iter().collect()) } @@ -414,7 +409,7 @@ pub fn remove_file_if_exists(filename: &str) { trace!("remove_file_if_exists >>> filename: {}", filename); if Path::new(filename).exists() { match fs::remove_file(filename) { - Ok(t) => (), + Ok(()) => (), Err(e) => println!("Unable to remove file: {:?}", e) } } @@ -547,8 +542,6 @@ pub mod tests { #[test] fn test_validate_config_failures() { let invalid = "invalid"; - let valid_did = DEFAULT_DID; - let valid_ver = DEFAULT_VERKEY; let mut config: HashMap = HashMap::new(); assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::MissingWalletKey); diff --git a/vcx/libvcx/src/utils/devsetup.rs b/vcx/libvcx/src/utils/devsetup.rs index 84d3ad9511..b953bbae0d 100644 --- a/vcx/libvcx/src/utils/devsetup.rs +++ b/vcx/libvcx/src/utils/devsetup.rs @@ -212,8 +212,8 @@ pub mod tests { pub fn setup_ledger_env(use_zero_fees: bool) { match pool::get_pool_handle() { - Ok(x) => pool::close().unwrap(), - Err(x) => (), + Ok(_) => pool::close().unwrap(), + Err(_) => (), }; pool::tests::delete_test_pool(); @@ -388,7 +388,7 @@ pub mod tests { init!("agency"); - let (faber, alice) = ::connection::tests::create_connected_connections(); + let (_faber, _alice) = ::connection::tests::create_connected_connections(); set_institution(); wallet::tests::delete_test_wallet(&format!("{}_{}", constants::ENTERPRISE_PREFIX, settings::DEFAULT_WALLET_NAME)); pool::close().unwrap(); diff --git a/vcx/libvcx/src/utils/error.rs b/vcx/libvcx/src/utils/error.rs index 09b85198ba..db80e8495f 100644 --- a/vcx/libvcx/src/utils/error.rs +++ b/vcx/libvcx/src/utils/error.rs @@ -233,7 +233,7 @@ fn insert_c_message(map: &mut HashMap, error: &Error) { } // Helper function for static defining of error messages. Does limited checking that it can. -fn insert_message(map: &mut HashMap, error: &Error) { +fn _insert_message(map: &mut HashMap, error: &Error) { if map.contains_key(&error.code_num) { panic!("Error Code number was repeated which is not allowed! (likely a copy/paste error)") } diff --git a/vcx/libvcx/src/utils/httpclient.rs b/vcx/libvcx/src/utils/httpclient.rs index e7a620a787..c438e0f26f 100644 --- a/vcx/libvcx/src/utils/httpclient.rs +++ b/vcx/libvcx/src/utils/httpclient.rs @@ -44,8 +44,8 @@ pub fn post_message(body_content: &Vec, url: &str) -> VcxResult> { if !response.status().is_success() { let mut content = String::new(); match response.read_to_string(&mut content) { - Ok(x) => info!("Request failed: {}", content), - Err(x) => info!("could not read response"), + Ok(_) => info!("Request failed: {}", content), + Err(_) => info!("could not read response"), }; return Err(VcxError::from_msg(VcxErrorKind::PostMessageFailed, format!("POST failed with: {}", content))); } diff --git a/vcx/libvcx/src/utils/json.rs b/vcx/libvcx/src/utils/json.rs index 46c827df12..93bc584675 100644 --- a/vcx/libvcx/src/utils/json.rs +++ b/vcx/libvcx/src/utils/json.rs @@ -11,7 +11,7 @@ pub trait KeyMatch { } impl KeyMatch for String { - fn matches(&self, key: &String, context: &Vec) -> bool { + fn matches(&self, key: &String, _context: &Vec) -> bool { key.eq(self) } } diff --git a/vcx/libvcx/src/utils/libindy/anoncreds.rs b/vcx/libvcx/src/utils/libindy/anoncreds.rs index 0ecf9fbd41..eb822df7bc 100644 --- a/vcx/libvcx/src/utils/libindy/anoncreds.rs +++ b/vcx/libvcx/src/utils/libindy/anoncreds.rs @@ -150,7 +150,7 @@ pub fn libindy_prover_get_credentials_for_proof_req(proof_req: &str) -> VcxResul // this may be too redundant since Prover::search_credentials will validate the proof reqeuest already. let proof_request_json: Map = serde_json::from_str(proof_req) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidProofRequest, format!("Cannot deserialize ProofRequest")))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidProofRequest, format!("Cannot deserialize ProofRequest: {:?}", err)))?; // since the search_credentials_for_proof request validates that the proof_req is properly structured, this get() // fn should never fail, unless libindy changes their formats. @@ -356,7 +356,7 @@ pub fn create_schema(name: &str, version: &str, data: &str) -> VcxResult<(String Ok((id, create_schema)) } -pub fn build_schema_request(id: &str, schema: &str) -> VcxResult { +pub fn build_schema_request(schema: &str) -> VcxResult { if settings::test_indy_mode_enabled() { return Ok(SCHEMA_TXN.to_string()); } @@ -370,14 +370,14 @@ pub fn build_schema_request(id: &str, schema: &str) -> VcxResult { Ok(request) } -pub fn publish_schema(id: &str, schema: &str) -> VcxResult> { +pub fn publish_schema(schema: &str) -> VcxResult> { if settings::test_indy_mode_enabled() { let inputs = vec!["pay:null:9UFgyjuJxi1i1HD".to_string()]; let outputs = serde_json::from_str::>(r#"[{"amount":4,"extra":null,"recipient":"pay:null:xkIsxem0YNtHrRO"}]"#).unwrap(); return Ok(Some(PaymentTxn::from_parts(inputs, outputs, 1, false))); } - let request = build_schema_request(id, schema)?; + let request = build_schema_request(schema)?; let (payment, response) = pay_for_txn(&request, CREATE_SCHEMA_ACTION)?; @@ -548,7 +548,7 @@ fn _check_schema_response(response: &str) -> VcxResult<()> { match parse_response(response)? { Response::Reply(_) => Ok(()), Response::Reject(reject) => Err(VcxError::from_msg(VcxErrorKind::DuplicationSchema, format!("{:?}", reject))), - Response::ReqNACK(reqnack) => Err(VcxError::from_msg(VcxErrorKind::UnknownSchemaRejection, "Unknown Rejection of Schema Creation, refer to libindy documentation")) + Response::ReqNACK(reqnack) => Err(VcxError::from_msg(VcxErrorKind::UnknownSchemaRejection, format!("{:?}", reqnack))) } } @@ -592,7 +592,7 @@ pub mod tests { } pub fn write_schema(request: &str) { - let (payment_info, response) = ::utils::libindy::payments::pay_for_txn(&request, CREATE_SCHEMA_ACTION).unwrap(); + ::utils::libindy::payments::pay_for_txn(&request, CREATE_SCHEMA_ACTION).unwrap(); } pub fn create_and_write_test_schema(attr_list: &str) -> (String, String) { @@ -652,7 +652,7 @@ pub mod tests { let credential_data = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#; let encoded_attributes = ::issuer_credential::encode_attributes(&credential_data).unwrap(); let (rev_def_json, tails_file) = if revocation { - let (id, json) = get_rev_reg_def_json(&rev_reg_id.clone().unwrap()).unwrap(); + let (_id, json) = get_rev_reg_def_json(&rev_reg_id.clone().unwrap()).unwrap(); (Some(json), Some(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap().to_string().to_string())) } else { (None, None) }; @@ -664,7 +664,7 @@ pub mod tests { pub fn create_proof() -> (String, String, String, String) { let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json, cred_def_id, cred_def_json, offer, req, req_meta, cred_id, _, _) + let (schema_id, schema_json, cred_def_id, cred_def_json, _offer, _req, _req_meta, cred_id, _, _) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); let proof_req = json!({ @@ -721,8 +721,6 @@ pub mod tests { } pub fn create_self_attested_proof() -> (String, String) { - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", @@ -764,7 +762,7 @@ pub mod tests { pub fn create_proof_with_predicate(include_predicate_cred: bool) -> (String, String, String, String) { let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json, cred_def_id, cred_def_json, offer, req, req_meta, cred_id, _, _) + let (schema_id, schema_json, cred_def_id, cred_def_json, _offer, _req, _req_meta, cred_id, _, _) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); let proof_req = json!({ @@ -914,8 +912,6 @@ pub mod tests { }).to_string(); let result = libindy_prover_get_credentials_for_proof_req(&proof_req); let result_malformed_json = libindy_prover_get_credentials_for_proof_req("{}"); - let wallet_handle = get_wallet_handle(); - let proof_req_str: String = serde_json::to_string(&proof_req).unwrap(); assert!(result.is_ok()); assert_eq!(result_malformed_json.unwrap_err().kind(), VcxErrorKind::InvalidAttributesStructure); } @@ -927,7 +923,7 @@ pub mod tests { let rc = libindy_issuer_revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), "", ""); assert!(rc.is_err()); - let (_, _, cred_def_id, _, _, _, _, cred_id, rev_reg_id, cred_rev_id) + let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id) = create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let rc = ::utils::libindy::anoncreds::libindy_issuer_revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id.unwrap(), &cred_rev_id.unwrap()); @@ -946,16 +942,10 @@ pub mod tests { fn test_create_cred_def_real() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let (_, schema_json) = get_schema_json(&schema_id).unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let revocation_details = json!({ - "support_revocation": true, - "tails_file": get_temp_dir_path(Some("tails.txt")).to_str().unwrap(), - "max_creds": 2 - }).to_string(); let (_, cred_def_json) = generate_cred_def(&did, &schema_json, "tag_1", None, Some(true)).unwrap(); publish_cred_def(&did, &cred_def_json).unwrap(); } @@ -963,10 +953,8 @@ pub mod tests { #[cfg(feature = "pool_tests")] #[test] fn test_rev_reg_def_fails_for_cred_def_created_without_revocation() { - let wallet_name = "test_create_revocable_fails_with_no_tails_file"; init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); // 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, _, _, _) = ::utils::libindy::anoncreds::tests::create_and_store_credential_def(::utils::constants::DEFAULT_SCHEMA_ATTRS, false); @@ -981,7 +969,6 @@ pub mod tests { fn test_create_rev_reg_def() { init!("ledger"); - let data = r#"["address1","address2","zip","city","state"]"#.to_string(); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let (_, schema_json) = get_schema_json(&schema_id).unwrap(); let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); @@ -1002,7 +989,7 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); + let (id, _json) = get_rev_reg_def_json(&rev_reg_id).unwrap(); assert_eq!(id, rev_reg_id); } @@ -1015,7 +1002,7 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, delta, timestamp) = get_rev_reg_delta_json(&rev_reg_id, None, None).unwrap(); + let (id, _delta, _timestamp) = get_rev_reg_delta_json(&rev_reg_id, None, None).unwrap(); assert_eq!(id, rev_reg_id); } @@ -1028,21 +1015,19 @@ pub mod tests { ::utils::libindy::anoncreds::tests::create_and_store_credential_def(attrs, true); let rev_reg_id = rev_reg_id.unwrap(); - let (id, rev_reg, timestamp) = get_rev_reg(&rev_reg_id, time::get_time().sec as u64).unwrap(); + let (id, _rev_reg, _timestamp) = get_rev_reg(&rev_reg_id, time::get_time().sec as u64).unwrap(); assert_eq!(id, rev_reg_id); } #[cfg(feature = "pool_tests")] #[test] fn from_pool_ledger_with_id() { - use settings; init!("ledger"); - let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap(); - let (schema_id, schema_json) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); + let (schema_id, _schema_json) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let rc = get_schema_json(&schema_id); - let (id, retrieved_schema) = rc.unwrap(); + let (_id, retrieved_schema) = rc.unwrap(); assert!(retrieved_schema.contains(&schema_id)); } @@ -1058,7 +1043,7 @@ pub mod tests { #[test] fn test_revoke_credential() { init!("ledger"); - let (_, _, cred_def_id, _, _, _, _, cred_id, rev_reg_id, cred_rev_id) + let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id) = ::utils::libindy::anoncreds::tests::create_and_store_credential(::utils::constants::DEFAULT_SCHEMA_ATTRS, true); let rev_reg_id = rev_reg_id.unwrap(); @@ -1068,7 +1053,7 @@ pub mod tests { assert_eq!(first_rev_reg_delta, test_same_delta); assert_eq!(first_timestamp, test_same_timestamp); - let (payment, revoked_rev_reg_delta) = revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id, cred_rev_id.unwrap().as_str()).unwrap(); + let (payment, _revoked_rev_reg_delta) = revoke_credential(get_temp_dir_path(Some(TEST_TAILS_FILE)).to_str().unwrap(), &rev_reg_id, cred_rev_id.unwrap().as_str()).unwrap(); // Delta should change after revocation let (_, second_rev_reg_delta, _) = get_rev_reg_delta_json(&rev_reg_id, Some(first_timestamp + 1), None).unwrap(); diff --git a/vcx/libvcx/src/utils/libindy/cache.rs b/vcx/libvcx/src/utils/libindy/cache.rs index ac20cf219a..30c568c5da 100644 --- a/vcx/libvcx/src/utils/libindy/cache.rs +++ b/vcx/libvcx/src/utils/libindy/cache.rs @@ -98,7 +98,7 @@ pub mod tests { #[test] fn test_get_credential_cache_returns_default_when_not_exists_in_wallet() { - let init = Init::new(); + let _init = Init::new(); let result = get_rev_reg_cache("test-id"); assert_eq!(result, RevRegCache::default()); @@ -106,7 +106,7 @@ pub mod tests { #[test] fn test_get_credential_cache_returns_default_when_invalid_data_in_the_wallet() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -118,7 +118,7 @@ pub mod tests { #[test] fn test_credential_cache_set_than_get_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -138,7 +138,7 @@ pub mod tests { #[test] fn test_credential_cache_set_than_double_get_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; @@ -160,7 +160,7 @@ pub mod tests { #[test] fn test_credential_cache_overwrite_works() { - let init = Init::new(); + let _init = Init::new(); let rev_reg_id = "test-id"; diff --git a/vcx/libvcx/src/utils/libindy/callback.rs b/vcx/libvcx/src/utils/libindy/callback.rs index 05ca860343..be9b3b1d23 100644 --- a/vcx/libvcx/src/utils/libindy/callback.rs +++ b/vcx/libvcx/src/utils/libindy/callback.rs @@ -167,7 +167,7 @@ mod tests { let mutex_map: Mutex>> = Default::default(); assert!(get_cb(2123, &mutex_map).is_none()); - let closure: Box = Box::new(move |err | { + let closure: Box = Box::new(move |_ | { }); @@ -185,7 +185,7 @@ mod tests { // Should be come not needed as the transition is complete //************************************** -fn init_callback(closure: T, map: &Mutex>) -> (CommandHandle) { +fn init_callback(closure: T, map: &Mutex>) -> CommandHandle { let command_handle = next_command_handle(); { let mut callbacks = map.lock().unwrap(); diff --git a/vcx/libvcx/src/utils/libindy/callback_u32.rs b/vcx/libvcx/src/utils/libindy/callback_u32.rs index f2064b85a0..31eb104f66 100644 --- a/vcx/libvcx/src/utils/libindy/callback_u32.rs +++ b/vcx/libvcx/src/utils/libindy/callback_u32.rs @@ -126,7 +126,7 @@ mod tests { let mutex_map: Mutex>> = Default::default(); assert!(get_cb(2123, &mutex_map).is_none()); - let closure: Box = Box::new(move |err | { + let closure: Box = Box::new(move |_ | { }); diff --git a/vcx/libvcx/src/utils/libindy/mod.rs b/vcx/libvcx/src/utils/libindy/mod.rs index a968a14b6c..26d6bf48ae 100644 --- a/vcx/libvcx/src/utils/libindy/mod.rs +++ b/vcx/libvcx/src/utils/libindy/mod.rs @@ -48,7 +48,7 @@ pub fn init_pool() -> VcxResult<()> { warn!("Pool Config Creation Error: {}", e); Err(e) } - Ok(_) => { + Ok(()) => { debug!("Pool Config Created Successfully"); let pool_config: Option = settings::get_config_value(settings::CONFIG_POOL_CONFIG).ok(); pool::open_pool_ledger(&pool_name, pool_config.as_ref().map(String::as_str))?; @@ -63,7 +63,7 @@ pub mod tests { use futures::Future; use indy_sys::WalletHandle; - pub fn create_key(wallet_handle: WalletHandle, seed: Option<&str>) -> String { + pub fn create_key(_wallet_handle: WalletHandle, seed: Option<&str>) -> String { let key_config = json!({"seed": seed}).to_string(); indy::crypto::create_key(::utils::libindy::wallet::get_wallet_handle(), Some(&key_config)).wait().unwrap() } diff --git a/vcx/libvcx/src/utils/libindy/payments.rs b/vcx/libvcx/src/utils/libindy/payments.rs index cfce65a748..aa9a5601a4 100644 --- a/vcx/libvcx/src/utils/libindy/payments.rs +++ b/vcx/libvcx/src/utils/libindy/payments.rs @@ -13,7 +13,6 @@ use settings; use error::prelude::*; static DEFAULT_FEES: &str = r#"{"0":0, "1":0, "101":2, "10001":0, "102":42, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":2, "114":2, "115":0, "116":0, "117":0, "118":0, "119":0}"#; -static ZERO_FEES: &str = r#"{"0":0, "1":0, "101":0, "10001":0, "102":0, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":0, "114":0, "115":0, "116":0, "117":0, "118":0, "119":0}"#; #[derive(Serialize, Deserialize, Debug)] pub struct WalletInfo { @@ -58,7 +57,7 @@ impl fmt::Display for WalletInfo { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match ::serde_json::to_string(&self) { Ok(s) => write!(f, "{}", s), - Err(e) => write!(f, "null"), + Err(_) => write!(f, "null"), } } } @@ -267,7 +266,7 @@ pub fn pay_for_txn(req: &str, txn_action: (&str, &str, &str, Option<&str>, Optio let (refund, inputs, refund_address) = inputs(txn_price)?; let output = outputs(refund, &refund_address, None, None)?; - let (fee_response, txn_response) = _submit_fees_request(req, &inputs, &output)?; + let (_fee_response, txn_response) = _submit_fees_request(req, &inputs, &output)?; let payment = PaymentTxn::from_parts(inputs, output, txn_price, false); Ok((Some(payment), txn_response)) @@ -346,7 +345,7 @@ pub fn pay_a_payee(price: u64, address: &str) -> VcxResult<(PaymentTxn, String)> None => None }; - let (request, payment_method) = + let (request, _payment_method) = payments::build_payment_req(get_wallet_handle(), Some(&my_did), &inputs_json, &outputs_json, extra.as_ref().map(String::as_str)) .wait() .map_err(map_rust_indy_sdk_error)?; @@ -495,11 +494,11 @@ pub fn mint_tokens_and_set_fees(number_of_addresses: Option, tokens_per_add let tokens_per_address: u64 = tokens_per_address.unwrap_or(50_000_000_000); let mut addresses = Vec::new(); - for n in 0..number_of_addresses { + for _n in 0..number_of_addresses { addresses.push(create_address(seed.clone()).unwrap()) } - let mint: Vec = addresses.clone().into_iter().enumerate().map(|(i, payment_address)| + let mint: Vec = addresses.clone().into_iter().enumerate().map(|(_i, payment_address)| json!( { "recipient": payment_address, "amount": tokens_per_address } ) ).collect(); let outputs = serde_json::to_string(&mint).unwrap(); @@ -511,7 +510,7 @@ pub fn mint_tokens_and_set_fees(number_of_addresses: Option, tokens_per_add let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap(); match ::utils::libindy::ledger::libindy_submit_request(&sign4) { - Ok(x) => (), + Ok(_) => (), Err(x) => println!("failure minting tokens: {}", x), }; } @@ -557,12 +556,14 @@ pub fn add_new_did(role: Option<&str>) -> (String, String) { #[cfg(test)] pub mod tests { use super::*; + static ZERO_FEES: &str = r#"{"0":0, "1":0, "101":0, "10001":0, "102":0, "103":0, "104":0, "105":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":0, "114":0, "115":0, "116":0, "117":0, "118":0, "119":0}"#; pub fn token_setup(number_of_addresses: Option, tokens_per_address: Option, use_zero_fees: bool) { let fees = if use_zero_fees { ZERO_FEES } else { DEFAULT_FEES }; mint_tokens_and_set_fees(number_of_addresses, tokens_per_address, Some(fees.to_string()), None).unwrap(); } + #[allow(dead_code)] fn get_my_balance() -> u64 { let info: WalletInfo = get_wallet_token_info().unwrap(); info.balance @@ -593,7 +594,7 @@ pub mod tests { fn test_get_addresses() { init!("true"); create_address(None).unwrap(); - let addresses = list_addresses().unwrap(); + let _addresses = list_addresses().unwrap(); } #[test] @@ -752,7 +753,7 @@ pub mod tests { // Schema let create_schema_req = ::utils::constants::SCHEMA_CREATE_JSON.to_string(); - let (payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); + let (_payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); assert_eq!(response, SUBMIT_SCHEMA_RESPONSE.to_string()); } @@ -764,7 +765,7 @@ pub mod tests { let create_schema_req = ::utils::libindy::anoncreds::tests::create_schema_req(&schema_json); let start_wallet = get_wallet_token_info().unwrap(); - let (payment, response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); + let (payment, _response) = pay_for_txn(&create_schema_req, ::utils::constants::CREATE_SCHEMA_ACTION).unwrap(); let end_wallet = get_wallet_token_info().unwrap(); @@ -875,7 +876,7 @@ pub mod tests { let end_wallet = get_wallet_token_info().unwrap(); assert_eq!(start_wallet.balance - 2, end_wallet.balance); - let rc = _submit_fees_request(&req, &inputs, &output); + let _rc = _submit_fees_request(&req, &inputs, &output); } #[cfg(feature = "pool_tests")] @@ -892,9 +893,8 @@ pub mod tests { assert_eq!(remainder, remaining_balance); let output = outputs(remainder, &refund_address, None, None).unwrap(); - let expected_output: Vec = ::serde_json::from_str(&format!(r#"[{{"amount":{},"recipient":"{}"}}]"#, remaining_balance, refund_address)).unwrap(); - let rc = _submit_fees_request(&req, &inputs, &output).unwrap(); + let _rc = _submit_fees_request(&req, &inputs, &output).unwrap(); let end_wallet = get_wallet_token_info().unwrap(); assert_eq!(end_wallet.balance, remaining_balance); diff --git a/vcx/libvcx/src/utils/libindy/pool.rs b/vcx/libvcx/src/utils/libindy/pool.rs index 20d3506c94..5bdfcf5784 100644 --- a/vcx/libvcx/src/utils/libindy/pool.rs +++ b/vcx/libvcx/src/utils/libindy/pool.rs @@ -27,7 +27,7 @@ pub fn create_pool_ledger_config(pool_name: &str, path: &str) -> VcxResult<()> { match pool::create_pool_ledger_config(pool_name, Some(&pool_config)) .wait() { - Ok(x) => Ok(()), + Ok(()) => Ok(()), Err(x) => if x.error_code != ErrorCode::PoolLedgerConfigAlreadyExistsError { Err(VcxError::from_msg(VcxErrorKind::UnknownLiibndyError, x)) } else { @@ -88,7 +88,7 @@ pub mod tests { pub fn delete_test_pool() { match delete(POOL) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } diff --git a/vcx/libvcx/src/utils/libindy/wallet.rs b/vcx/libvcx/src/utils/libindy/wallet.rs index dda2fd7204..32c0b5a584 100644 --- a/vcx/libvcx/src/utils/libindy/wallet.rs +++ b/vcx/libvcx/src/utils/libindy/wallet.rs @@ -26,7 +26,7 @@ pub fn create_wallet(wallet_name: &str, wallet_type: Option<&str>, storage_confi match wallet::create_wallet(&config, &credentials) .wait() { - Ok(x) => Ok(()), + Ok(()) => Ok(()), Err(x) => if x.error_code != ErrorCode::WalletAlreadyExistsError { warn!("could not create wallet {}: {:?}", wallet_name, x.message); Err(VcxError::from_msg(VcxErrorKind::WalletCreate, format!("could not create wallet {}: {:?}", wallet_name, x.message))) @@ -154,9 +154,6 @@ pub fn import(config: &str) -> VcxResult<()> { settings::process_config_string(config, true)?; - let key = settings::get_config_value(settings::CONFIG_WALLET_KEY) - .or(Err(VcxError::from(VcxErrorKind::MissingWalletKey)))?; - let name = settings::get_config_value(settings::CONFIG_WALLET_NAME) .or(Err(VcxError::from(VcxErrorKind::MissingWalletName)))?; @@ -212,12 +209,12 @@ pub mod tests { pub fn delete_test_wallet(name: &str) { match close_wallet() { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; match delete_wallet(name, None, None, None) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), }; } @@ -273,7 +270,6 @@ pub mod tests { let xtype = "type1"; let id = "id1"; let value = "value1"; - let options = "{}"; ::api::vcx::vcx_shutdown(true); @@ -399,7 +395,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_add_new_record_with_no_tag"; add_record(record_type, id, record, None).unwrap(); } @@ -411,7 +406,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_add_duplicate_record_fails"; add_record(record_type, id, record, None).unwrap(); let rc = add_record(record_type, id, record, None); @@ -426,7 +420,6 @@ pub mod tests { let record_type = "Type"; let record_type2 = "Type2"; let id = "123"; - let wallet_n = "test_add_duplicate_record_fails"; add_record(record_type, id, record, None).unwrap(); add_record(record_type2, id, record, None).unwrap(); @@ -443,7 +436,6 @@ pub mod tests { "retrieveValue": false, "retrieveTags": false }).to_string(); - let wallet_n = "test_retrieve_missing_record_fails"; let rc = get_record(record_type, id, &options); assert_eq!(rc.unwrap_err().kind(), VcxErrorKind::WalletRecordNotFound); @@ -457,7 +449,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_retrieve_record_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -488,7 +479,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_delete_record_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, @@ -508,7 +498,6 @@ pub mod tests { let record = "Record Value"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_update_record_value_fails_with_no_initial_record"; let rc = update_record_value(record_type, id, record); assert_eq!(rc.unwrap_err().kind(), VcxErrorKind::WalletRecordNotFound); @@ -522,7 +511,6 @@ pub mod tests { let changed_record = "Record2"; let record_type = "Type"; let id = "123"; - let wallet_n = "test_update_record_value_success"; let options = json!({ "retrieveType": true, "retrieveValue": true, diff --git a/vcx/libvcx/src/utils/logger.rs b/vcx/libvcx/src/utils/logger.rs index 440f11df07..3ff503fc04 100644 --- a/vcx/libvcx/src/utils/logger.rs +++ b/vcx/libvcx/src/utils/logger.rs @@ -1,7 +1,5 @@ extern crate env_logger; extern crate log; -extern crate log4rs; -extern crate log_panics; extern crate libc; extern crate indy_sys; @@ -11,7 +9,6 @@ extern crate android_logger; use std::io::Write; use self::env_logger::Builder as EnvLoggerBuilder; use self::log::{Level, LevelFilter, Metadata, Record}; -use std::sync::Once; use self::libc::{c_char}; use std::env; use std::ptr; @@ -28,7 +25,6 @@ use error::prelude::*; use utils::libindy; pub static mut LOGGER_STATE: LoggerState = LoggerState::Default; -static LOGGER_INIT: Once = Once::new(); static mut CONTEXT: *const CVoid = ptr::null(); static mut ENABLED_CB: Option = None; static mut LOG_CB: Option = None; @@ -146,7 +142,7 @@ impl LibvcxDefaultLogger { // the user did not set the RUST_LOG env var. let pattern = Some(env::var("RUST_LOG").unwrap_or("trace".to_string())); match LibvcxDefaultLogger::init(pattern) { - Ok(_) => (), + Ok(()) => (), Err(_) => (), } } @@ -183,7 +179,7 @@ impl LibvcxDefaultLogger { .filter(None, LevelFilter::Off) .parse(pattern.as_ref().map(String::as_str).unwrap_or("warn")) .try_init() { - Ok(_) => {} + Ok(()) => {} Err(e) => { error!("Error in logging init: {:?}", e); return Err(VcxError::from_msg(VcxErrorKind::LoggingError, format!("Cannot init logger: {:?}", e))) @@ -257,21 +253,19 @@ mod tests { ptr::null() } - static mut CHANGED: Option = None; static mut COUNT: u32 = 0; - extern fn custom_enabled(context: *const CVoid, level: u32, target: *const c_char) -> bool { true } + extern fn custom_enabled(_context: *const CVoid, _level: u32, _target: *const c_char) -> bool { true } - extern fn custom_flush(context: *const CVoid) {} + extern fn custom_flush(_context: *const CVoid) {} - extern fn custom_log(context: *const CVoid, - level: u32, - target: *const c_char, - message: *const c_char, - module_path: *const c_char, - file: *const c_char, - line: u32) { - let message = CStringUtils::c_str_to_string(message).unwrap(); + extern fn custom_log(_context: *const CVoid, + _level: u32, + _target: *const c_char, + _message: *const c_char, + _module_path: *const c_char, + _file: *const c_char, + _line: u32) { unsafe { COUNT = COUNT + 1 } } @@ -280,7 +274,7 @@ mod tests { fn test_logging_get_logger() { LibvcxDefaultLogger::init(Some("debug".to_string())).unwrap(); unsafe { - let (context, enabled_cb, log_cb, flush_cb) = LOGGER_STATE.get(); + let (context, enabled_cb, _log_cb, _flush_cb) = LOGGER_STATE.get(); assert_eq!(context, ptr::null()); let target = CStringUtils::string_to_cstring("target".to_string()); let level = 1; diff --git a/vcx/libvcx/src/utils/threadpool.rs b/vcx/libvcx/src/utils/threadpool.rs index 03c3cc9aa2..d07959ae0c 100644 --- a/vcx/libvcx/src/utils/threadpool.rs +++ b/vcx/libvcx/src/utils/threadpool.rs @@ -55,7 +55,7 @@ where unsafe { handle = TP_HANDLE; } match THREADPOOL.lock().unwrap().get(&handle) { Some(x) => { - let n = x.spawn(future); + let _n= x.spawn(future); }, None => panic!("no threadpool!"), } diff --git a/vcx/libvcx/src/v3/handlers/connection/agent.rs b/vcx/libvcx/src/v3/handlers/connection/agent.rs index 96a7d2b6f7..c653569f7d 100644 --- a/vcx/libvcx/src/v3/handlers/connection/agent.rs +++ b/vcx/libvcx/src/v3/handlers/connection/agent.rs @@ -119,7 +119,7 @@ impl AgentInfo { pub fn decode_message(&self, message: &Message) -> VcxResult { trace!("Agent::decode_message >>>"); - EncryptionEnvelope::open(&self.pw_vk, message.payload()?) + EncryptionEnvelope::open(message.payload()?) } pub fn send_message(&self, message: &A2AMessage, did_dod: &DidDoc) -> VcxResult<()> { diff --git a/vcx/libvcx/src/v3/handlers/connection/mod.rs b/vcx/libvcx/src/v3/handlers/connection/mod.rs index bd0507004d..ce20949bc7 100644 --- a/vcx/libvcx/src/v3/handlers/connection/mod.rs +++ b/vcx/libvcx/src/v3/handlers/connection/mod.rs @@ -93,7 +93,7 @@ pub mod tests { } } - let res = ::messages::get_message::download_messages(None, None, Some(vec![uid.clone()])).unwrap(); + let _res = ::messages::get_message::download_messages(None, None, Some(vec![uid.clone()])).unwrap(); // Get Message by id works { diff --git a/vcx/libvcx/src/v3/handlers/connection/states.rs b/vcx/libvcx/src/v3/handlers/connection/states.rs index 14a0425356..158d6ba152 100644 --- a/vcx/libvcx/src/v3/handlers/connection/states.rs +++ b/vcx/libvcx/src/v3/handlers/connection/states.rs @@ -94,14 +94,14 @@ pub struct CompleteState { } impl From<(NullState, Invitation)> for InvitedState { - fn from((state, invitation): (NullState, Invitation)) -> InvitedState { + fn from((_state, invitation): (NullState, Invitation)) -> InvitedState { trace!("DidExchangeStateSM: transit state from NullState to InvitedState"); InvitedState { invitation } } } impl From<(InvitedState, ProblemReport)> for NullState { - fn from((state, error): (InvitedState, ProblemReport)) -> NullState { + fn from((_state, _error): (InvitedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from InvitedState to NullState"); NullState {} } @@ -115,42 +115,42 @@ impl From<(InvitedState, Request)> for RequestedState { } impl From<(InvitedState, Request, SignedResponse, AgentInfo)> for RespondedState { - fn from((state, request, response, prev_agent_info): (InvitedState, Request, SignedResponse, AgentInfo)) -> RespondedState { + fn from((_state, request, response, prev_agent_info): (InvitedState, Request, SignedResponse, AgentInfo)) -> RespondedState { trace!("DidExchangeStateSM: transit state from InvitedState to RequestedState"); RespondedState { response, did_doc: request.connection.did_doc, prev_agent_info } } } impl From<(RequestedState, ProblemReport)> for NullState { - fn from((state, error): (RequestedState, ProblemReport)) -> NullState { + fn from((_state, _error): (RequestedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from RequestedState to NullState"); NullState {} } } impl From<(RequestedState, Response)> for CompleteState { - fn from((state, response): (RequestedState, Response)) -> CompleteState { + fn from((_state, response): (RequestedState, Response)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RequestedState to RespondedState"); CompleteState { did_doc: response.connection.did_doc, pending_messages: HashMap::new(), protocols: None } } } impl From<(RespondedState, ProblemReport)> for NullState { - fn from((state, error): (RespondedState, ProblemReport)) -> NullState { + fn from((_state, _error): (RespondedState, ProblemReport)) -> NullState { trace!("DidExchangeStateSM: transit state from RespondedState to NullState"); NullState {} } } impl From<(RespondedState, Ack)> for CompleteState { - fn from((state, ack): (RespondedState, Ack)) -> CompleteState { + fn from((state, _ack): (RespondedState, Ack)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RespondedState to CompleteState"); CompleteState { did_doc: state.did_doc, pending_messages: HashMap::new(), protocols: None } } } impl From<(RespondedState, Ping)> for CompleteState { - fn from((state, ping): (RespondedState, Ping)) -> CompleteState { + fn from((state, _ping): (RespondedState, Ping)) -> CompleteState { trace!("DidExchangeStateSM: transit state from RespondedState to CompleteState"); CompleteState { did_doc: state.did_doc, pending_messages: HashMap::new(), protocols: None } } @@ -231,7 +231,7 @@ impl CompleteState { self.handle_ping(&ping, agent_info)?; DidExchangeState::Completed(self) } - DidExchangeMessages::PingResponseReceived(ping_response) => { + DidExchangeMessages::PingResponseReceived(_) => { DidExchangeState::Completed(self) } DidExchangeMessages::DiscoverFeatures((query_, comment)) => { @@ -345,7 +345,7 @@ impl DidExchangeSM { for (uid, message) in messages { match self.state { - ActorDidExchangeState::Inviter(DidExchangeState::Invited(ref state)) => { + ActorDidExchangeState::Inviter(DidExchangeState::Invited(_)) => { match message { request @ A2AMessage::ConnectionRequest(_) => { debug!("Inviter received ConnectionRequest message"); @@ -360,7 +360,7 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Invitee(DidExchangeState::Requested(ref state)) => { + ActorDidExchangeState::Invitee(DidExchangeState::Requested(_)) => { match message { response @ A2AMessage::ConnectionResponse(_) => { debug!("Invitee received ConnectionResponse message"); @@ -375,7 +375,7 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Inviter(DidExchangeState::Responded(ref state)) => { + ActorDidExchangeState::Inviter(DidExchangeState::Responded(_)) => { match message { ack @ A2AMessage::Ack(_) => { debug!("Ack message received"); @@ -394,8 +394,8 @@ impl DidExchangeSM { } } } - ActorDidExchangeState::Invitee(DidExchangeState::Completed(ref state)) | - ActorDidExchangeState::Inviter(DidExchangeState::Completed(ref state)) => { + ActorDidExchangeState::Invitee(DidExchangeState::Completed(_)) | + ActorDidExchangeState::Inviter(DidExchangeState::Completed(_)) => { match message { ping @ A2AMessage::Ping(_) => { debug!("Ping message received"); @@ -1236,8 +1236,6 @@ pub mod test { let mut did_exchange_sm = invitee_sm().to_invitee_requested_state(); - let invitation = Invitation::default().set_recipient_keys(vec![key.clone()]); - did_exchange_sm = did_exchange_sm.step(DidExchangeMessages::ExchangeResponseReceived(_response(&key))).unwrap(); assert_match!(ActorDidExchangeState::Invitee(DidExchangeState::Completed(_)), did_exchange_sm.state); diff --git a/vcx/libvcx/src/v3/handlers/issuance/holder.rs b/vcx/libvcx/src/v3/handlers/issuance/holder.rs index 513da34cbe..b5fd65dfd7 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/holder.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/holder.rs @@ -72,10 +72,10 @@ impl HolderSM { for (uid, message) in messages { match self.state { - HolderState::OfferReceived(ref state) => { + HolderState::OfferReceived(_) => { // do not process messages } - HolderState::RequestSent(ref state) => { + HolderState::RequestSent(_) => { match message { A2AMessage::Credential(credential) => { if credential.from_thread(&self.thread_id) { @@ -90,7 +90,7 @@ impl HolderSM { _ => {} } } - HolderState::Finished(ref state) => { + HolderState::Finished(_) => { // do not process messages } }; @@ -251,7 +251,7 @@ fn _make_credential_request(conn_handle: u32, offer: &CredentialOffer) -> VcxRes let my_did = connection::get_pw_did(conn_handle)?; let cred_offer = offer.offers_attach.content()?; let cred_def_id = _parse_cred_def_from_cred_offer(&cred_offer)?; - let (req, req_meta, cred_def_id, cred_def_json) = + let (req, req_meta, _cred_def_id, cred_def_json) = credential::Credential::create_credential_request(&cred_def_id, &my_did, &cred_offer)?; Ok((CredentialRequest::create().set_requests_attach(req)?, req_meta, cred_def_json)) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/issuer.rs b/vcx/libvcx/src/v3/handlers/issuance/issuer.rs index d3f4f36e2a..51a2f53930 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/issuer.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/issuer.rs @@ -66,10 +66,10 @@ impl IssuerSM { for (uid, message) in messages { match self.state { - IssuerState::Initial(ref state) => { + IssuerState::Initial(_) => { // do not process messages } - IssuerState::OfferSent(ref state) => { + IssuerState::OfferSent(_) => { match message { A2AMessage::CredentialRequest(credential) => { if credential.from_thread(&self.state.thread_id()) { @@ -91,10 +91,10 @@ impl IssuerSM { _ => {} } } - IssuerState::RequestReceived(ref state) => { + IssuerState::RequestReceived(_) => { // do not process messages } - IssuerState::CredentialSent(ref state) => { + IssuerState::CredentialSent(_) => { match message { A2AMessage::Ack(ack) | A2AMessage::CredentialAck(ack) => { if ack.from_thread(&self.state.thread_id()) { @@ -109,7 +109,7 @@ impl IssuerSM { _ => {} } } - IssuerState::Finished(ref state) => { + IssuerState::Finished(_) => { // do not process messages } }; @@ -156,7 +156,7 @@ impl IssuerSM { CredentialIssuanceMessage::CredentialRequest(request) => { IssuerState::RequestReceived((state_data, request).into()) } - CredentialIssuanceMessage::CredentialProposal(proposal) => { + CredentialIssuanceMessage::CredentialProposal(_) => { let problem_report = ProblemReport::create() .set_comment(String::from("CredentialProposal is not supported")) .set_thread_id(&state_data.thread_id); @@ -266,11 +266,11 @@ fn _create_credential(request: &CredentialRequest, rev_reg_id: &Option, let cred_data = encode_attributes(cred_data)?; - let (credential, cred_id, revoc_reg_delta) = anoncreds::libindy_issuer_create_credential(offer, - &request, - &cred_data, - rev_reg_id.clone(), - tails_file.clone())?; + let (credential, _, _) = anoncreds::libindy_issuer_create_credential(offer, + &request, + &cred_data, + rev_reg_id.clone(), + tails_file.clone())?; Credential::create() .set_credential(credential) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/mod.rs b/vcx/libvcx/src/v3/handlers/issuance/mod.rs index ff482d7c26..7dddf4bb92 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/mod.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/mod.rs @@ -36,7 +36,7 @@ impl Issuer { self.step(CredentialIssuanceMessage::CredentialInit(connection_handle)) } - pub fn send_credential(&mut self, connection_handle: u32) -> VcxResult<()> { + pub fn send_credential(&mut self, _connection_handle: u32) -> VcxResult<()> { // TODO: should use connection_handle self.step(CredentialIssuanceMessage::CredentialSend()) } diff --git a/vcx/libvcx/src/v3/handlers/issuance/states.rs b/vcx/libvcx/src/v3/handlers/issuance/states.rs index 38e8a889ed..9a2e6bdb78 100644 --- a/vcx/libvcx/src/v3/handlers/issuance/states.rs +++ b/vcx/libvcx/src/v3/handlers/issuance/states.rs @@ -23,17 +23,17 @@ pub enum IssuerState { impl IssuerState { pub fn get_connection_handle(&self) -> u32 { match self { - IssuerState::Initial(state) => 0, + IssuerState::Initial(_) => 0, IssuerState::OfferSent(state) => state.connection_handle, IssuerState::RequestReceived(state) => state.connection_handle, IssuerState::CredentialSent(state) => state.connection_handle, - IssuerState::Finished(state) => 0 + IssuerState::Finished(_) => 0 } } pub fn thread_id(&self) -> String { match self { - IssuerState::Initial(state) => String::new(), + IssuerState::Initial(_) => String::new(), IssuerState::OfferSent(state) => state.thread_id.clone(), IssuerState::RequestReceived(state) => state.thread_id.clone(), IssuerState::CredentialSent(state) => state.thread_id.clone(), @@ -110,7 +110,7 @@ impl From<(InitialState, String, u32, MessageId)> for OfferSentState { } impl From for FinishedState { - fn from(state: InitialState) -> Self { + fn from(_state: InitialState) -> Self { trace!("SM is now in Finished state"); FinishedState { cred_id: None, @@ -136,7 +136,7 @@ impl From<(OfferSentState, CredentialRequest)> for RequestReceivedState { } impl From<(RequestReceivedState, MessageId)> for CredentialSentState { - fn from((state, sent_id): (RequestReceivedState, MessageId)) -> Self { + fn from((state, _sent_id): (RequestReceivedState, MessageId)) -> Self { trace!("SM is now in CredentialSent state"); CredentialSentState { connection_handle: state.connection_handle, @@ -210,9 +210,9 @@ pub enum HolderState { impl HolderState { pub fn get_connection_handle(&self) -> u32 { match self { - HolderState::OfferReceived(state) => 0, + HolderState::OfferReceived(_) => 0, HolderState::RequestSent(state) => state.connection_handle, - HolderState::Finished(state) => 0 + HolderState::Finished(_) => 0 } } } @@ -246,7 +246,7 @@ pub struct FinishedHolderState { } impl From<(OfferReceivedState, String, String, u32)> for RequestSentState { - fn from((state, req_meta, cred_def_json, connection_handle): (OfferReceivedState, String, String, u32)) -> Self { + fn from((_state, req_meta, cred_def_json, connection_handle): (OfferReceivedState, String, String, u32)) -> Self { trace!("SM is now in RequestSent state"); RequestSentState { req_meta, diff --git a/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs b/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs index 6ddf118607..7fb47f35c5 100644 --- a/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs +++ b/vcx/libvcx/src/v3/handlers/proof_presentation/prover/states.rs @@ -143,7 +143,7 @@ impl From<(PresentationPreparationFailedState, u32)> for FinishedState { } impl From<(PresentationSentState, PresentationAck)> for FinishedState { - fn from((state, ack): (PresentationSentState, PresentationAck)) -> Self { + fn from((state, _ack): (PresentationSentState, PresentationAck)) -> Self { trace!("transit state from PresentationSentState to FinishedState"); FinishedState { connection_handle: state.connection_handle, @@ -180,7 +180,7 @@ impl ProverSM { for (uid, message) in messages { match self.state { - ProverState::Initiated(ref state) => { + ProverState::Initiated(_) => { match message { A2AMessage::PresentationRequest(_) => { // ignore it here?? @@ -194,7 +194,7 @@ impl ProverSM { ProverState::PresentationPreparationFailed(_) => { // do not process messages } - ProverState::PresentationSent(ref state) => { + ProverState::PresentationSent(_) => { match message { A2AMessage::Ack(ack) | A2AMessage::PresentationAck(ack) => { if ack.from_thread(&self.thread_id) { @@ -209,7 +209,7 @@ impl ProverSM { _ => {} } } - ProverState::Finished(ref state) => { + ProverState::Finished(_) => { // do not process messages } }; @@ -412,9 +412,9 @@ impl ProverSM { pub fn presentation(&self) -> VcxResult<&Presentation> { match self.state { - ProverState::Initiated(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), + ProverState::Initiated(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), ProverState::PresentationPrepared(ref state) => Ok(&state.presentation), - ProverState::PresentationPreparationFailed(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), + ProverState::PresentationPreparationFailed(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not created yet")), ProverState::PresentationSent(ref state) => Ok(&state.presentation), ProverState::Finished(ref state) => Ok(&state.presentation), } diff --git a/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs b/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs index 2567b8b7a2..f395f5e534 100644 --- a/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs +++ b/vcx/libvcx/src/v3/handlers/proof_presentation/verifier/states.rs @@ -57,7 +57,7 @@ pub struct FinishedState { } impl From<(InitialState, PresentationRequest, u32)> for PresentationRequestSentState { - fn from((state, presentation_request, connection_handle): (InitialState, PresentationRequest, u32)) -> Self { + fn from((_state, presentation_request, connection_handle): (InitialState, PresentationRequest, u32)) -> Self { trace!("transit state from InitialState to PresentationRequestSentState"); PresentationRequestSentState { connection_handle, presentation_request } } @@ -111,10 +111,10 @@ impl VerifierSM { for (uid, message) in messages { match self.state { - VerifierState::Initiated(ref state) => { + VerifierState::Initiated(_) => { // do not process message } - VerifierState::PresentationRequestSent(ref state) => { + VerifierState::PresentationRequestSent(_) => { match message { A2AMessage::Presentation(presentation) => { if presentation.from_thread(&self.thread_id()) { @@ -134,7 +134,7 @@ impl VerifierSM { _ => {} } } - VerifierState::Finished(ref state) => { + VerifierState::Finished(_) => { // do not process message } }; @@ -196,7 +196,7 @@ impl VerifierSM { VerifierMessages::PresentationRejectReceived(problem_report) => { VerifierState::Finished((state, problem_report).into()) } - VerifierMessages::PresentationProposalReceived(presentation_proposal) => { // TODO: handle Presentation Proposal + VerifierMessages::PresentationProposalReceived(_) => { // TODO: handle Presentation Proposal let problem_report = ProblemReport::create() .set_comment(String::from("PresentationProposal is not supported")) @@ -259,8 +259,8 @@ impl VerifierSM { pub fn presentation_request_data(&self) -> VcxResult<&PresentationRequestData> { match self.state { VerifierState::Initiated(ref state) => Ok(&state.presentation_request_data), - VerifierState::PresentationRequestSent(ref state) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), - VerifierState::Finished(ref state) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), + VerifierState::PresentationRequestSent(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), + VerifierState::Finished(_) => Err(VcxError::from(VcxErrorKind::InvalidProofHandle)), } } @@ -276,8 +276,8 @@ impl VerifierSM { pub fn presentation(&self) -> VcxResult { match self.state { - VerifierState::Initiated(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), - VerifierState::PresentationRequestSent(ref state) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), + VerifierState::Initiated(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), + VerifierState::PresentationRequestSent(_) => Err(VcxError::from_msg(VcxErrorKind::NotReady, "Presentation is not received yet")), VerifierState::Finished(ref state) => { state.presentation.clone() .ok_or(VcxError::from(VcxErrorKind::InvalidProofHandle)) diff --git a/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs b/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs index 1fdcd93c9f..5ba96ad5ff 100644 --- a/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs +++ b/vcx/libvcx/src/v3/messages/a2a/protocol_registry.rs @@ -39,7 +39,7 @@ impl ProtocolRegistry { self.protocols.push(ProtocolDescriptor { pid: family.id(), roles: None }) } Some((actor_1, actor_2)) => { - match (actors.contains(&actor_1), actors.contains(&actor_1)) { + match (actors.contains(&actor_1), actors.contains(&actor_2)) { (true, true) => { self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: None } }) } @@ -47,7 +47,7 @@ impl ProtocolRegistry { self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_1]) } }) } (false, true) => { - self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_1]) } }) + self.protocols.push({ ProtocolDescriptor { pid: family.id(), roles: Some(vec![actor_2]) } }) } (false, false) => {} } @@ -151,11 +151,13 @@ pub mod tests { let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: None }, ]; + assert_eq!(expected_protocols, protocols); let protocols = registry.get_protocols_for_query(Some("did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0")); let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: None }, ]; + assert_eq!(expected_protocols, protocols); } #[test] @@ -169,5 +171,8 @@ pub mod tests { let expected_protocols = vec![ ProtocolDescriptor { pid: MessageFamilies::Connections.id(), roles: Some(vec![Actors::Invitee]) }, ]; + assert_eq!(expected_protocols, protocols); + + ::settings::clear_config(); } } \ No newline at end of file diff --git a/vcx/libvcx/src/v3/messages/connection/did_doc.rs b/vcx/libvcx/src/v3/messages/connection/did_doc.rs index 6da2484162..23237df315 100644 --- a/vcx/libvcx/src/v3/messages/connection/did_doc.rs +++ b/vcx/libvcx/src/v3/messages/connection/did_doc.rs @@ -2,6 +2,7 @@ use v3::messages::connection::invite::Invitation; use error::prelude::*; use url::Url; +use messages::validation::validate_verkey; pub const CONTEXT: &str = "https://w3id.org/did/v1"; pub const KEY_TYPE: &str = "Ed25519VerificationKey2018"; @@ -13,6 +14,7 @@ pub const SERVICE_TYPE: &str = "IndyAgent"; pub struct DidDoc { #[serde(rename = "@context")] pub context: String, + #[serde(default)] pub id: String, #[serde(default)] #[serde(rename = "publicKey")] @@ -104,7 +106,7 @@ impl DidDoc { self.authentication.push( Authentication { type_: String::from(KEY_AUTHENTICATION_TYPE), - public_key: key_reference.clone() + public_key: key_reference.clone(), }); @@ -118,6 +120,7 @@ impl DidDoc { routing_keys .iter() .for_each(|key| { + // Note: comment lines 123 - 134 and append key instead key_reference to be compatible with Streetcred id += 1; let key_id = id.to_string(); @@ -141,38 +144,45 @@ impl DidDoc { pub fn validate(&self) -> VcxResult<()> { if self.context != CONTEXT { - return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported @context value: {:?}", self.context))) + return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported @context value: {:?}", self.context))); } if self.id.is_empty() { - return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, "DIDDoc validation failed: id is empty")) + return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, "DIDDoc validation failed: id is empty")); } - + for service in self.service.iter() { Url::parse(&service.service_endpoint) - .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported endpoint: {:?}", service.service_endpoint)))?; + .map_err(|err| VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Invalid endpoint \"{:?}\", err: {:?}", service.service_endpoint, err)))?; service.recipient_keys .iter() - .map(|key| { - self.validate_public_key(key) - .and_then(|public_key| - self.validate_authentication(&public_key.id) - ) - }) + .map(|key| self.validate_recipient_key(key)) .collect::>()?; service.routing_keys .iter() - .map(|key| { - self.validate_public_key(key).map(|_| ()) - }) + .map(|key| self.validate_routing_key(key)) .collect::>()?; } Ok(()) } + fn validate_recipient_key(&self, key: &str) -> VcxResult<()> { + let public_key = self.validate_public_key(key)?; + self.validate_authentication(&public_key.id) + } + + fn validate_routing_key(&self, key: &str) -> VcxResult<()> { + if DidDoc::_key_parts(key).len() == 2 { + self.validate_public_key(key)?; + } else { + validate_verkey(key)?; + } + Ok(()) + } + fn validate_public_key(&self, target_key: &str) -> VcxResult<&Ed25519PublicKey> { let id = DidDoc::_parse_key_reference(target_key); @@ -183,12 +193,14 @@ impl DidDoc { return Err(VcxError::from_msg(VcxErrorKind::InvalidJson, format!("DIDDoc validation failed: Unsupported PublicKey type: {:?}", key.type_))); } + validate_verkey(&key.public_key_base_58)?; + Ok(key) } fn validate_authentication(&self, target_key: &str) -> VcxResult<()> { - if self.authentication.is_empty(){ - return Ok(()) + if self.authentication.is_empty() { + return Ok(()); } let key = self.authentication.iter().find(|key_| @@ -246,15 +258,19 @@ impl DidDoc { self.public_key.iter().find(|key_| key_.id == id.to_string() || key_.public_key_base_58 == id.to_string()) .map(|key| key.public_key_base_58.clone()) - .unwrap_or_default() + .unwrap_or(id) } fn _build_key_reference(did: &str, id: &str) -> String { format!("{}#{}", did, id) } + fn _key_parts(key: &str) -> Vec<&str> { + key.split("#").collect() + } + fn _parse_key_reference(key_reference: &str) -> String { - let pars: Vec<&str> = key_reference.split("#").collect(); + let pars: Vec<&str> = DidDoc::_key_parts(key_reference); pars.get(1).or(pars.get(0)).map(|s| s.to_string()).unwrap_or_default() } } @@ -427,6 +443,25 @@ pub mod tests { } } + pub fn _did_doc_5() -> DidDoc { + DidDoc { + context: String::from(CONTEXT), + id: _id(), + public_key: vec![ + Ed25519PublicKey { id: _key_reference_1(), type_: KEY_TYPE.to_string(), controller: _id(), public_key_base_58: _key_1() }, + ], + authentication: vec![ + Authentication { type_: KEY_AUTHENTICATION_TYPE.to_string(), public_key: _key_reference_1() } + ], + service: vec![Service { + service_endpoint: _service_endpoint(), + recipient_keys: vec![_key_1()], + routing_keys: vec![_key_2(), _key_3()], + ..Default::default() + }], + } + } + #[test] fn test_did_doc_build_works() { let mut did_doc: DidDoc = DidDoc::default(); @@ -443,6 +478,7 @@ pub mod tests { _did_doc_2().validate().unwrap(); _did_doc_3().validate().unwrap(); _did_doc_4().validate().unwrap(); + _did_doc_5().validate().unwrap(); } #[test] @@ -455,6 +491,10 @@ pub mod tests { let (recipient_keys, routing_keys) = _did_doc().resolve_keys(); assert_eq!(_recipient_keys(), recipient_keys); assert_eq!(_routing_keys(), routing_keys); + + let (recipient_keys, routing_keys) = _did_doc_2().resolve_keys(); + assert_eq!(_recipient_keys(), recipient_keys); + assert_eq!(_routing_keys(), routing_keys); } #[test] diff --git a/vcx/libvcx/src/v3/mod.rs b/vcx/libvcx/src/v3/mod.rs index 3d15b523dc..fbd6238a7c 100644 --- a/vcx/libvcx/src/v3/mod.rs +++ b/vcx/libvcx/src/v3/mod.rs @@ -233,7 +233,6 @@ pub mod test { } pub fn create_presentation_request(&self) -> u32 { - let did = String::from("V4SGRU86Z58d6TV7PBUe6f"); let requested_attrs = json!([ {"name": "name"}, {"name": "date"}, diff --git a/vcx/libvcx/src/v3/utils/encryption_envelope.rs b/vcx/libvcx/src/v3/utils/encryption_envelope.rs index be4edc826c..fc04db982d 100644 --- a/vcx/libvcx/src/v3/utils/encryption_envelope.rs +++ b/vcx/libvcx/src/v3/utils/encryption_envelope.rs @@ -61,7 +61,7 @@ impl EncryptionEnvelope { crypto::pack_message(None, &receiver_keys, message.as_bytes()) } - pub fn open(my_vk: &str, payload: Vec) -> VcxResult { + pub fn open(payload: Vec) -> VcxResult { let unpacked_msg = crypto::unpack_message(&payload)?; let message: ::serde_json::Value = ::serde_json::from_slice(unpacked_msg.as_slice()) @@ -110,7 +110,7 @@ pub mod tests { let message = A2AMessage::Ack(_ack()); let envelope = EncryptionEnvelope::create(&message, Some(&setup.key), &_did_doc_4()).unwrap(); - assert_eq!(message, EncryptionEnvelope::open(&_key_1(), envelope.0).unwrap()); + assert_eq!(message, EncryptionEnvelope::open(envelope.0).unwrap()); } #[test] @@ -128,7 +128,7 @@ pub mod tests { let envelope = EncryptionEnvelope::create(&ack, Some(&setup.key), &did_doc).unwrap(); - let message_1 = EncryptionEnvelope::open(&key_1, envelope.0).unwrap(); + let message_1 = EncryptionEnvelope::open(envelope.0).unwrap(); let message_1 = match message_1 { A2AMessage::Forward(forward) => { @@ -138,7 +138,7 @@ pub mod tests { _ => return assert!(false) }; - let message_2 = EncryptionEnvelope::open(&key_2, message_1).unwrap(); + let message_2 = EncryptionEnvelope::open(message_1).unwrap(); let message_2 = match message_2 { A2AMessage::Forward(forward) => { @@ -148,6 +148,6 @@ pub mod tests { _ => return assert!(false) }; - assert_eq!(ack, EncryptionEnvelope::open(&_key_1(), message_2).unwrap()); + assert_eq!(ack, EncryptionEnvelope::open(message_2).unwrap()); } } \ No newline at end of file diff --git a/vcx/libvcx/tests/utils/demo.rs b/vcx/libvcx/tests/utils/demo.rs index f490256293..096dda8168 100644 --- a/vcx/libvcx/tests/utils/demo.rs +++ b/vcx/libvcx/tests/utils/demo.rs @@ -1,5 +1,4 @@ extern crate vcx; -extern crate tempfile; extern crate libc; extern crate serde_json; diff --git a/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m b/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m index 524d92207f..1aa8a4e189 100644 --- a/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m +++ b/wrappers/ios/libindy-pod/Indy-demoTests/Test Utils/WalletUtils.m @@ -129,7 +129,7 @@ - (NSError *)closeWalletWithHandle:(IndyHandle)walletHandle { [completionExpectation fulfill]; }]; - [self waitForExpectations:@[completionExpectation] timeout:[TestUtils shortTimeout]]; + [self waitForExpectations:@[completionExpectation] timeout:[TestUtils defaultTimeout]]; return err; } diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h index 233d53267e..de21a0b7d5 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndyAnoncreds.h @@ -1074,12 +1074,19 @@ And is documented in this HIPE: completion:(void (^)(NSError *error, BOOL valid))completion; /** - Create revocation state for a credential in the particular time moment. + Create revocation state for a credential that corresponds to a particular time. + + Note that revocation delta must cover the whole registry existence time. + You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + + The resulting revocation state and provided timestamp can be saved and reused later with applying a new + revocation delta with `updateRevocationState` function. + This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. @param credRevID: user credential revocation id in revocation registry @param timestamp: time represented as a total number of seconds from Unix Epoch @param revRegDefJSON: revocation registry definition json - @param revRegDeltaJSON: revocation registry definition delta json + @param revRegDeltaJSON: revocation registry definition delta which covers the whole registry existence time @param blobStorageReaderHandle: configuration of blob storage reader handle that will allow to read revocation tails @param completion Callback that takes command result as parameter. Returns result revocation state json: @@ -1098,13 +1105,19 @@ And is documented in this HIPE: completion:(void (^)(NSError *error, NSString *revStateJSON))completion; /** - Create new revocation state for a credential based on existed state at the particular time moment (to reduce calculation time). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. @param revStateJSON: revocation registry state json @param credRevID: user credential revocation id in revocation registry @param timestamp: time represented as a total number of seconds from Unix Epoch @param revRegDefJSON: revocation registry definition json - @param revRegDeltaJSON: revocation registry definition delta json + @param revRegDeltaJSON: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp @param blobStorageReaderHandle: configuration of blob storage reader handle that will allow to read revocation tails @param completion Callback that takes command result as parameter. Returns result revocation state json: diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java index 212af894f2..7062de04eb 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/anoncreds/Anoncreds.java @@ -1444,11 +1444,18 @@ public static CompletableFuture verifierVerifyProof( } /** - * Create revocation state for credential in the particular time moment. + * Create revocation state for a credential that corresponds to a particular time. + * + * Note that revocation delta must cover the whole registry existence time. + * You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + * + * The resulting revocation state and provided timestamp can be saved and reused later with applying a new + * revocation delta with `updateRevocationState` function. + * This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. * * @param blobStorageReaderHandle Configuration of blob storage reader handle that will allow to read revocation tails * @param revRegDef Revocation registry definition json - * @param revRegDelta Revocation registry definition delta json + * @param revRegDelta Revocation registry delta which covers the whole registry existence time * @param timestamp Time represented as a total number of seconds from Unix Epoch * @param credRevId user credential revocation id in revocation registry * @return A future that resolves to a revocation state json: @@ -1488,13 +1495,18 @@ public static CompletableFuture createRevocationState( } /** - * Create new revocation state for a credential based on already state - * at the particular time moment (to reduce calculation time). + * Create a new revocation state for a credential based on a revocation state created before. + * Note that provided revocation delta must cover the registry gap from based state creation until the specified time + * (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + * + * This function reduces the calculation time. + * + * The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. * * @param blobStorageReaderHandle Configuration of blob storage reader handle that will allow to read revocation tails * @param revState Rrevocation registry state json * @param revRegDef Revocation registry definition json - * @param revRegDelta Revocation registry definition delta json + * @param revRegDelta Revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp * @param timestamp Time represented as a total number of seconds from Unix Epoch * @param credRevId user credential revocation id in revocation registry * @return A future that resolves to a revocation state json: diff --git a/wrappers/nodejs/README.md b/wrappers/nodejs/README.md index de96d9cbfd..367bafcfff 100644 --- a/wrappers/nodejs/README.md +++ b/wrappers/nodejs/README.md @@ -986,11 +986,18 @@ Errors: `Annoncreds*`, `Common*`, `Wallet*` #### createRevocationState \( blobStorageReaderHandle, revRegDef, revRegDelta, timestamp, credRevId \) -> revState -Create revocation state for a credential in the particular time moment. +Create revocation state for a credential that corresponds to a particular time. + +Note that revocation delta must cover the whole registry existence time. +You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + +The resulting revocation state and provided timestamp can be saved and reused later with applying a new +revocation delta with `updateRevocationState` function. +This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. * `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails * `revRegDef`: Json - revocation registry definition json -* `revRegDelta`: Json - revocation registry definition delta json +* `revRegDelta`: Json - revocation registry delta which covers the whole registry existence time * `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch * `credRevId`: String - user credential revocation id in revocation registry * __->__ `revState`: Json - revocation state json: @@ -1006,13 +1013,18 @@ Errors: `Common*`, `Wallet*`, `Anoncreds*` #### updateRevocationState \( blobStorageReaderHandle, revState, revRegDef, revRegDelta, timestamp, credRevId \) -> updatedRevState -Create new revocation state for a credential based on existed state -at the particular time moment \(to reduce calculation time\). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. * `blobStorageReaderHandle`: Handle (Number) - configuration of blob storage reader handle that will allow to read revocation tails * `revState`: Json - revocation registry state json * `revRegDef`: Json - revocation registry definition json -* `revRegDelta`: Json - revocation registry definition delta json +* `revRegDelta`: Json - revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp * `timestamp`: Timestamp (Number) - time represented as a total number of seconds from Unix Epoch * `credRevId`: String - user credential revocation id in revocation registry * __->__ `updatedRevState`: Json - revocation state json: diff --git a/wrappers/python/indy/anoncreds.py b/wrappers/python/indy/anoncreds.py index c4f317eb88..901a978c94 100644 --- a/wrappers/python/indy/anoncreds.py +++ b/wrappers/python/indy/anoncreds.py @@ -1765,11 +1765,18 @@ async def create_revocation_state(blob_storage_reader_handle: int, timestamp: int, cred_rev_id: str) -> str: """ - Create revocation state for a credential in the particular time moment. + Create revocation state for a credential that corresponds to a particular time. + + Note that revocation delta must cover the whole registry existence time. + You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. + + The resulting revocation state and provided timestamp can be saved and reused later with applying a new + revocation delta with `update_revocation_state` function. + This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. :param blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails :param rev_reg_def_json: revocation registry definition json - :param rev_reg_delta_json: revocation registry definition delta json + :param rev_reg_delta_json: revocation registry definition delta which covers the whole registry existence time :param timestamp: time represented as a total number of seconds from Unix Epoch :param cred_rev_id: user credential revocation id in revocation registry :return: revocation state json { @@ -1818,13 +1825,18 @@ async def update_revocation_state(blob_storage_reader_handle: int, timestamp: int, cred_rev_id: str) -> str: """ - Create new revocation state for a credential based on existed state - at the particular time moment (to reduce calculation time). + Create a new revocation state for a credential based on a revocation state created before. + Note that provided revocation delta must cover the registry gap from based state creation until the specified time + (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). + + This function reduces the calculation time. + + The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. :param blob_storage_reader_handle: configuration of blob storage reader handle that will allow to read revocation tails :param rev_state_json: revocation registry state json :param rev_reg_def_json: revocation registry definition json - :param rev_reg_delta_json: revocation registry definition delta json + :param rev_reg_delta_json: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp :param timestamp: time represented as a total number of seconds from Unix Epoch :param cred_rev_id: user credential revocation id in revocation registry :return: revocation state json { diff --git a/wrappers/python/tests/interation/test_interaction_several_credentials.py b/wrappers/python/tests/interation/test_interaction_several_credentials.py new file mode 100644 index 0000000000..fa6954d758 --- /dev/null +++ b/wrappers/python/tests/interation/test_interaction_several_credentials.py @@ -0,0 +1,652 @@ +import json + +import pytest +import time + +from enum import IntEnum +from pprint import pformat + +from indy import ledger, anoncreds, wallet, blob_storage + +from tests.ledger.test_submit_request import ensure_previous_request_applied + +import logging + + +# logging.getLogger("tests").setLevel(logging.ERROR) +# logging.getLogger("indy").setLevel(logging.ERROR) + + +def ppjson(dumpit, elide_to: int = None) -> str: + if elide_to is not None: + elide_to = max(elide_to, 3) # make room for ellipses '...' + try: + rv = json.dumps(json.loads(dumpit) if isinstance(dumpit, str) else dumpit, indent=4) + except TypeError: + rv = '{}'.format(pformat(dumpit, indent=4, width=120)) + return rv if elide_to is None or len(rv) <= elide_to else '{}...'.format(rv[0:(elide_to - 3)]) + + +class Ink(IntEnum): + BLACK = 30 + RED = 31 + GREEN = 32 + YELLOW = 33 + BLUE = 34 + MAGENTA = 35 + CYAN = 36 + WHITE = 37 + + + def __call__(self, message: str) -> str: + return '\033[{}m{}\033[0m'.format(self.value, message) + + +@pytest.mark.asyncio +async def test_anoncreds_revocation_interaction_test_issuance_by_demand_4_creds(pool_name, pool_handle, wallet_handle, + identity_my, identity_my1, path_home, + did_my2, credentials): + issuer_did, _ = identity_my + issuer_wallet_handle = wallet_handle + + prover_did, _ = identity_my1 + + # Prover Creates Wallet and Get Wallet Handle + prover_wallet_config = '{"id":"prover_wallet"}' + await wallet.create_wallet(prover_wallet_config, credentials) + prover_wallet_handle = await wallet.open_wallet(prover_wallet_config, credentials) + + # Issuer Creates Schema + (schema_id, schema_json) = await anoncreds.issuer_create_schema( + issuer_did, + "gvt", + "1.0", + json.dumps(["name", "age", "sex", "height"]) + ) + + # Issuer Posts Schema + schema_request = await ledger.build_schema_request(issuer_did, schema_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, schema_request) + + # Issuer Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(issuer_did, str(schema_id)) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Issuer Creates credential Definition for Schema + (cred_def_id, cred_def_json) = await anoncreds.issuer_create_and_store_credential_def( + issuer_wallet_handle, + issuer_did, + schema_json, + 'tag1', + 'CL', + '{"support_revocation": true}' + ) + + # Issuer Posts Credential Definition + cred_def_request = await ledger.build_cred_def_request(issuer_did, cred_def_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, cred_def_request) + + # Issuer Creates Revocation Registry + tails_writer_config = json.dumps({'base_dir': str(path_home.joinpath("tails")), 'uri_pattern': ''}) + tails_writer = await blob_storage.open_writer('default', tails_writer_config) + (rev_reg_def_id, rev_reg_def_json, rev_reg_entry_json) = await anoncreds.issuer_create_and_store_revoc_reg( + issuer_wallet_handle, + issuer_did, None, + 'tag1', + cred_def_id, + '{"max_cred_num": 16, "issuance_type":"ISSUANCE_ON_DEMAND"}', + tails_writer + ) + + # Issuer posts Revocation Registry Definition to Ledger + revoc_reg_request = await ledger.build_revoc_reg_def_request(issuer_did, rev_reg_def_json) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_request) + + # Issuer posts Revocation Registry Entry to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_entry_json + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + # ISSUANCE Credential for Prover + + # Prover Creates Master Secret + master_secret_id = "master_secret" + await anoncreds.prover_create_master_secret(prover_wallet_handle, master_secret_id) + + # Issuer Creates credential Offer + cred_offer_json = await anoncreds.issuer_create_credential_offer(issuer_wallet_handle, cred_def_id) + cred_offer = json.loads(cred_offer_json) + + # Prover Gets Credential Definition from Ledger + get_cred_def_request = await ledger.build_get_cred_def_request(prover_did, cred_offer['cred_def_id']) + get_cred_def_response = await ensure_previous_request_applied( + pool_handle, + get_cred_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (cred_def_id, cred_def_json) = await ledger.parse_get_cred_def_response(get_cred_def_response) + + # Prover create credential Request + (cred_req_json, cred_req_metadata_json) = await anoncreds.prover_create_credential_req( + prover_wallet_handle, + prover_did, + cred_offer_json, + cred_def_json, + master_secret_id + ) + + # Issuer Opens Tails reader + blob_storage_reader_cfg_handle = await blob_storage.open_reader('default', tails_writer_config) + + # Issuer create credential for credential Request + # note that encoding is not standardized by Indy except that 32-bit integers are encoded as themselves. IS-786 + cred_values_json = [ + json.dumps( + { + "sex": {"raw": "male", "encoded": "7239210949258394887428692050081607692519917050011144233115103"}, + "name": {"raw": "Alex", "encoded": "1139481716457488690172217916278103335"}, + "height": {"raw": "180", "encoded": "180"}, + "age": {"raw": "28", "encoded": "28"} + } + ), + json.dumps( + { + "sex": {"raw": "female", "encoded": "7239210949258394887428692050081607692519917050011144233115104"}, + "name": {"raw": "Ludmilla", "encoded": "690172217916278103335"}, + "height": {"raw": "171", "encoded": "171"}, + "age": {"raw": "30", "encoded": "30"} + } + ), + json.dumps( + { + "sex": {"raw": "male", "encoded": "7239210949258394887428692050081607692519917050011144233115103"}, + "name": {"raw": "Boris", "encoded": "239572896838295261729"}, + "height": {"raw": "172", "encoded": "172"}, + "age": {"raw": "48", "encoded": "48"} + } + ), + json.dumps( + { + "sex": {"raw": "female", "encoded": "7239210949258394887428692050081607692519917050011144233115104"}, + "name": {"raw": "Olga", "encoded": "258623589235632895688"}, + "height": {"raw": "173", "encoded": "173"}, + "age": {"raw": "78", "encoded": "78"} + } + ) + ] + + cred_json = [None] * 4 + cred_rev_id = [None] * 4 + rev_reg_delta_json = [None] * 4 + credential = [None] * 4 + print(Ink.CYAN('\n\nCreating and storing credentials')) + for i in range(4): + (cred_json[i], cred_rev_id[i], rev_reg_delta_json[i]) = await anoncreds.issuer_create_credential( + issuer_wallet_handle, + cred_offer_json, + cred_req_json, + cred_values_json[i], + rev_reg_def_id, + blob_storage_reader_cfg_handle + ) + + # Issuer Posts Revocation Registry Delta to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_delta_json[i] + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + # Prover Gets RevocationRegistryDefinition + credential[i] = json.loads(cred_json[i]) + get_revoc_reg_def_request = await ledger.build_get_revoc_reg_def_request( + prover_did, + credential[i]['rev_reg_id'] + ) + get_revoc_reg_def_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_def_json) = await ledger.parse_get_revoc_reg_def_response(get_revoc_reg_def_response) + + print( + '.. Prover storing credential {}, rev-id {}, values {}'.format( + 'cred_%s_id' % i, + cred_rev_id[i], + ppjson(json.loads(cred_json[i])['values']) + ) + ) + # Prover Stores Credential + await anoncreds.prover_store_credential( + prover_wallet_handle, + 'cred_%s_id' % i, + cred_req_metadata_json, + cred_json[i], + cred_def_json, + revoc_reg_def_json + ) + + # VERIFYING Prover Credentials (Alex, Olga) when issuer has not revoked any + time.sleep(2) + to = int(time.time()) + + proof_req_json = { + 'Alex': json.dumps( + { + 'nonce': '100000000001', + 'name': 'proof_req', + 'version': '0.1', + 'requested_attributes': { + 'attr1_referent': {'name': 'name'} + }, + 'requested_predicates': { + 'pred1_referent': {'name': 'height', 'p_type': '>=', 'p_value': 180} + }, + "non_revoked": {"to": to} + } + ), + 'Olga': json.dumps( + { + 'nonce': '100000000000', + 'name': 'proof_req', + 'version': '0.1', + 'requested_attributes': { + 'attr1_referent': {'name': 'name'} + }, + 'requested_predicates': { + 'pred1_referent': {'name': 'age', 'p_type': '>=', 'p_value': 65} + }, + "non_revoked": {"to": to} + } + ) + } + + rev_states = { + 'Alex': { + 'timestamp': 0, + 'value': '' + }, + 'Olga': { + 'timestamp': 0, + 'value': '' + } + } + + cred_info = {} + print(Ink.CYAN('\n\nCreating proofs')) + for proof_name in proof_req_json: + print('\n\n.. Creating proof for {}'.format(proof_name)) + # Prover Gets credentials for Proof Request + search_credentials_for_proof_handle = await anoncreds.prover_search_credentials_for_proof_req( + prover_wallet_handle, + proof_req_json[proof_name], + None + ) + fetched_credential_json = await anoncreds.prover_fetch_credentials_for_proof_req( + search_credentials_for_proof_handle, + 'attr1_referent', + 4 + ) + await anoncreds.prover_close_credentials_search_for_proof_req(search_credentials_for_proof_handle) + + pred_spec = None + for i in range(4): + found = json.loads(fetched_credential_json)[i]['cred_info'] # don't clobber cred_info ... + pred_spec = json.loads(proof_req_json[proof_name])['requested_predicates']['pred1_referent'] + if found['attrs'][pred_spec['name']] >= str(pred_spec['p_value']): + break + else: + print('!! No matching credential found for {}'.format(proof_name)) + assert False + cred_info[proof_name] = found # ... until we have the right cred info + print( + '.. Credential info for proof on {}>={} ({}): {}'.format( + pred_spec['name'], + pred_spec['p_value'], + proof_name, + ppjson(cred_info[proof_name]) + ) + ) + + # Prover Gets RevocationRegistryDelta from Ledger + get_revoc_reg_delta_request = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + None, + to + ) + get_revoc_reg_delta_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json, timestamp) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response + ) + + # Prover Creates Revocation State + rev_state_from_timestamp_to_now_json = await anoncreds.create_revocation_state( + blob_storage_reader_cfg_handle, + revoc_reg_def_json, + revoc_reg_delta_json, + timestamp, + cred_info[proof_name]['cred_rev_id'] + ) + rev_states[proof_name] = { + 'timestamp': timestamp, + 'value': rev_state_from_timestamp_to_now_json, + } + + # Prover Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(prover_did, str(cred_info[proof_name]["schema_id"])) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Prover Creates Proof for Proof Request + requested_credentials_json = json.dumps( + { + 'self_attested_attributes': {}, + 'requested_attributes': { + 'attr1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'revealed': True, + 'timestamp': timestamp + } + }, + 'requested_predicates': { + 'pred1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'timestamp': timestamp + } + } + } + ) + + schemas_json = json.dumps({schema_id: json.loads(schema_json)}) + credential_defs_json = json.dumps({cred_def_id: json.loads(cred_def_json)}) + revoc_states_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_state_from_timestamp_to_now_json)}}) + + proof_json = await anoncreds.prover_create_proof( + prover_wallet_handle, + proof_req_json[proof_name], + requested_credentials_json, + master_secret_id, + schemas_json, + credential_defs_json, + revoc_states_json) + proof = json.loads(proof_json) + print('.. Proof for {}: {}'.format(proof_name, ppjson(proof_json, 1024))) + + # Verifier Gets required entities from Ledger + verifier_did = did_my2 + identifier = proof['identifiers'][0] + + # Verifier Gets Schema from Ledger + get_schema_request = await ledger.build_get_schema_request(verifier_did, identifier['schema_id']) + get_schema_response = await ensure_previous_request_applied( + pool_handle, + get_schema_request, + lambda response: response['result']['seqNo'] is not None + ) + (schema_id, schema_json) = await ledger.parse_get_schema_response(get_schema_response) + + # Verifier Gets Credential Definition from Ledger + get_cred_def_request = await ledger.build_get_cred_def_request(verifier_did, identifier['cred_def_id']) + get_cred_def_response = await ensure_previous_request_applied( + pool_handle, + get_cred_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (cred_def_id, cred_def_json) = await ledger.parse_get_cred_def_response(get_cred_def_response) + + # Verifier Gets Revocation Registry Definition from Ledger + get_revoc_reg_def_request = await ledger.build_get_revoc_reg_def_request(verifier_did, identifier['rev_reg_id']) + get_revoc_reg_def_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_def_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_def_json) = await ledger.parse_get_revoc_reg_def_response(get_revoc_reg_def_response) + + # Verifier Gets Revocation Registry from Ledger + get_revoc_reg_request = await ledger.build_get_revoc_reg_request( + verifier_did, + identifier['rev_reg_id'], + identifier['timestamp'] + ) + get_revoc_reg_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, rev_reg_json, identifier) = await ledger.parse_get_revoc_reg_response(get_revoc_reg_response) + + # Verifier verify proof + assert proof_name == proof['requested_proof']['revealed_attrs']['attr1_referent']['raw'] + + schemas_json = json.dumps({schema_id: json.loads(schema_json)}) + credential_defs_json = json.dumps({cred_def_id: json.loads(cred_def_json)}) + revoc_ref_defs_json = json.dumps({rev_reg_id: json.loads(revoc_reg_def_json)}) + revoc_regs_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_reg_json)}}) + + print(Ink.RED('>> rev regs: {}'.format(ppjson(revoc_regs_json)))) + verified = await anoncreds.verifier_verify_proof( + proof_req_json[proof_name], + proof_json, + schemas_json, + credential_defs_json, + revoc_ref_defs_json, + revoc_regs_json + ) + print(Ink.GREEN('.. Proof for {} before any revocations verifies as {}'.format(proof_name, verified))) + assert verified + + proof_req_expected_result = { + 'Alex': False, + 'Olga': True + } + # Issuer revokes creds for all but Olga, one by one, creating and verifying proofs for Alex and Olga each time + print(Ink.CYAN('\n\nIssuer revoking creds one by one')) + for i in range(3): + revo_name = json.loads(cred_values_json[i])['name']['raw'] + print( + '\n\n.. Issuer revoking {} (cred rev id {}) at epoch={}'.format( + revo_name, + cred_rev_id[i], + int(time.time()) + ) + ) + rev_reg_delta_json = await anoncreds.issuer_revoke_credential( + issuer_wallet_handle, + blob_storage_reader_cfg_handle, + rev_reg_def_id, + cred_rev_id[i] + ) + + # Issuer Posts RevocationRegistryDelta to Ledger + revoc_reg_entry_request = await ledger.build_revoc_reg_entry_request( + issuer_did, + rev_reg_def_id, + "CL_ACCUM", + rev_reg_delta_json + ) + await ledger.sign_and_submit_request(pool_handle, issuer_wallet_handle, issuer_did, revoc_reg_entry_request) + + print(Ink.CYAN('.. Processing proofs after revocation of {}'.format(revo_name))) + for proof_name in proof_req_json: + # VERIFYING Prover Credential after Revocation + time.sleep(2) + fro = to + to = int(time.time()) + print( + '.. .. after sleeping 2 seconds, doing {} for interval [{}, {}]'.format( + proof_name, + fro, + to + ) + ) + # There two possible ways: + + # 1) Prover creates updates previously created revocation state + # Prover Gets RevocationRegistryDelta from Ledger + # from: when last prover revocation state were created + # to: to + get_revoc_reg_delta_request = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + rev_states[proof_name]['timestamp'], + to + ) + + get_revoc_reg_delta_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json, timestamp) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response + ) + + # Prover Updates previously created Revocation State + rev_state_from_timestamp_to_now_json = await anoncreds.update_revocation_state( + blob_storage_reader_cfg_handle, + rev_states[proof_name]['value'], + revoc_reg_def_json, + revoc_reg_delta_json, + timestamp, + cred_rev_id[0 if proof_name == 'Alex' else 3] # Alex, then Olga + ) + + # Prover creates revocation state from scratch + # from: 0 or time of credential issuance + # to: to + # Prover Gets RevocationRegistryDelta from Ledger + get_revoc_reg_delta_request_2 = await ledger.build_get_revoc_reg_delta_request( + prover_did, + rev_reg_def_id, + 0, + to + ) + + get_revoc_reg_delta_response_2 = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_delta_request_2, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, revoc_reg_delta_json_2, timestamp_2) = await ledger.parse_get_revoc_reg_delta_response( + get_revoc_reg_delta_response_2 + ) + + # Prover creates Revocation State + rev_state_from_0_to_now_json = await anoncreds.create_revocation_state( + blob_storage_reader_cfg_handle, + revoc_reg_def_json, + revoc_reg_delta_json_2, + timestamp_2, + cred_rev_id[0 if proof_name == 'Alex' else 3] # Alex, then Olga + ) + + rev_states[proof_name] = { + 'timestamp': timestamp, + 'value': rev_state_from_timestamp_to_now_json # rev_state_from_0_to_now_json must also work + } + + revoc_states_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_states[proof_name]['value'])}}) + + # Prover Creates Proof for Proof Request + requested_credentials_json = json.dumps( + { + 'self_attested_attributes': {}, + 'requested_attributes': { + 'attr1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'revealed': True, + 'timestamp': timestamp + } + }, + 'requested_predicates': { + 'pred1_referent': { + 'cred_id': cred_info[proof_name]['referent'], + 'timestamp': timestamp + } + } + } + ) + + proof_json = await anoncreds.prover_create_proof( + prover_wallet_handle, + proof_req_json[proof_name], + requested_credentials_json, + master_secret_id, + schemas_json, + credential_defs_json, + revoc_states_json + ) + + proof = json.loads(proof_json) + identifier = proof['identifiers'][0] + + # Verifier Gets RevocationRegistry from Ledger + get_revoc_reg_request = await ledger.build_get_revoc_reg_request( + verifier_did, + identifier['rev_reg_id'], + identifier['timestamp'] + ) + get_revoc_reg_response = await ensure_previous_request_applied( + pool_handle, + get_revoc_reg_request, + lambda response: response['result']['seqNo'] is not None + ) + (rev_reg_id, rev_reg_json, timestamp) = await ledger.parse_get_revoc_reg_response(get_revoc_reg_response) + + revoc_regs_json = json.dumps({rev_reg_id: {timestamp: json.loads(rev_reg_json)}}) + print(Ink.RED('>> >> rev regs: {}'.format(ppjson(revoc_regs_json)))) + + proof_req_touchup = json.loads(proof_req_json[proof_name]) + proof_req_touchup['non_revoked']['to'] = int(time.time()) + proof_req_json[proof_name] = json.dumps(proof_req_touchup) + print( + '.. .. {}: Proof req {}, proof {}'.format( + proof_name, + ppjson(proof_req_json[proof_name]), + ppjson(proof_json, 1024) + ) + ) + verified = await anoncreds.verifier_verify_proof( + proof_req_json[proof_name], + proof_json, + schemas_json, + credential_defs_json, + revoc_ref_defs_json, + revoc_regs_json + ) + assert proof_req_expected_result[proof_name] == verified + print( + Ink.GREEN( + '.. .. Proof for {} after {} revocation verifies as: {}'.format( + proof_name, + revo_name, + verified + ) + ) + ) + + # Close and Delete Prover Wallet + await wallet.close_wallet(prover_wallet_handle) + await wallet.delete_wallet(prover_wallet_config, credentials) diff --git a/wrappers/rust/src/anoncreds.rs b/wrappers/rust/src/anoncreds.rs index 9d04630f5a..9b646236ab 100644 --- a/wrappers/rust/src/anoncreds.rs +++ b/wrappers/rust/src/anoncreds.rs @@ -1346,12 +1346,19 @@ fn _verifier_verify_proof(command_handle: CommandHandle, proof_request_json: &st } -/// Create revocation state for a credential in the particular time moment. +/// Create revocation state for a credential that corresponds to a particular time. +/// +/// Note that revocation delta must cover the whole registry existence time. +/// You can use `from`: `0` and `to`: `needed_time` as parameters for building request to get correct revocation delta. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later with applying a new +/// revocation delta with `update_revocation_state` function. +/// This new delta should be received with parameters: `from`: `timestamp` and `to`: `needed_time`. /// /// # Arguments /// * `blob_storage_reader_handle`: configuration of blob storage reader handle that will allow to read revocation tails /// * `rev_reg_def_json`: revocation registry definition json -/// * `rev_reg_delta_json`: revocation registry definition delta json +/// * `rev_reg_delta_json`: revocation registry delta which covers the whole registry existence time /// * `timestamp`: time represented as a total number of seconds from Unix Epoch /// * `cred_rev_id`: user credential revocation id in revocation registry /// @@ -1381,14 +1388,19 @@ fn _create_revocation_state(command_handle: CommandHandle, blob_storage_reader_h }) } -/// Create new revocation state for a credential based on existed state -/// at the particular time moment (to reduce calculation time). +/// Create a new revocation state for a credential based on a revocation state created before. +/// Note that provided revocation delta must cover the registry gap from based state creation until the specified time +/// (this new delta should be received with parameters: `from`: `state_timestamp` and `to`: `needed_time`). +/// +/// This function reduces the calculation time. +/// +/// The resulting revocation state and provided timestamp can be saved and reused later by applying a new revocation delta again. /// /// # Arguments /// * `blob_storage_reader_handle`: configuration of blob storage reader handle that will allow to read revocation tails /// * `rev_state_json`: revocation registry state json /// * `rev_reg_def_json`: revocation registry definition json -/// * `rev_reg_delta_json`: revocation registry definition delta json +/// * `rev_reg_delta_json`: revocation registry definition delta which covers the gap form original `rev_state_json` creation till the requested timestamp. /// * `timestamp`: time represented as a total number of seconds from Unix Epoch /// * `cred_rev_id`: user credential revocation id in revocation registry ///