diff --git a/libsovtoken/src/lib.rs b/libsovtoken/src/lib.rs index f8cd1878c..47ac5d620 100644 --- a/libsovtoken/src/lib.rs +++ b/libsovtoken/src/lib.rs @@ -50,7 +50,6 @@ extern crate rust_indy_sdk as indy; // lib-sdk project // ------------------------------------------ -#[allow(unused_variables)] #[macro_use] pub mod utils; pub mod api; diff --git a/libsovtoken/src/logic/config/payment_address_config.rs b/libsovtoken/src/logic/config/payment_address_config.rs index f6cac1691..a9515027a 100644 --- a/libsovtoken/src/logic/config/payment_address_config.rs +++ b/libsovtoken/src/logic/config/payment_address_config.rs @@ -1,9 +1,6 @@ //! defines structure and implementation for PaymentAddressConfig which is used //! for generating payment addresses -#![warn(unused_imports)] -#[allow(unused_imports)] - use serde_json; use std::ffi::CString; use utils::ffi_support::cstring_from_str; diff --git a/libsovtoken/src/logic/output.rs b/libsovtoken/src/logic/output.rs index 340997d96..797797364 100644 --- a/libsovtoken/src/logic/output.rs +++ b/libsovtoken/src/logic/output.rs @@ -177,7 +177,7 @@ mod output_tests { #[test] fn deserialize_output_tuple() { let json = json!(["pay:sov:a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7", 10]); - let expected = Output::new(String::from("pay:sov:a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7"), 10); + let expected = output(); assert_valid_deserialize(json, expected); } @@ -189,15 +189,21 @@ mod output_tests { assert_invalid_deserialize(json, "missing field `amount`"); } - // this test ensures that the deserialized JSON is serialized correctly + #[test] + fn serialize_valid_output_object() { + let output = output(); + let json = json!(["pay:sov:a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7", 10]); + assert_valid_serialize(output, json); + } + #[test] fn serializing_fee_struct_output_config() { - let output = Output::new(String::from("a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7"), 10); + let output = output(); let fee: OutputConfig = OutputConfig { ver: 1, outputs: vec![output], }; - assert_eq!(fee.to_json().unwrap(), r#"{"ver":1,"outputs":[["a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7",10]]}"#); + assert_eq!(fee.to_json().unwrap(), r#"{"ver":1,"outputs":[["pay:sov:a8QAXMjRwEGoGLmMFEc5sTcntZxEF1BpqAs8GoKFa9Ck81fo7",10]]}"#); } } diff --git a/libsovtoken/src/logic/parsers/parse_get_utxo_response.rs b/libsovtoken/src/logic/parsers/parse_get_utxo_response.rs index 09b4224a8..ad63bd512 100644 --- a/libsovtoken/src/logic/parsers/parse_get_utxo_response.rs +++ b/libsovtoken/src/logic/parsers/parse_get_utxo_response.rs @@ -1,6 +1,4 @@ //! types used for parse_get_utxo_response_handler -#![allow(unused_variables)] -#![allow(unused_imports)] use base64; use indy::ErrorCode; @@ -10,11 +8,9 @@ use logic::parsers::common::{ResponseOperations, TXO, StateProof, ParsedSP, KeyV use logic::parsers::error_code_parser; use logic::type_aliases::{TokenAmount, TxnSeqNo, ProtocolVersion, ReqId}; use logic::address; -use rust_base58::ToBase58; use serde_json; use utils::constants::txn_fields::OUTPUTS; use utils::ffi_support::c_pointer_from_string; -use utils::json_conversion::{JsonSerialize, JsonDeserialize}; type Outputs_ = Vec<(String, TxnSeqNo, TokenAmount)>; @@ -83,7 +79,7 @@ pub fn from_response(base : ParseGetUtxoResponse) -> Result Result Result Result { + fn indy_create_key(&self, _wallet_id: i32, _config: PaymentAddressConfig) -> Result { return Ok(gen_random_base58_verkey()); } @@ -106,7 +104,7 @@ mod payments_tests { return ErrorCode::CommonInvalidState; } - fn indy_create_key_async(&self, wallet_id: i32, config: PaymentAddressConfig, mut closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send { + fn indy_create_key_async(&self, _wallet_id: i32, _config: PaymentAddressConfig, mut closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send { closure(ErrorCode::Success, gen_random_base58_verkey()); return ErrorCode::Success; } @@ -140,7 +138,7 @@ mod payments_tests { let address = match handler.create_payment_address(WALLET_ID, config) { Ok(s) => s, - Err(e) => "".to_string(), + Err(_) => "".to_string(), }; // got our result, if its correct, it will look something like this: @@ -167,7 +165,7 @@ mod payments_tests { let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler{}); let address = match handler.create_payment_address(WALLET_ID, config){ Ok(s) => s, - Err(e) => "".to_string(), + Err(_) => "".to_string(), }; // got our result, if its correct, it will look something like this: @@ -208,6 +206,6 @@ mod payments_tests { let got_good_result = receiver.recv_timeout(Duration::from_secs(10)).unwrap(); assert_eq!(got_good_result, true); - + assert_eq!(ErrorCode::Success, error_code); } } diff --git a/libsovtoken/src/logic/xfer_payload.rs b/libsovtoken/src/logic/xfer_payload.rs index 81c0951c1..755d9355f 100644 --- a/libsovtoken/src/logic/xfer_payload.rs +++ b/libsovtoken/src/logic/xfer_payload.rs @@ -6,7 +6,6 @@ * [`Inputs`]: Inputs * [`Outputs`]: Outputs */ -#![allow(unused_must_use)] use hex::ToHex; @@ -284,7 +283,6 @@ fn do_serialize_signature(v: serde_json::Value, is_top_level: bool) -> Result(&self, wallet_id: i32, config: PaymentAddressConfig, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send { + fn indy_create_key_async(&self, _wallet_id: i32, _config: PaymentAddressConfig, _closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send { return ErrorCode::CommonInvalidState; } } @@ -333,7 +331,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (sender, receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result, _| { sender.lock().unwrap().send(result); }; + let cb = move |result, _| { + sender.lock().unwrap().send(result).unwrap(); + }; XferPayload::sign_input( &CryptoApiHandler{}, wallet_handle, @@ -351,7 +351,7 @@ mod test_xfer_payload { let wallet_handle = 1; let (sender, receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; XferPayload::sign_inputs(&CryptoApiHandler{}, wallet_handle, inputs, outputs, &None, &None, Box::new(cb))?; receiver.recv().unwrap().map(|map| map.values().cloned().collect()) @@ -401,9 +401,9 @@ mod test_xfer_payload { String::remove(&mut outputs[0].recipient, 5); let payload = XferPayload::new(inputs, outputs, None); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = payload.sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); @@ -415,9 +415,9 @@ mod test_xfer_payload { let (mut inputs, outputs) = inputs_outputs_valid_qualified(); String::remove(&mut inputs[0].address, 13); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(inputs, outputs, None).sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); @@ -428,9 +428,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (_, outputs) = inputs_outputs_valid_qualified(); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(Vec::new(), outputs, None).sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); @@ -441,9 +441,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (inputs, _) = inputs_outputs_valid_qualified(); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(inputs, Vec::new(), None).sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); @@ -454,9 +454,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (inputs, _) = inputs_outputs_valid_qualified(); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(inputs, Vec::new(), None).sign_fees(&CryptoApiHandler{}, wallet_handle, &None, Box::new(cb)); assert!(signed_payload.is_ok()); @@ -467,9 +467,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (inputs, outputs) = inputs_outputs_valid_qualified(); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(inputs, outputs, None).sign_fees(&CryptoApiHandler{}, wallet_handle, &None, Box::new(cb)); assert!(signed_payload.is_ok()); @@ -480,9 +480,9 @@ mod test_xfer_payload { let wallet_handle = 1; let (_, outputs) = inputs_outputs_valid_qualified(); - let (sender, receiver) = channel(); + let (sender, _receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; let signed_payload = XferPayload::new(Vec::new(), outputs, None).sign_fees(&CryptoApiHandler{}, wallet_handle, &None, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); @@ -510,12 +510,13 @@ mod test_xfer_payload { let (sender, receiver) = channel(); let sender = Mutex::new(sender); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; XferPayload::new(inputs, outputs, None).sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap(); let signed_payload = receiver.recv().unwrap().unwrap(); assert_eq!(expected_inputs, signed_payload.inputs); assert_eq!(expected_outputs, signed_payload.outputs); + assert_eq!(expected_signatures, signed_payload.signatures); } /* @@ -540,7 +541,7 @@ mod test_xfer_payload { for _ in 0..attempts { let sender = sender.clone(); - let cb = move |result| { sender.lock().unwrap().send(result); }; + let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; payload.clone().sign_transfer( &CryptoApiHandler{}, wallet_handle, diff --git a/libsovtoken/src/utils/ffi_support.rs b/libsovtoken/src/utils/ffi_support.rs index 2c735c475..cd1386029 100644 --- a/libsovtoken/src/utils/ffi_support.rs +++ b/libsovtoken/src/utils/ffi_support.rs @@ -170,7 +170,7 @@ mod ffi_support_tests { #[test] fn api_result_handler_callback_on_ok() { static mut CALLBACK_CALLED: bool = false; - extern fn callback(ch: i32, ec: i32, val: u32) { + extern fn callback(_ch: i32, _ec: i32, val: u32) { assert_eq!(val, 2); unsafe { CALLBACK_CALLED = true } } diff --git a/libsovtoken/src/utils/general.rs b/libsovtoken/src/utils/general.rs index 9ad8ccccd..a7949d86d 100644 --- a/libsovtoken/src/utils/general.rs +++ b/libsovtoken/src/utils/general.rs @@ -108,7 +108,6 @@ mod general_tests { fn success_from_right_full_string_when_exceeding_len() { let data = "1234567890".to_string(); - let len = data.len(); let copy = data.as_str(); let result = copy.from_right(75); diff --git a/libsovtoken/tests/api_tests.rs b/libsovtoken/tests/api_tests.rs index d8eea2d0d..1bb747f46 100644 --- a/libsovtoken/tests/api_tests.rs +++ b/libsovtoken/tests/api_tests.rs @@ -1,12 +1,6 @@ //! //! tests for API related functions - -#![warn(unused_imports)] -#![allow(unused_variables)] -#![allow(dead_code)] -#[allow(unused_imports)] - extern crate sovtoken; extern crate rust_indy_sdk as indy; // lib-sdk project diff --git a/libsovtoken/tests/create_payment_tests.rs b/libsovtoken/tests/create_payment_tests.rs index cbbc255c3..02a6b1193 100644 --- a/libsovtoken/tests/create_payment_tests.rs +++ b/libsovtoken/tests/create_payment_tests.rs @@ -1,12 +1,6 @@ //! //! tests for Payment related functions - -#![warn(unused_imports)] -#![allow(unused_variables)] -#![allow(dead_code)] -#[allow(unused_imports)] - extern crate env_logger; extern crate libc; extern crate rand; @@ -28,7 +22,6 @@ use std::time::Duration; use indy::ErrorCode; use sovtoken::logic::config::payment_address_config::PaymentAddressConfig; use sovtoken::logic::address::unqualified_address_from_address; -use sovtoken::utils::logger::*; use sovtoken::utils::test::callbacks; mod utils; use rust_base58::FromBase58; @@ -38,11 +31,8 @@ const WALLET_ID: i32 = 99; const COMMAND_HANDLE: i32 = 1; const TIMEOUT_SECONDS: u64 = 20; static VALID_SEED_LEN: usize = 32; -static WALLET_NAME_1: &'static str = "integration_test_wallet_1"; -static WALLET_NAME_2: &'static str = "integration_test_wallet_2"; static INVALID_CONFIG_JSON: &'static str = r#"{ "horrible" : "only on tuedays"}"#; static VALID_CONFIG_EMPTY_SEED_JSON: &'static str = r#"{}"#; -static TESTING_LOGGER: ConsoleLogger = ConsoleLogger; // ***** HELPER METHODS ***** @@ -56,7 +46,7 @@ fn rand_string(length : usize) -> String { return s; } -extern "C" fn empty_create_payment_callback(command_handle_: i32, err: i32, payment_address: *const c_char) -> i32 { +extern "C" fn empty_create_payment_callback(_command_handle: i32, _err: i32, _payment_address: *const c_char) -> i32 { return ErrorCode::Success as i32; } @@ -163,7 +153,7 @@ pub fn create_address_two_times_with_the_same_seed() { let seed = json!({"seed": "00000000000000000000000000000000"}).to_string(); - let pa1 = indy::payments::Payment::create_payment_address(wallet.handle, "sov", &seed).unwrap(); + let _pa1 = indy::payments::Payment::create_payment_address(wallet.handle, "sov", &seed).unwrap(); let err = indy::payments::Payment::create_payment_address(wallet.handle, "sov", &seed).unwrap_err(); assert_eq!(err, indy::ErrorCode::WalletItemAlreadyExists);