From 4c9b7ae0f18e793ffa2f0de3c7f0f994bfcd79b1 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 16 Apr 2019 13:59:45 +0300 Subject: [PATCH 01/25] Corrected requet id building Signed-off-by: artem.ivanov --- libsovtoken/Cargo.toml | 1 + libsovtoken/src/lib.rs | 1 + libsovtoken/src/logic/parsers/parse_payment_response.rs | 2 +- libsovtoken/src/logic/request.rs | 4 ++-- libsovtoken/src/logic/type_aliases.rs | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libsovtoken/Cargo.toml b/libsovtoken/Cargo.toml index 7029ac168..ef9b64b28 100644 --- a/libsovtoken/Cargo.toml +++ b/libsovtoken/Cargo.toml @@ -36,6 +36,7 @@ serde_json = "1.0.39" sha2 = "0.8.0" sha3 = "0.8.0" sodiumoxide = "0.0.16" +time = "0.1.42" [dev-dependencies] diff --git a/libsovtoken/src/lib.rs b/libsovtoken/src/lib.rs index 91f2e9c67..6e000f113 100644 --- a/libsovtoken/src/lib.rs +++ b/libsovtoken/src/lib.rs @@ -16,6 +16,7 @@ extern crate rand; extern crate serde; extern crate sodiumoxide; extern crate sha2; +extern crate time; // ------------------------------------------ // crates from crate.io etc that require macro // ------------------------------------------ diff --git a/libsovtoken/src/logic/parsers/parse_payment_response.rs b/libsovtoken/src/logic/parsers/parse_payment_response.rs index 061a10ecf..fea6edf55 100644 --- a/libsovtoken/src/logic/parsers/parse_payment_response.rs +++ b/libsovtoken/src/logic/parsers/parse_payment_response.rs @@ -72,7 +72,7 @@ pub struct TransactionData { pub struct TransactionMetaData2 { pub digest: String, pub from: String, - pub req_id: u32, + pub req_id: u64, } diff --git a/libsovtoken/src/logic/request.rs b/libsovtoken/src/logic/request.rs index e761fd713..46a321523 100644 --- a/libsovtoken/src/logic/request.rs +++ b/libsovtoken/src/logic/request.rs @@ -4,13 +4,13 @@ use libc::c_char; use serde::Serialize; use serde_json; use std::ffi::CString; +use time; use logic::type_aliases::{ProtocolVersion, ReqId}; use {IndyHandle, ErrorCode}; use utils::constants::general::PROTOCOL_VERSION; use utils::ffi_support::{cstring_from_str, c_pointer_from_string}; use utils::json_conversion::JsonSerialize; -use utils::random::rand_req_id; use logic::indy_sdk_api::ledger; @@ -31,7 +31,7 @@ impl Request where T: Serialize { pub fn new(operation: T, identifier: Option) -> Self { - let req_id = rand_req_id(); + let req_id = time::get_time().sec as u64 * (1e9 as u64) + time::get_time().nsec as u64; return Request { operation, protocol_version: PROTOCOL_VERSION, diff --git a/libsovtoken/src/logic/type_aliases.rs b/libsovtoken/src/logic/type_aliases.rs index 7504fd1b7..5d94e006d 100644 --- a/libsovtoken/src/logic/type_aliases.rs +++ b/libsovtoken/src/logic/type_aliases.rs @@ -2,6 +2,6 @@ pub type TxnSeqNo = u64; pub type TokenAmount = u64; -pub type ReqId = u32; +pub type ReqId = u64; pub type ProtocolVersion = u32; pub type TxnVersion = String; From 264df8efe3a0ffb2515d51659609c4ab84750906 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 17 Apr 2019 09:51:59 +0300 Subject: [PATCH 02/25] Updated request serialization to match libindy's Signed-off-by: artem.ivanov --- libsovtoken/src/logic/xfer_payload.rs | 77 +++++++++++--------- libsovtoken/src/utils/constants/txn_types.rs | 13 ++-- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/libsovtoken/src/logic/xfer_payload.rs b/libsovtoken/src/logic/xfer_payload.rs index ada0d19d9..5d47ee8ff 100644 --- a/libsovtoken/src/logic/xfer_payload.rs +++ b/libsovtoken/src/logic/xfer_payload.rs @@ -20,8 +20,9 @@ use ErrorCode; use logic::address; use logic::indy_sdk_api::crypto_api::CryptoAPI; use logic::input::{Input, Inputs}; -use logic::output::{Outputs}; +use logic::output::Outputs; use logic::hash::Hash; +use utils::constants::txn_types::{ATTRIB, GET_ATTRIB}; /** * Holds `inputs` and `outputs` @@ -62,9 +63,11 @@ pub struct XferPayload { } unsafe impl Send for XferPayload {} + unsafe impl Sync for XferPayload {} impl InputSigner for XferPayload {} + impl XferPayload { pub fn new(inputs: Inputs, outputs: Outputs, extra: Option) -> Self { @@ -110,7 +113,7 @@ impl XferPayload { debug!("Indicator stripped from inputs"); - XferPayload::sign_inputs(crypto_api, wallet_handle, &self.inputs.clone(), &self.outputs.clone(), txn_digest, &self.extra.clone(),Box::new(move |signatures| { + XferPayload::sign_inputs(crypto_api, wallet_handle, &self.inputs.clone(), &self.outputs.clone(), txn_digest, &self.extra.clone(), Box::new(move |signatures| { match signatures { Ok(signatures) => { let payload = Self::clone_payload_add_signatures(&self, signatures); @@ -136,7 +139,7 @@ impl XferPayload { .filter(|signature| signature.is_some()) .map(|signature| signature.unwrap().to_owned()) .collect(); - + XferPayload { inputs: prev.inputs.clone(), outputs: prev.outputs.clone(), @@ -204,7 +207,7 @@ trait InputSigner { Some(json!([input])), Some(json!(outputs)), txn_digest.clone().map(|e| json!(e)), -// _extra.map(|e| json!(e)) + // _extra.map(|e| json!(e)) ].into_iter().filter_map(|e| e).collect(); let message = serialize_signature(json!(vals))?; @@ -236,24 +239,21 @@ trait InputSigner { } pub fn serialize_signature(v: serde_json::Value) -> Result { - do_serialize_signature(v, true) + let _type = v["operation"]["type"].clone(); + do_serialize_signature(v, true, _type.as_str()) } -fn do_serialize_signature(v: serde_json::Value, is_top_level: bool) -> Result { +fn do_serialize_signature(v: serde_json::Value, is_top_level: bool, _type: Option<&str>) -> Result { match v { serde_json::Value::Bool(value) => Ok(if value { "True".to_string() } else { "False".to_string() }), serde_json::Value::Number(value) => Ok(value.to_string()), serde_json::Value::String(value) => Ok(value), serde_json::Value::Array(array) => { - let mut result = "".to_string(); - let length = array.len(); - for (index, element) in array.iter().enumerate() { - result += &do_serialize_signature(element.clone(), false)?; - if index < length - 1 { - result += ","; - } - } - Ok(result) + array + .into_iter() + .map(|element| do_serialize_signature(element, false, _type)) + .collect::, ErrorCode>>() + .map(|res| res.join(",")) } serde_json::Value::Object(map) => { let mut result = "".to_string(); @@ -267,12 +267,19 @@ fn do_serialize_signature(v: serde_json::Value, is_top_level: bool) -> Result (Inputs, Outputs) { let outputs = vec![ Output::new(String::from("TKe9eXtchV71J2qXX5HwP8rbkTBStnEEkMwQkHie265VtRSbs"), 10), @@ -314,7 +321,7 @@ mod test_xfer_payload { let inputs = vec![ Input::new(String::from("E9LNHk8shQ6xe2RfydzXDSsyhWC6vJaUeKE2mmc6mWraDfmKm"), 1), Input::new(String::from("2oWxuFMbhPewEbCEeKnvjcpVq8qpHHrN5y4aU81MWG5dYfeM7V"), 1), - ]; + ]; return (inputs, outputs); } @@ -335,7 +342,7 @@ mod test_xfer_payload { sender.lock().unwrap().send(result).unwrap(); }; XferPayload::sign_input( - &CryptoApiHandler{}, + &CryptoApiHandler {}, wallet_handle, input, outputs, @@ -352,7 +359,7 @@ mod test_xfer_payload { let (sender, receiver) = channel(); let sender = Mutex::new(sender); let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; - XferPayload::sign_inputs(&CryptoApiHandler{}, wallet_handle, inputs, outputs, &None, &None, + XferPayload::sign_inputs(&CryptoApiHandler {}, wallet_handle, inputs, outputs, &None, &None, Box::new(cb))?; receiver.recv().unwrap().map(|map| map.values().cloned().collect()) } @@ -380,7 +387,7 @@ mod test_xfer_payload { fn sign_multi_input_invalid_input_address() { let (mut inputs, outputs) = inputs_outputs_valid(); String::remove(&mut inputs[0].address, 5); - + let signatures = sign_inputs_sync(&inputs, &outputs).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signatures); } @@ -388,7 +395,7 @@ mod test_xfer_payload { #[test] fn sign_multi_input() { let (inputs, outputs) = inputs_outputs_valid(); - + let signed_inputs = sign_inputs_sync(&inputs, &outputs).unwrap(); assert!(signed_inputs.contains(&"31VzUm5vZRfWPk38W3YJaNjrkUeD6tELmjxv42cp7Vnksigned".to_string())); assert!(signed_inputs.contains(&"GyPZzuu8S1KMs5p6iE1wBzjQsFtaB7eigssW4YbdXdtesigned".to_string())); @@ -404,7 +411,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; - let signed_payload = payload.sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).unwrap_err(); + let signed_payload = payload.sign_transfer(&CryptoApiHandler {}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); } @@ -418,7 +425,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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(); + let signed_payload = XferPayload::new(inputs, outputs, None).sign_transfer(&CryptoApiHandler {}, wallet_handle, Box::new(cb)).unwrap_err(); assert_eq!(ErrorCode::CommonInvalidStructure, signed_payload); } @@ -431,7 +438,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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(); + 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); } @@ -444,7 +451,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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(); + 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); } @@ -457,7 +464,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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)); + let signed_payload = XferPayload::new(inputs, Vec::new(), None).sign_fees(&CryptoApiHandler {}, wallet_handle, &None, Box::new(cb)); assert!(signed_payload.is_ok()); } @@ -470,7 +477,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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)); + let signed_payload = XferPayload::new(inputs, outputs, None).sign_fees(&CryptoApiHandler {}, wallet_handle, &None, Box::new(cb)); assert!(signed_payload.is_ok()); } @@ -483,7 +490,7 @@ mod test_xfer_payload { let (sender, _receiver) = channel(); let sender = Mutex::new(sender); 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(); + 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); } @@ -505,13 +512,13 @@ mod test_xfer_payload { ]; let expected_signatures = Some(vec![String::from("31VzUm5vZRfWPk38W3YJaNjrkUeD6tELmjxv42cp7Vnksigned"), - String::from("GyPZzuu8S1KMs5p6iE1wBzjQsFtaB7eigssW4YbdXdtesigned")]); + String::from("GyPZzuu8S1KMs5p6iE1wBzjQsFtaB7eigssW4YbdXdtesigned")]); let (sender, receiver) = channel(); let sender = Mutex::new(sender); let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; - XferPayload::new(inputs, outputs, None).sign_transfer(&CryptoApiHandler{}, wallet_handle, Box::new(cb)).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); @@ -527,7 +534,7 @@ mod test_xfer_payload { fn sign_multi_input_preserve_ordering() { let attempts = 5; let wallet_handle = 1; - let (mut inputs, outputs) = inputs_outputs_valid_qualified(); + let (mut inputs, outputs) = inputs_outputs_valid_qualified(); inputs.reverse(); let expected_signatures = vec![ @@ -543,7 +550,7 @@ mod test_xfer_payload { let sender = sender.clone(); let cb = move |result| { sender.lock().unwrap().send(result).unwrap(); }; payload.clone().sign_transfer( - &CryptoApiHandler{}, + &CryptoApiHandler {}, wallet_handle, Box::new(cb) ).unwrap(); diff --git a/libsovtoken/src/utils/constants/txn_types.rs b/libsovtoken/src/utils/constants/txn_types.rs index 1212625ed..1761551c3 100644 --- a/libsovtoken/src/utils/constants/txn_types.rs +++ b/libsovtoken/src/utils/constants/txn_types.rs @@ -29,14 +29,15 @@ pub const GET_UTXO: &'static str = "10002"; pub const SET_FEES: &'static str = "20000"; +pub const NYM: &'static str = "1"; + +pub const ATTRIB: &'static str = "100"; + +pub const GET_ATTRIB: &'static str = "104"; + /** #description A transaction type submitted by anyone to get the current Fees costs of every transaction */ -pub const GET_FEES: &'static str = "20001"; - - -pub const NYM: &'static str = "1"; - -pub const ATTRIB: &'static str = "100"; +pub const GET_FEES: &'static str = "20001"; \ No newline at end of file From 8ef5a7988e9dc3e7610794771e32d93e268ba745 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 17 Apr 2019 10:59:12 +0300 Subject: [PATCH 03/25] ST-576: Improve LibSovToken integration tests Signed-off-by: artem.ivanov --- libsovtoken/src/logic/address.rs | 42 +++++ .../logic/api_internals/add_request_fees.rs | 42 ++++- libsovtoken/src/logic/payments.rs | 69 +++----- libsovtoken/tests/add_fees_for_attrib_test.rs | 6 + ...st.rs => add_request_fees_handler_test.rs} | 146 ++++++++--------- .../tests/build_fees_txn_handler_test.rs | 152 ++++++++++++------ .../build_get_utxo_request_handler_test.rs | 94 +++++++++-- .../tests/build_mint_txn_handler_test.rs | 83 ++++------ .../tests/build_payment_req_handler_test.rs | 145 ++++++----------- libsovtoken/tests/build_verify_req_test.rs | 88 ++++++++-- ...=> create_payment_addres_handler_tests.rs} | 106 ++++-------- .../tests/parse_payment_response_test.rs | 95 ----------- libsovtoken/tests/utils/callbacks.rs | 9 ++ libsovtoken/tests/utils/mod.rs | 1 + 14 files changed, 562 insertions(+), 516 deletions(-) rename libsovtoken/tests/{build_add_fees_txn_handler_test.rs => add_request_fees_handler_test.rs} (58%) rename libsovtoken/tests/{create_payment_tests.rs => create_payment_addres_handler_tests.rs} (54%) delete mode 100644 libsovtoken/tests/parse_payment_response_test.rs create mode 100644 libsovtoken/tests/utils/callbacks.rs diff --git a/libsovtoken/src/logic/address.rs b/libsovtoken/src/logic/address.rs index 5842bab38..1a7bd68e9 100644 --- a/libsovtoken/src/logic/address.rs +++ b/libsovtoken/src/logic/address.rs @@ -272,6 +272,14 @@ pub mod address_tests { assert_eq!(address_bytes.len() - vk_bytes.len(), ADDRESS_CHECKSUM_LEN); } + #[test] + fn test_unqualified_address_from_verkey_invalid_verkey() { + let vk_bytes = rand_bytes(VERKEY_LEN - 1); + let verkey = vk_bytes.into_base58(); + let err = unqualified_address_from_verkey(&verkey).unwrap_err(); + assert_eq!(ErrorCode::CommonInvalidStructure, err); + } + #[test] fn test_verkey_invalid_address_length_long_and_short() { validate_address_invalid_verkey_len(30); @@ -288,6 +296,13 @@ pub mod address_tests { assert_eq!(ErrorCode::CommonInvalidStructure, error); } + #[test] + fn test_address_from_unqualified_address() { + let unqualified_address = gen_random_base58_address(); + let address = address_from_unqualified_address(&unqualified_address).unwrap(); + assert_eq!(format!("pay:sov:{}", unqualified_address), address); + } + #[test] fn test_verkey_from_qualified_address() { let verkey = gen_random_base58_verkey(); @@ -327,6 +342,14 @@ pub mod address_tests { assert_eq!(ErrorCode::CommonInvalidStructure, error); } + #[test] + fn test_unqualified_address() { + let address = gen_random_base58_address(); + let qualified_address = format!("pay:sov:{}", address); + let unqualified_address = unqualified_address_from_address(&qualified_address).unwrap(); + assert_eq!(address, unqualified_address); + } + #[test] fn test_unqualified_address_invalid_qualifier() { let address = gen_random_base58_address(); @@ -375,4 +398,23 @@ pub mod address_tests { assert_eq!(validate_address(&fa).unwrap(), verkeys[i]) } } + + #[test] + fn string_to_txo_works() { + let txo_str = "txo:sov:fkjZEd8eTBnYJsw7m7twMph3UYD7j2SoWcDM45DkmRx8eq2SkQnzxoLxyMT1RBAat9x86MwXNJH88Pxf9u7JsM5m8ApXn3bvgbtS5cegZzNp7WmMSpWL"; + let result_txo = string_to_txo(txo_str).unwrap(); + assert_eq!(TXO {address:"pay:sov:iTQzpdRdugkJ2gLD5vW5c159dncSL9jbAtu3WfPcb8qWD9bUd".to_string(), seq_no: 1}, result_txo); + } + + #[test] + fn string_to_txo_fail_for_no_qualifier() { + let txo_str = "fkjZEd8eTBnYJsw7m7twMph3UYD7j2SoWcDM45DkmRx8eq2SkQnzxoLxyMT1RBAat9x86MwXNJH88Pxf9u7JsM5m8ApXn3bvgbtS5cegZzNp7WmMSpWL"; + assert!(string_to_txo(txo_str).is_err()); + } + + #[test] + fn string_to_txo_fail_for_invalid_txo() { + let txo_str = "txo:sov:fkjZEd8eTBnYJsw7m"; + assert!(string_to_txo(txo_str).is_err()); + } } diff --git a/libsovtoken/src/logic/api_internals/add_request_fees.rs b/libsovtoken/src/logic/api_internals/add_request_fees.rs index 42e42b36e..10f0351a0 100644 --- a/libsovtoken/src/logic/api_internals/add_request_fees.rs +++ b/libsovtoken/src/logic/api_internals/add_request_fees.rs @@ -243,21 +243,57 @@ mod test_deserialize_inputs { #[test] fn deserialize_inputs_invalid_inputs_json() { + // no `address` field let invalid_json = json_c_pointer!([ { - "addres": "pay:sov:d0kitWxupHvZ4i0NHJhoj79RcUeyt3YlwAc8Hbcy87iRLSZC", + "add": "pay:sov:d0kitWxupHvZ4i0NHJhoj79RcUeyt3YlwAc8Hbcy87iRLSZC", "seqNo": 4 } ]); error_deserialize_inputs_inputs(invalid_json, ErrorCode::CommonInvalidStructure); + + // negative `seqNo` + let invalid_json = json_c_pointer!([ + { + "address": "pay:sov:d0kitWxupHvZ4i0NHJhoj79RcUeyt3YlwAc8Hbcy87iRLSZC", + "seqNo": -4 + } + ]); + error_deserialize_inputs_inputs(invalid_json, ErrorCode::CommonInvalidStructure); + + // no `seqNo` field + let invalid_json = json_c_pointer!([ + { + "address": "pay:sov:d0kitWxupHvZ4i0NHJhoj79RcUeyt3YlwAc8Hbcy87iRLSZC" + } + ]); + error_deserialize_inputs_inputs(invalid_json, ErrorCode::CommonInvalidStructure); } #[test] fn deserialize_inputs_invalid_outputs_json() { + // no `address` field + let invalid_json = json_c_pointer!([ + { + "add": "pay:sov:ql33nBkjGw6szxPT6LLRUIejn9TZAYk", + "amount": 10 + } + ]); + error_deserialize_inputs_ouputs(invalid_json, ErrorCode::CommonInvalidStructure); + + // negative `amount` + let invalid_json = json_c_pointer!([ + { + "recipient": "pay:sov:ql33nBkjGw6szxPT6LLRUIejn9TZAYk", + "amount": -10 + } + ]); + error_deserialize_inputs_ouputs(invalid_json, ErrorCode::CommonInvalidStructure); + + // no `amount` field let invalid_json = json_c_pointer!([ { - "address": "pay:sov:ql33nBkjGw6szxPT6LLRUIejn9TZAYkVRPd0QJzfJ8FdhZWs", - "amount": "10" + "recipient": "pay:sov:ql33nBkjGw6szxPT6LLRUIejn9TZAYk", } ]); error_deserialize_inputs_ouputs(invalid_json, ErrorCode::CommonInvalidStructure); diff --git a/libsovtoken/src/logic/payments.rs b/libsovtoken/src/logic/payments.rs index 90c37512a..94cdf84fa 100644 --- a/libsovtoken/src/logic/payments.rs +++ b/libsovtoken/src/logic/payments.rs @@ -17,13 +17,13 @@ use logic::address; and in testing environments its anything else as long as it implements CryptoAPI */ -pub struct CreatePaymentHandler where T : CryptoAPI { - injected_api : T +pub struct CreatePaymentHandler where T: CryptoAPI { + injected_api: T } impl CreatePaymentHandler { - pub fn new(api_handler : T) -> Self { - CreatePaymentHandler { injected_api : api_handler } + pub fn new(api_handler: T) -> Self { + CreatePaymentHandler { injected_api: api_handler } } /** @@ -45,11 +45,11 @@ impl CreatePaymentHandler { pay:sov:{32 byte address}{4 byte checksum} */ pub fn create_payment_address_async(&self, - wallet_id: i32, - config: PaymentAddressConfig, - mut cb : F) -> ErrorCode where F: FnMut(String, ErrorCode) + Send { + wallet_id: i32, + config: PaymentAddressConfig, + mut cb: F) -> ErrorCode where F: FnMut(String, ErrorCode) + Send { - let cb_closure = move | err: ErrorCode, verkey : String | { + let cb_closure = move |err: ErrorCode, verkey: String| { let res = if ErrorCode::Success == err { trace!("got verkey from self.injected_api.indy_create_key_async {}", verkey); address::qualified_address_from_verkey(&verkey) @@ -82,11 +82,10 @@ impl CreatePaymentHandler { mod payments_tests { extern crate log; - use std::sync::mpsc::{channel}; + use std::sync::mpsc::channel; use std::time::Duration; use logic::address::*; use logic::address::address_tests::gen_random_base58_verkey; - use utils::random::rand_string; use utils::constants::general::PAYMENT_ADDRESS_QUALIFIER; use utils::base58::FromBase58; @@ -111,10 +110,9 @@ mod payments_tests { } - static VALID_SEED_LEN: usize = 32; static WALLET_ID: i32 = 10; - fn validate_address(address : String) { + fn validate_address(address: String) { // got our result, if its correct, it will look something like this: // pay:sov:gzidfrdJtvgUh4jZTtGvTZGU5ebuGMoNCbofXGazFa91234 // break it up into the individual parts we expect to find and @@ -131,54 +129,25 @@ mod payments_tests { // a fully formatted address is returned. #[test] fn success_create_payment_with_seed_returns_address() { - - let seed = rand_string(VALID_SEED_LEN); + let seed = "000000000000000000000000Address1".to_string(); let config: PaymentAddressConfig = PaymentAddressConfig { seed }; - let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler{}); - - let address = match handler.create_payment_address(WALLET_ID, config) { - Ok(s) => s, - Err(_) => "".to_string(), - }; - - // got our result, if its correct, it will look something like this: - // pay:sov:gzidfrdJtvgUh4jZTtGvTZGU5ebuGMoNCbofXGazFa91234 - // break it up into the individual parts we expect to find and - // test the validity of the parts - let qualifer = &address[..ADDRESS_QUAL_LEN]; - let result_address = &address[ADDRESS_QUAL_LEN..]; - - assert_eq!(PAYMENT_ADDRESS_QUALIFIER, qualifer, "PAYMENT_ADDRESS_QUALIFIER, not found"); - assert_eq!(VERKEY_LEN + ADDRESS_CHECKSUM_LEN, result_address.from_base58().unwrap().len(), "address is not 36 bytes"); - assert_eq!(VERKEY_LEN, result_address.from_base58_check().unwrap().len(), "verkey is not 32 bytes"); + let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler {}); + let address = handler.create_payment_address(WALLET_ID, config).unwrap(); + validate_address(address); } // This is the happy path test when seed provided is empty. Expectation is a // a fully formatted address is returned. #[test] fn success_create_payment_with_no_seed_returns_address() { - let seed = String::new(); let config: PaymentAddressConfig = PaymentAddressConfig { seed }; - let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler{}); - let address = match handler.create_payment_address(WALLET_ID, config){ - Ok(s) => s, - Err(_) => "".to_string(), - }; - - // got our result, if its correct, it will look something like this: - // pay:sov:gzidfrdJtvgUh4jZTtGvTZGU5ebuGMoNCbofXGazFa91234 - // break it up into the individual parts we expect to find and - // test the validity of the parts - let qualifer = &address[..ADDRESS_QUAL_LEN]; - let result_address = &address[ADDRESS_QUAL_LEN..]; - - assert_eq!(PAYMENT_ADDRESS_QUALIFIER, qualifer, "PAYMENT_ADDRESS_QUALIFIER, not found"); - assert_eq!(VERKEY_LEN + ADDRESS_CHECKSUM_LEN, result_address.from_base58().unwrap().len(), "address is not 36 bytes"); - assert_eq!(VERKEY_LEN, result_address.from_base58_check().unwrap().len(), "verkey is not 32 bytes"); + let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler {}); + let address = handler.create_payment_address(WALLET_ID, config).unwrap(); + validate_address(address); } // Happy path test assumes the CB is valid and it is successfully called @@ -187,11 +156,11 @@ mod payments_tests { let seed = String::new(); let config: PaymentAddressConfig = PaymentAddressConfig { seed }; - let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler{}); + let handler = CreatePaymentHandler::new(CreatePaymentSDKMockHandler {}); let (sender, receiver) = channel(); - let cb_closure = move | address : String, err: ErrorCode | { + let cb_closure = move |address: String, err: ErrorCode| { if err != ErrorCode::Success { sender.send(false).unwrap(); diff --git a/libsovtoken/tests/add_fees_for_attrib_test.rs b/libsovtoken/tests/add_fees_for_attrib_test.rs index 3efece2a8..423470a5f 100644 --- a/libsovtoken/tests/add_fees_for_attrib_test.rs +++ b/libsovtoken/tests/add_fees_for_attrib_test.rs @@ -48,6 +48,8 @@ pub fn build_and_submit_attrib_with_fees() { assert_eq!(parsed_utxos[0].amount, 9); assert_eq!(parsed_utxos[0].recipient, addresses[0]); + std::thread::sleep(std::time::Duration::from_millis(100)); + let get_attrib_resp = send_get_attrib_req(&wallet, pool_handle, dids[0], dids[0], Some("endpoint")); let data = get_data_from_attrib_reply(get_attrib_resp); assert_eq!(ATTRIB_RAW_DATA, data); @@ -79,6 +81,8 @@ pub fn build_and_submit_attrib_with_fees_and_no_change() { let parsed_utxos: Vec = serde_json::from_str(&parsed_resp).unwrap(); assert_eq!(parsed_utxos.len(), 0); + std::thread::sleep(std::time::Duration::from_millis(100)); + let get_attrib_resp = send_get_attrib_req(&wallet, pool_handle, dids[0], dids[0], Some("endpoint")); let data = get_data_from_attrib_reply(get_attrib_resp); assert_eq!(ATTRIB_RAW_DATA_2, data); @@ -185,6 +189,8 @@ pub fn build_and_submit_attrib_with_fees_double_spend() { assert_eq!(parsed_utxos[0].amount, 9); assert_eq!(parsed_utxos[0].recipient, addresses[0]); + std::thread::sleep(std::time::Duration::from_millis(100)); + let get_attrib_resp = send_get_attrib_req(&wallet, pool_handle, dids[0], dids[0], Some("endpoint")); let data = get_data_from_attrib_reply(get_attrib_resp); assert_eq!(ATTRIB_RAW_DATA, data); diff --git a/libsovtoken/tests/build_add_fees_txn_handler_test.rs b/libsovtoken/tests/add_request_fees_handler_test.rs similarity index 58% rename from libsovtoken/tests/build_add_fees_txn_handler_test.rs rename to libsovtoken/tests/add_request_fees_handler_test.rs index 2cc7fe451..7e1192f1d 100644 --- a/libsovtoken/tests/build_add_fees_txn_handler_test.rs +++ b/libsovtoken/tests/add_request_fees_handler_test.rs @@ -5,8 +5,6 @@ extern crate serde_derive; extern crate sovtoken; extern crate indyrs as indy; -use indy::future::Future; - pub mod utils; use sovtoken::utils::results::ResultHandler; @@ -18,7 +16,7 @@ use sovtoken::{ErrorCode, IndyHandle}; use utils::wallet::Wallet; -fn call_add_fees(wallet_handle: IndyHandle, inputs: String, outputs: String, extra: Option, request: String) -> Result { +fn call_add_request_fees(wallet_handle: IndyHandle, inputs: String, outputs: String, extra: Option, request: String) -> Result { let (receiver, command_handle, cb) = callbacks::cb_ec_string(); let did = "mydid1"; @@ -87,7 +85,7 @@ fn test_add_fees_to_request_valid() { } }); - let result = call_add_fees( + let result = call_add_request_fees( wallet.handle, inputs.to_string(), outputs.to_string(), @@ -98,16 +96,11 @@ fn test_add_fees_to_request_valid() { assert_eq!(expected_fees_request.to_string(), result); } -#[test] // TODO: look carefully on changes -fn test_add_fees_to_request_valid_from_libindy() { +#[test] +fn test_add_fees_to_request_works_for_invalid_request() { let (wallet, input_address) = init_wallet_with_address(); - let did = "Th7MpTaRZVRYnPiabds81Y"; - let fake_request = json!({ - "operation": { - "type": "3" - } - }); + let fake_request = "INVALID REQUEST"; let txo = TXO { address: input_address, seq_no: 1 }; @@ -118,95 +111,102 @@ fn test_add_fees_to_request_valid_from_libindy() { "amount": 20, }]); - let expected_fees_request = json!({ - "fees": [ - [ - { - "address": "iTQzpdRdugkJ2gLD5vW5c159dncSL9jbAtu3WfPcb8qWD9bUd", - "seqNo": 1 - } - ], - [ - { - "address": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "amount": 20 - } - ], - ["64wPLDPMjGxgqTdrNTZFa9CK4NtvBx7eLJkgnjW3JchRGyMUr29tjkAiHCTnhLtkdW81k5BtBiiqM2tkaMB2eouv"] - ], - "operation": { - "type": "3" - } - }); + let err = call_add_request_fees( + wallet.handle, + inputs.to_string(), + outputs.to_string(), + None, + fake_request.to_string() + ).unwrap_err(); + + assert_eq!(err, ErrorCode::CommonInvalidStructure) +} + +#[test] +fn build_add_fees_to_request_works_for_invalid_utxo() { + sovtoken::api::sovtoken_init(); + let wallet = Wallet::new(); - let (req, method) = indy::payments::add_request_fees( + let fake_request = json!({ + "operation": { + "type": "3" + } + }).to_string(); + + let inputs = json!(["txo:sov:1234"]).to_string(); + + let outputs = json!([{ + "recipient": "pay:sov:dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", + "amount": 20, + }]).to_string(); + + let err = call_add_request_fees( wallet.handle, - Some(did), - &fake_request.to_string(), - &inputs.to_string(), - &outputs.to_string(), + inputs.to_string(), + outputs.to_string(), None, - ).wait().unwrap(); + fake_request.to_string() + ).unwrap_err(); - assert_eq!("sov", method); - assert_eq!(expected_fees_request.to_string(), req); + assert_eq!(err, ErrorCode::CommonInvalidStructure) } #[test] -fn test_add_fees_to_request_valid_from_libindy_for_not_owned_payment_address() { - let wallet_1 = utils::wallet::Wallet::new(); - let wallet_2 = utils::wallet::Wallet::new(); - - let setup = utils::setup::Setup::new(&wallet_1, utils::setup::SetupConfig { - num_addresses: 1, - num_trustees: 4, - num_users: 0, - mint_tokens: Some(vec![30]), - fees: None, - }); - let addresses = &setup.addresses; - let pool_handle = setup.pool_handle; - let dids = setup.trustees.dids(); +fn test_add_fees_to_request_works_for_invalid_receipt() { + let (wallet, input_address) = init_wallet_with_address(); let fake_request = json!({ - "operation": { - "type": "3" - } + "operation": { + "type": "3" + } }); - let utxo = utils::payment::get_utxo::get_first_utxo_txo_for_payment_address(&wallet_1, pool_handle, dids[0], &addresses[0]); + let txo = TXO { address: input_address, seq_no: 1 }; - let inputs = json!([utxo]); + let inputs = json!([txo.to_libindy_string().unwrap()]); let outputs = json!([{ - "recipient": addresses[0], + "recipient": "pay:sov:1234", "amount": 20, }]); - let err = indy::payments::add_request_fees(wallet_2.handle, Some(dids[0]), &fake_request.to_string(), &inputs.to_string(), &outputs.to_string(), None).wait().unwrap_err(); - assert_eq!(err.error_code, ErrorCode::WalletItemNotFound); + let err = call_add_request_fees( + wallet.handle, + inputs.to_string(), + outputs.to_string(), + None, + fake_request.to_string() + ).unwrap_err(); + + assert_eq!(err, ErrorCode::CommonInvalidStructure) } #[test] -fn build_add_fees_to_request_works_for_invalid_utxo() { - sovtoken::api::sovtoken_init(); - let wallet = Wallet::new(); - let (did, _) = indy::did::create_and_store_my_did(wallet.handle, &json!({"seed": "000000000000000000000000Trustee1"}).to_string()).wait().unwrap(); +fn test_add_fees_to_request_works_for_invalid_amount() { + let (wallet, input_address) = init_wallet_with_address(); let fake_request = json!({ "operation": { "type": "3" } - }).to_string(); + }); - let inputs = json!(["txo:sov:1234"]).to_string(); + let txo = TXO { address: input_address, seq_no: 1 }; + + let inputs = json!([txo.to_libindy_string().unwrap()]); let outputs = json!([{ - "recipient": "pay:sov:dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "amount": 20, - }]).to_string(); + "recipient": "pay:sov:1234", + "amount": -20, + }]); - let err = indy::payments::add_request_fees(wallet.handle, Some(&did), &fake_request, &inputs, &outputs, None).wait().unwrap_err(); + let err = call_add_request_fees( + wallet.handle, + inputs.to_string(), + outputs.to_string(), + None, + fake_request.to_string() + ).unwrap_err(); - assert_eq!(err.error_code, ErrorCode::CommonInvalidStructure) + assert_eq!(err, ErrorCode::CommonInvalidStructure) } \ No newline at end of file diff --git a/libsovtoken/tests/build_fees_txn_handler_test.rs b/libsovtoken/tests/build_fees_txn_handler_test.rs index e074c8a92..fff3ee655 100644 --- a/libsovtoken/tests/build_fees_txn_handler_test.rs +++ b/libsovtoken/tests/build_fees_txn_handler_test.rs @@ -1,5 +1,7 @@ -#[macro_use] extern crate serde_json; -#[macro_use] extern crate serde_derive; +#[macro_use] +extern crate serde_json; +#[macro_use] +extern crate serde_derive; extern crate libc; extern crate sovtoken; extern crate indyrs as indy; // lib-sdk project @@ -9,61 +11,96 @@ extern crate bs58; use libc::c_char; use std::ffi::CString; use std::ptr; -use std::sync::mpsc::{Receiver}; -use std::time::Duration; + +use indy::future::Future; use sovtoken::ErrorCode; +use sovtoken::logic::request::Request; +use sovtoken::logic::config::set_fees_config::SetFees; use sovtoken::utils::ffi_support; use sovtoken::utils::test::callbacks; +use sovtoken::utils::results::ResultHandler; + +mod utils; -pub mod utils; -use utils::payment::fees; use utils::setup::{Setup, SetupConfig}; use utils::wallet::Wallet; // ***** HELPER METHODS ***** -extern "C" fn empty_create_payment_callback(_command_handle: i32, _err: i32, _mint_req_json: *const c_char) -> i32 { - return ErrorCode::Success as i32; +fn build_set_fees(wallet_handle: i32, did: Option<&str>, fees_json: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let did = did.map(ffi_support::c_pointer_from_str).unwrap_or(std::ptr::null()); + let fees = ffi_support::c_pointer_from_str(fees_json); + + let ec = sovtoken::api::build_set_txn_fees_handler(command_handle, wallet_handle, did, fees, cb); + + return ResultHandler::one(ErrorCode::from(ec), receiver); } -// ***** HELPER TEST DATA ***** +fn build_get_fees(wallet_handle: i32, did: Option<&str>) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); -const COMMAND_HANDLE:i32 = 10; -const WALLET_ID:i32 = 10; -static INVALID_OUTPUT_JSON: &'static str = r#"{"totally" : "Not a Number", "bobby" : "DROP ALL TABLES"}"#; -const CB : Option i32 > = Some(empty_create_payment_callback); -static FAKE_DID : &'static str = "Enfru5LNlA2CnA5n4Hfze"; + let did = did.map(ffi_support::c_pointer_from_str).unwrap_or(std::ptr::null()); + + let ec = sovtoken::api::build_get_txn_fees_handler(command_handle, wallet_handle, did, cb); + return ResultHandler::one(ErrorCode::from(ec), receiver); +} -fn call_set_fees(did: &str, fees_json: serde_json::value::Value) -> (ErrorCode, Receiver<(ErrorCode, String)>) { +fn parse_get_txn_fees_response(response: &str) -> Result { let (receiver, command_handle, cb) = callbacks::cb_ec_string(); - let did_pointer = ffi_support::c_pointer_from_str(did); - let fees_pointer = ffi_support::c_pointer_from_string(fees_json.to_string()); + let response_pointer = ffi_support::c_pointer_from_str(response); + + let ec = sovtoken::api::parse_get_txn_fees_response_handler(command_handle, response_pointer, cb); + + return ResultHandler::one(ErrorCode::from(ec), receiver); +} + +pub fn set_fees(pool_handle: i32, wallet_handle: i32, fees: &str, dids: &Vec<&str>, submitter_did: Option<&str>) -> String { + let set_fees_req = build_set_fees(wallet_handle, submitter_did, &fees).unwrap(); - let ec = sovtoken::api::build_set_txn_fees_handler(command_handle, WALLET_ID, did_pointer, fees_pointer, cb); + let set_fees_req = Request::::multi_sign_request(wallet_handle, &set_fees_req, dids.to_vec()).unwrap(); - return (ErrorCode::from(ec), receiver); + indy::ledger::submit_request(pool_handle, &set_fees_req).wait().unwrap() } +pub fn get_fees(wallet: &Wallet, pool_handle: i32, submitter_did: Option<&str>) -> String { + let get_fees_req = build_get_fees( + wallet.handle, + submitter_did, + ).unwrap(); + let result = indy::ledger::submit_request(pool_handle, &get_fees_req).wait().unwrap(); + parse_get_txn_fees_response(&result).unwrap() +} + +// ***** HELPER TEST DATA ***** +const COMMAND_HANDLE: i32 = 10; +const WALLET_ID: i32 = 10; +static INVALID_OUTPUT_JSON: &'static str = r#"{"totally" : "Not a Number", "bobby" : "DROP ALL TABLES"}"#; +const CB: Option i32> = Some(utils::callbacks::empty_callback); +static FAKE_DID: &'static str = "Enfru5LNlA2CnA5n4Hfze"; + + // the build_fees_txn_handler requires a callback and this test ensures that we // receive an error when no callback is provided #[test] -fn errors_with_no_call_back() { - let return_error = sovtoken::api::build_set_txn_fees_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(),ptr::null(), None); +fn add_fees_errors_with_no_call_back() { + let return_error = sovtoken::api::build_set_txn_fees_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), ptr::null(), None); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting Callback for 'build_fees_txn_handler'"); } // the build fees txn handler method requires an outputs_json parameter and this test ensures that // a error is returned when no config is provided #[test] -fn errors_with_no_fees_json() { - let return_error = sovtoken::api::build_set_txn_fees_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(),ptr::null(), CB); +fn add_fees_errors_with_no_fees_json() { + let return_error = sovtoken::api::build_set_txn_fees_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), ptr::null(), CB); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting outputs_json for 'build_fees_txn_handler'"); } #[test] -fn errors_with_invalid_fees_json() { +fn add_fees_errors_with_invalid_fees_json() { let fees_str = CString::new(INVALID_OUTPUT_JSON).unwrap(); let fees_str_ptr = fees_str.as_ptr(); let return_error = sovtoken::api::build_set_txn_fees_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), fees_str_ptr, CB); @@ -71,22 +108,26 @@ fn errors_with_invalid_fees_json() { } #[test] -fn add_fees_invalid_json_key() { +fn add_fees_invalid_did() { let fees = json!({ "1000": 4, - "XFER_PUBLIC": 13, - }); + "20001": 13, + }).to_string(); - let (ec, receiver) = call_set_fees(FAKE_DID, fees); - let received = receiver.recv_timeout(Duration::from_millis(300)); + let err = build_set_fees(WALLET_ID, Some(FAKE_DID), &fees).unwrap_err(); + assert_eq!(ErrorCode::CommonInvalidStructure, err); +} - assert_eq!(ErrorCode::CommonInvalidStructure, ec); - assert!(received.is_err()); +#[test] +fn add_fees_invalid_fees() { + let fees = "1000"; + let did = bs58::encode("1234567890123456").into_string(); + let err = build_set_fees(WALLET_ID, Some(&did), fees).unwrap_err(); + assert_eq!(ErrorCode::CommonInvalidStructure, err); } #[test] fn add_fees_json() { - sovtoken::api::sovtoken_init(); let fees = json!({ "3": 6, "20001": 12 @@ -97,21 +138,35 @@ fn add_fees_json() { }); let did = bs58::encode("1234567890123456").into_string(); - let (ec_initial, receiver) = call_set_fees(&did, fees); - let (ec_callback, fees_request) = receiver.recv().unwrap(); + let fees_request = build_set_fees(WALLET_ID, Some(&did), &fees.to_string()).unwrap(); let request_value: serde_json::value::Value = serde_json::from_str(&fees_request).unwrap(); - assert_eq!(ErrorCode::Success, ec_initial); - assert_eq!(ErrorCode::Success, ec_callback); assert_eq!(&expected_operation, request_value.get("operation").unwrap()); } +#[test] +fn build_get_fees_req() { + let expected_operation = json!({ + "type": "20001", + }); + + let did = bs58::encode("1234567890123456").into_string(); + let get_fees_request = build_get_fees(WALLET_ID, Some(&did)).unwrap(); + + let request_value: serde_json::value::Value = serde_json::from_str(&get_fees_request).unwrap(); + + assert_eq!(&expected_operation, request_value.get("operation").unwrap()); +} +#[test] +fn build_get_fees_error_with_invalid_did() { + let err = build_get_fees(WALLET_ID, Some(FAKE_DID)).unwrap_err(); + assert_eq!(ErrorCode::CommonInvalidStructure, err); +} #[test] pub fn build_and_submit_set_fees() { - let payment_method = sovtoken::utils::constants::general::PAYMENT_METHOD_NAME; let wallet = Wallet::new(); let setup = Setup::new(&wallet, SetupConfig { num_addresses: 0, @@ -128,8 +183,8 @@ pub fn build_and_submit_set_fees() { "101": 2 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, Some(dids[0])); - let current_fees = fees::get_fees(&wallet, pool_handle, Some(dids[0])); + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); + let current_fees = get_fees(&wallet, pool_handle, Some(dids[0])); let current_fees_value: serde_json::Value = serde_json::from_str(¤t_fees).unwrap(); assert_eq!(current_fees_value["101"].as_u64().unwrap(), 2); @@ -140,14 +195,12 @@ pub fn build_and_submit_set_fees() { "101": 0 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, Some(dids[0])); - + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); } #[test] pub fn build_and_submit_set_fees_with_names() { - let payment_method = sovtoken::utils::constants::general::PAYMENT_METHOD_NAME; let wallet = Wallet::new(); let setup = Setup::new(&wallet, SetupConfig { num_addresses: 0, @@ -164,8 +217,8 @@ pub fn build_and_submit_set_fees_with_names() { "ATTRIB": 2 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, Some(dids[0])); - let current_fees = fees::get_fees(&wallet, pool_handle, Some(dids[0])); + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); + let current_fees = get_fees(&wallet, pool_handle, Some(dids[0])); let current_fees_value: serde_json::Value = serde_json::from_str(¤t_fees).unwrap(); assert_eq!(current_fees_value["1"].as_u64().unwrap(), 1); @@ -176,13 +229,11 @@ pub fn build_and_submit_set_fees_with_names() { "ATTRIB": 0 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, Some(dids[0])); - + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); } #[test] pub fn build_and_submit_set_fees_with_empty_did() { - let payment_method = sovtoken::utils::constants::general::PAYMENT_METHOD_NAME; let wallet = Wallet::new(); let setup = Setup::new(&wallet, SetupConfig { num_addresses: 0, @@ -199,8 +250,8 @@ pub fn build_and_submit_set_fees_with_empty_did() { "ATTRIB": 2 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, None); - let current_fees = fees::get_fees(&wallet, pool_handle, None); + set_fees(pool_handle, wallet.handle, &fees, &dids, None); + let current_fees = get_fees(&wallet, pool_handle, None); let current_fees_value: serde_json::Value = serde_json::from_str(¤t_fees).unwrap(); assert_eq!(current_fees_value["1"].as_u64().unwrap(), 1); @@ -211,6 +262,5 @@ pub fn build_and_submit_set_fees_with_empty_did() { "ATTRIB": 0 }).to_string(); - fees::set_fees(pool_handle, wallet.handle, &payment_method, &fees, &dids, None); - + set_fees(pool_handle, wallet.handle, &fees, &dids, None); } \ No newline at end of file diff --git a/libsovtoken/tests/build_get_utxo_request_handler_test.rs b/libsovtoken/tests/build_get_utxo_request_handler_test.rs index d0870330f..d0517fc39 100644 --- a/libsovtoken/tests/build_get_utxo_request_handler_test.rs +++ b/libsovtoken/tests/build_get_utxo_request_handler_test.rs @@ -1,16 +1,92 @@ -#[macro_use] extern crate serde_json; -#[macro_use] extern crate serde_derive; +#[macro_use] +extern crate serde_json; +#[macro_use] +extern crate serde_derive; extern crate sovtoken; extern crate indyrs as indy; +extern crate libc; +extern crate bs58; + +use libc::c_char; +use std::ptr; use indy::future::Future; -mod utils; +pub mod utils; + use utils::wallet::Wallet; use utils::setup::{Setup, SetupConfig}; use sovtoken::logic::address::strip_qualifier_from_address; use sovtoken::logic::address::verkey_from_unqualified_address; +use sovtoken::utils::results::ResultHandler; +use sovtoken::utils::test::callbacks; +use sovtoken::utils::ffi_support::c_pointer_from_str; +use sovtoken::{ErrorCode, IndyHandle}; + +// ***** HELPER METHODS ***** +fn build_get_payment_sources_request(wallet_handle: IndyHandle, did: &str, payment_address: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let error_code = sovtoken::api::build_get_utxo_request_handler( + command_handle, + wallet_handle, + c_pointer_from_str(did), + c_pointer_from_str(payment_address), + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} + +fn parse_get_payment_sources_response(res: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let error_code = sovtoken::api::parse_get_utxo_response_handler( + command_handle, + c_pointer_from_str(res), + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} + +// ***** HELPER TEST DATA ***** +const COMMAND_HANDLE: i32 = 10; +const WALLET_ID: i32 = 10; +const CB: Option i32> = Some(utils::callbacks::empty_callback); +const ADDRESS: &str = "pay:sov:dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q"; + +// the build_fees_txn_handler requires a callback and this test ensures that we +// receive an error when no callback is provided +#[test] +fn get_utxo_errors_with_no_call_back() { + let return_error = sovtoken::api::build_get_utxo_request_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), ptr::null(), None); + assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting Callback for 'build_get_utxo_request_handler'"); +} + +// the build fees txn handler method requires an outputs_json parameter and this test ensures that +// a error is returned when no config is provided +#[test] +fn get_utxo_errors_with_no_payment_address() { + let return_error = sovtoken::api::build_get_utxo_request_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), ptr::null(), CB); + assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting outputs_json for 'build_fees_txn_handler'"); +} + +#[test] +fn build_get_utxo_json() { + let did = bs58::encode("1234567890123456").into_string(); + let expected_operation = json!({ + "type": "10002", + "address": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q" + }); + + let request = build_get_payment_sources_request(WALLET_ID, &did, &ADDRESS).unwrap(); + + let request_value: serde_json::value::Value = serde_json::from_str(&request).unwrap(); + + assert_eq!(&expected_operation, request_value.get("operation").unwrap()); +} #[test] pub fn build_and_submit_get_utxo_request() { @@ -26,9 +102,9 @@ pub fn build_and_submit_get_utxo_request() { let pool_handle = setup.pool_handle; let dids = setup.trustees.dids(); - let (get_utxo_req, payment_method) = indy::payments::build_get_payment_sources_request(wallet.handle, Some(dids[0]), &payment_addresses[0]).wait().unwrap(); + let get_utxo_req = build_get_payment_sources_request(wallet.handle, dids[0], &payment_addresses[0]).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_get_payment_sources_response(&payment_method, &res).wait().unwrap(); + let res = parse_get_payment_sources_response(&res).unwrap(); let res_parsed: Vec = serde_json::from_str(&res).unwrap(); assert_eq!(res_parsed.len(), 1); @@ -51,9 +127,9 @@ pub fn build_and_submit_get_utxo_request_no_utxo() { let pool_handle = setup.pool_handle; let dids = setup.trustees.dids(); - let (get_utxo_req, payment_method) = indy::payments::build_get_payment_sources_request(wallet.handle, Some(dids[0]), &payment_addresses[0]).wait().unwrap(); + let get_utxo_req = build_get_payment_sources_request(wallet.handle, dids[0], &payment_addresses[0]).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_get_payment_sources_response(&payment_method, &res).wait().unwrap(); + let res = parse_get_payment_sources_response(&res).unwrap(); let res_parsed: Vec = serde_json::from_str(&res).unwrap(); assert_eq!(res_parsed.len(), 0); @@ -72,8 +148,8 @@ pub fn payment_address_is_identifier() { let payment_addresses = &setup.addresses; let dids = setup.trustees.dids(); - let (get_utxo_req, _) = indy::payments::build_get_payment_sources_request(wallet.handle, Some(dids[0]), &payment_addresses[0]).wait().unwrap(); - let req : serde_json::Value = serde_json::from_str(&get_utxo_req).unwrap(); + let get_utxo_req = build_get_payment_sources_request(wallet.handle, dids[0], &payment_addresses[0]).unwrap(); + let req: serde_json::Value = serde_json::from_str(&get_utxo_req).unwrap(); let identifier = req.as_object().unwrap().get("identifier").unwrap().as_str().unwrap(); let unqualified_addr = strip_qualifier_from_address(&payment_addresses[0]); let unqualified_addr = verkey_from_unqualified_address(&unqualified_addr).unwrap(); diff --git a/libsovtoken/tests/build_mint_txn_handler_test.rs b/libsovtoken/tests/build_mint_txn_handler_test.rs index 326b2a93b..3112e5c2e 100644 --- a/libsovtoken/tests/build_mint_txn_handler_test.rs +++ b/libsovtoken/tests/build_mint_txn_handler_test.rs @@ -15,7 +15,7 @@ use std::ffi::CString; use indy::future::Future; -use sovtoken::ErrorCode; +use sovtoken::{ErrorCode, IndyHandle}; use sovtoken::utils::ffi_support::{str_from_char_ptr, c_pointer_from_str}; use sovtoken::utils::constants::txn_types::MINT_PUBLIC; use sovtoken::utils::constants::txn_fields::OUTPUTS; @@ -23,6 +23,8 @@ use sovtoken::logic::parsers::common::ResponseOperations; use sovtoken::utils::json_conversion::JsonDeserialize; use sovtoken::logic::config::output_mint_config::MintRequest; use sovtoken::logic::request::Request; +use sovtoken::utils::results::ResultHandler; +use sovtoken::utils::test::callbacks; mod utils; @@ -31,10 +33,27 @@ use utils::parse_mint_response::ParseMintResponse; use utils::setup::{Setup, SetupConfig}; // ***** HELPER METHODS ***** +fn build_mint_req(wallet_handle: IndyHandle, did: Option<&str>, outputs: &str, extra: Option<&str>) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let did = did.map(c_pointer_from_str).unwrap_or(std::ptr::null()); + let extra = extra.map(c_pointer_from_str).unwrap_or(std::ptr::null()); + + let error_code = sovtoken::api::build_mint_txn_handler( + command_handle, + wallet_handle, + did, + c_pointer_from_str(outputs), + extra, + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} // ***** HELPER TEST DATA ***** -const COMMAND_HANDLE:i32 = 10; +const COMMAND_HANDLE: i32 = 10; static INVALID_OUTPUT_JSON: &'static str = r#"{"totally" : "Not a Number", "bobby" : "DROP ALL TABLES"}"#; static VALID_OUTPUT_JSON: &'static str = r#"[{"recipient":"pay:sov:dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", "amount":10}]"#; @@ -61,7 +80,7 @@ fn errors_with_no_outputs_json() { let return_error = sovtoken::api::build_mint_txn_handler(COMMAND_HANDLE, 1, ptr::null(), ptr::null(), ptr::null(), Some(cb_no_json)); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting outputs_json for 'build_mint_txn_handler'"); - unsafe { assert!(! CALLBACK_CALLED) } + unsafe { assert!(!CALLBACK_CALLED) } } // // the mint txn handler method requires a valid JSON format (format is described @@ -79,11 +98,11 @@ fn errors_with_invalid_outputs_json() { let outputs_str_ptr = outputs_str.as_ptr(); let return_error = sovtoken::api::build_mint_txn_handler(COMMAND_HANDLE, 1, ptr::null(), outputs_str_ptr, ptr::null(), Some(cb_invalid_json)); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting Valid JSON for 'build_mint_txn_handler'"); - unsafe { assert!(! CALLBACK_CALLED) } + unsafe { assert!(!CALLBACK_CALLED) } } #[test] -fn valid_output_json() { +fn valid_output_json() { sovtoken::api::sovtoken_init(); static mut CALLBACK_CALLED: bool = false; extern "C" fn valid_output_json_cb(command_handle: i32, error_code: i32, mint_request: *const c_char) -> i32 { @@ -91,7 +110,7 @@ fn valid_output_json() { assert_eq!(command_handle, COMMAND_HANDLE); assert_eq!(error_code, ErrorCode::Success as i32); let mint_request_json_string = str_from_char_ptr(mint_request).unwrap(); - let mint_request_json_value : serde_json::Value = serde_json::from_str(mint_request_json_string).unwrap(); + let mint_request_json_value: serde_json::Value = serde_json::from_str(mint_request_json_string).unwrap(); let mint_operation = mint_request_json_value .get("operation") .unwrap(); @@ -120,47 +139,13 @@ fn valid_output_json() { ptr::null(), Some(valid_output_json_cb) ); - + assert_eq!(return_error, ErrorCode::Success as i32, "Expecting Valid JSON for 'build_mint_txn_handler'"); unsafe { assert!(CALLBACK_CALLED); } } -#[test] // TODO: look carefully on changes -fn valid_output_json_from_libindy() { - sovtoken::api::sovtoken_init(); - let did = "Th7MpTaRZVRYnPiabds81Y"; - let wallet = Wallet::new(); - let outputs_str = VALID_OUTPUT_JSON; - - let (req, payment_method) = indy::payments::build_mint_req( - wallet.handle, - Some(did), - outputs_str, - None, - ).wait().unwrap(); - - let mint_request_json_value : serde_json::Value = serde_json::from_str(&req).unwrap(); - let mint_operation = mint_request_json_value - .get("operation") - .unwrap(); - - let expected = json!({ - "type": MINT_PUBLIC, - OUTPUTS: [ - { - "address": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "amount": 10 - } - ] - }); - - - assert_eq!("sov", payment_method); - assert_eq!(mint_operation, &expected); -} - #[test] pub fn build_and_submit_mint_txn_works() { let wallet = Wallet::new(); @@ -191,12 +176,12 @@ pub fn build_and_submit_mint_txn_works() { } ]).to_string(); - let (mint_req, _) = indy::payments::build_mint_req( + let mint_req = build_mint_req( wallet.handle, Some(dids[0]), &output_json, None, - ).wait().unwrap(); + ).unwrap(); trace!("{:?}", &mint_req); @@ -246,12 +231,12 @@ pub fn build_and_submit_mint_txn_works_with_empty_did() { } ]).to_string(); - let (mint_req, _) = indy::payments::build_mint_req( + let mint_req = build_mint_req( wallet.handle, None, &output_json, None, - ).wait().unwrap(); + ).unwrap(); trace!("{:?}", &mint_req); @@ -301,12 +286,12 @@ pub fn build_and_submit_mint_txn_works_for_double_send_mint() { } ]).to_string(); - let (mint_req, _) = indy::payments::build_mint_req( + let mint_req = build_mint_req( wallet.handle, Some(dids[0]), &output_json, None - ).wait().unwrap(); + ).unwrap(); trace!("{:?}", &mint_req); @@ -353,12 +338,12 @@ fn mint_10_billion_tokens() { "amount": tokens, }]).to_string(); - let (mint_req, _) = indy::payments::build_mint_req( + let mint_req = build_mint_req( wallet.handle, Some(dids[0]), &output_json, None - ).wait().unwrap(); + ).unwrap(); trace!("{:?}", &mint_req); diff --git a/libsovtoken/tests/build_payment_req_handler_test.rs b/libsovtoken/tests/build_payment_req_handler_test.rs index 434cbd6f9..1571f16ce 100644 --- a/libsovtoken/tests/build_payment_req_handler_test.rs +++ b/libsovtoken/tests/build_payment_req_handler_test.rs @@ -15,10 +15,10 @@ use indy::future::Future; use sovtoken::logic::address; use sovtoken::logic::parsers::common::TXO; -use sovtoken::ErrorCode; +use sovtoken::{ErrorCode, IndyHandle}; use sovtoken::utils::constants::txn_types::XFER_PUBLIC; use sovtoken::utils::results::ResultHandler; -use sovtoken::utils::ffi_support::c_pointer_from_string; +use sovtoken::utils::ffi_support::{c_pointer_from_string, c_pointer_from_str}; use sovtoken::utils::test::callbacks; mod utils; @@ -26,19 +26,44 @@ use utils::wallet::Wallet; use utils::setup::{SetupConfig, Setup}; -// ***** HELPER METHODS ***** -extern "C" fn empty_create_payment_callback(_command_handle_: i32, _err: i32, _payment_req: *const c_char) -> i32 { - return ErrorCode::Success as i32; -} - // ***** HELPER TEST DATA ***** const COMMAND_HANDLE:i32 = 10; static INVALID_OUTPUT_JSON: &'static str = r#"{"totally" : "Not a Number", "bobby" : "DROP ALL TABLES"}"#; static VALID_OUTPUT_JSON: &'static str = r#"{"outputs":[["AesjahdahudgaiuNotARealAKeyygigfuigraiudgfasfhja",10]]}"#; const WALLET_HANDLE:i32 = 0; -const CB : Option i32 > = Some(empty_create_payment_callback); +const CB : Option i32 > = Some(utils::callbacks::empty_callback); +// ***** HELPER METHODS ***** +fn build_payment_req(wallet_handle: IndyHandle, did: &str, inputs: &str, outputs: &str, extra: Option) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let extra = extra.map(c_pointer_from_string).unwrap_or(std::ptr::null()); + + let error_code = sovtoken::api::build_payment_req_handler( + command_handle, + wallet_handle, + c_pointer_from_str(did), + c_pointer_from_str(inputs), + c_pointer_from_str(outputs), + extra, + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} + +fn parse_payment_response(response: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let error_code = sovtoken::api::parse_payment_response_handler( + command_handle, + c_pointer_from_str(response), + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} fn generate_payment_addresses(wallet: &Wallet) -> (Vec, Vec) { let seeds = vec![ @@ -64,11 +89,10 @@ fn generate_payment_addresses(wallet: &Wallet) -> (Vec, Vec) { } fn get_resp_for_payment_req(pool_handle: i32, wallet_handle: i32, did: &str, - inputs: &str, outputs: &str) -> Result { - let (req, method) = indy::payments::build_payment_req(wallet_handle, - Some(did), inputs, outputs, None).wait().unwrap(); + inputs: &str, outputs: &str) -> Result { + let req = build_payment_req(wallet_handle, did, inputs, outputs, None).unwrap(); let res = indy::ledger::submit_request(pool_handle, &req).wait().unwrap(); - indy::payments::parse_payment_response(&method, &res).wait() + parse_payment_response(&res) } // ***** UNIT TESTS **** @@ -180,89 +204,15 @@ fn success_signed_request() { ] }); - let (receiver, command_handle, cb) = callbacks::cb_ec_string(); - trace!("Calling build_payment_req"); - let error_code = sovtoken::api::build_payment_req_handler( - command_handle, + let request_string = build_payment_req( wallet.handle, - c_pointer_from_string(did), - c_pointer_from_string(inputs.to_string()), - c_pointer_from_string(outputs.to_string()), - ptr::null(), - cb - ); - - assert_eq!(ErrorCode::from(error_code), ErrorCode::Success); - - let request_string = ResultHandler::one(ErrorCode::Success, receiver).unwrap(); - - let request: serde_json::value::Value = serde_json::from_str(&request_string).unwrap(); - debug!("Received request {:?}", request); - - assert_eq!(&expected_operation, request.get("operation").unwrap()); - let ident = bs58::decode(&addresses[0]).with_check(None).into_vec().unwrap(); - let ident = bs58::encode(ident).into_string(); - assert_eq!(&ident, request.get("identifier").unwrap().as_str().unwrap()); - assert!(request.get("reqId").is_some()); -} - -#[test] // TODO: look carefully on changes -fn success_signed_request_from_libindy() { - - sovtoken::api::sovtoken_init(); - - let did = String::from("Th7MpTaRZVRYnPiabds81Y"); - - let wallet = Wallet::new(); - debug!("wallet id = {:?}", wallet.handle); - - let (payment_addresses, addresses) = generate_payment_addresses(&wallet); - - let txo_1 = TXO { address: payment_addresses[0].clone(), seq_no: 1 }.to_libindy_string().unwrap(); - let txo_2 = TXO { address: payment_addresses[1].clone(), seq_no: 1 }.to_libindy_string().unwrap(); - - let inputs = json!([ - txo_1, txo_2 - ]); - - let outputs = json!([ - { - "recipient": payment_addresses[2], - "amount": 10 - }, - { - "recipient": payment_addresses[3], - "amount": 22 - } - ]); - - let expected_operation = json!({ - "type": XFER_PUBLIC, - "inputs": [ - {"address": addresses[0], "seqNo": 1}, - {"address": addresses[1], "seqNo": 1}, - ], - "outputs": [ - {"address": addresses[2], "amount": 10}, - {"address": addresses[3], "amount": 22}, - ], - "signatures": [ - "bnuZUPAq5jgpqvaQBzXKBQ973yCpjL1pkqJjiBtVPybpzzKGnPv3uE3VufBVZtR6hq2y55b8MSJpPFVMqskBy3m", - "4HpwuknWrSpJCs2qXEMZA1kbAsP9WxJFaoHq1cH7W3yxLg5R2fHV8QPdY5Hz2bgDmGkRitLaPa3HbF65kTxNpNTe" - ] - }); - - trace!("Calling build_payment_req"); - - let (request_string, _) = indy::payments::build_payment_req( - wallet.handle, - Some(&did), + &did, &inputs.to_string(), &outputs.to_string(), - None, - ).wait().unwrap(); + None + ).unwrap(); let request: serde_json::value::Value = serde_json::from_str(&request_string).unwrap(); debug!("Received request {:?}", request); @@ -272,7 +222,6 @@ fn success_signed_request_from_libindy() { let ident = bs58::encode(ident).into_string(); assert_eq!(&ident, request.get("identifier").unwrap().as_str().unwrap()); assert!(request.get("reqId").is_some()); - } #[test] @@ -361,7 +310,7 @@ pub fn build_and_submit_payment_req_incorrect_funds() { ]).to_string(); let res = get_resp_for_payment_req(pool_handle, wallet.handle, dids[0], &inputs, &outputs_1).unwrap_err(); - assert_eq!(res.error_code, ErrorCode::PaymentInsufficientFundsError); + assert_eq!(res, ErrorCode::PaymentInsufficientFundsError); let outputs_2 = json!([ { @@ -375,7 +324,7 @@ pub fn build_and_submit_payment_req_incorrect_funds() { ]).to_string(); let res = get_resp_for_payment_req(pool_handle, wallet.handle, dids[0], &inputs, &outputs_2).unwrap_err(); - assert_eq!(res.error_code, ErrorCode::PaymentExtraFundsError); + assert_eq!(res, ErrorCode::PaymentExtraFundsError); } #[test] @@ -411,7 +360,7 @@ pub fn build_and_submit_payment_req_with_spent_utxo() { "amount": 20 }]).to_string(); let err = get_resp_for_payment_req(pool_handle, wallet.handle, dids[0], &inputs, &outputs).unwrap_err(); - assert_eq!(err.error_code, ErrorCode::PaymentSourceDoesNotExistError); + assert_eq!(err, ErrorCode::PaymentSourceDoesNotExistError); //utxo should stay unspent! let utxos = utils::payment::get_utxo::send_get_utxo_request(&wallet, pool_handle, dids[0], &addresses[0]); @@ -435,8 +384,8 @@ pub fn build_payment_with_invalid_utxo() { } ]).to_string(); - let err = indy::payments::build_payment_req(wallet.handle, Some(&did), &inputs, &outputs, None).wait().unwrap_err(); - assert_eq!(err.error_code, ErrorCode::CommonInvalidStructure); + let err = build_payment_req(wallet.handle, &did, &inputs, &outputs, None).unwrap_err(); + assert_eq!(err, ErrorCode::CommonInvalidStructure); } pub fn build_payment_req_for_not_owned_payment_address() { @@ -464,6 +413,6 @@ pub fn build_payment_req_for_not_owned_payment_address() { } ]).to_string(); - let err = indy::payments::build_payment_req(wallet_2.handle, Some(dids[0]), &inputs, &outputs, None).wait().unwrap_err(); - assert_eq!(err.error_code, ErrorCode::WalletItemNotFound); + let err = build_payment_req(wallet_2.handle, dids[0], &inputs, &outputs, None).unwrap_err(); + assert_eq!(err, ErrorCode::WalletItemNotFound); } \ No newline at end of file diff --git a/libsovtoken/tests/build_verify_req_test.rs b/libsovtoken/tests/build_verify_req_test.rs index 1dc321413..854fc2fd9 100644 --- a/libsovtoken/tests/build_verify_req_test.rs +++ b/libsovtoken/tests/build_verify_req_test.rs @@ -7,19 +7,73 @@ use std::{thread, time}; use indy::future::Future; -use sovtoken::ErrorCode; -use sovtoken::logic::parsers::common::TXO; - mod utils; + +use sovtoken::{ErrorCode, IndyHandle}; +use sovtoken::logic::parsers::common::TXO; +use sovtoken::utils::results::ResultHandler; +use sovtoken::utils::test::callbacks; +use sovtoken::utils::ffi_support::c_pointer_from_str; use utils::wallet::Wallet; -use utils::setup::{Setup, SetupConfig}; +use utils::setup::{Setup, SetupConfig}; fn sleep(msec: u64) { let ms = time::Duration::from_millis(msec); thread::sleep(ms); } +fn build_verify_payment_req(wallet_handle: IndyHandle, did: Option<&str>, txo: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let did = did.map(c_pointer_from_str).unwrap_or(std::ptr::null()); + + let error_code = sovtoken::api::build_verify_req_handler( + command_handle, + wallet_handle, + did, + c_pointer_from_str(txo), + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} + +fn parse_verify_payment_response(response: &str) -> Result { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let error_code = sovtoken::api::parse_verify_response_handler( + command_handle, + c_pointer_from_str(response), + cb + ); + + return ResultHandler::one(ErrorCode::from(error_code), receiver); +} + +#[test] +fn build_verify_payment_request() { + let txo = "txo:sov:3x42qH8UkJac1BuorqjSEvuVjvYkXk8sUAqoVPn1fGCwjLPquu4CndzBHBQ5hX6RSmDVnXGdMPrnWDUN5S1ty4YQP87hW8ubMSzu9M56z1FbAQV6aMSX5h"; + let expected_operation = json!({ + "type": "3", + "ledgerId": "1001", + "data": 28 + }); + + let request = build_verify_payment_req(1, None, txo).unwrap(); + + let request_value: serde_json::value::Value = serde_json::from_str(&request).unwrap(); + + assert_eq!(&expected_operation, request_value.get("operation").unwrap()); +} + +#[test] +fn build_verify_payment_for_invalid_txo() { + let txo = "txo:sov:3x42qH8"; + let res = build_verify_payment_req(1, None, txo).unwrap_err(); + assert_eq!(ErrorCode::CommonInvalidStructure, res); +} + #[test] pub fn build_and_submit_verify_on_mint() { let wallet = Wallet::new(); @@ -38,9 +92,9 @@ pub fn build_and_submit_verify_on_mint() { //We need to wait a little before trying to verify txn sleep(1000); - let (get_utxo_req, payment_method) = indy::payments::build_verify_payment_req(wallet.handle, Some(dids[0]), &txo).wait().unwrap(); + let get_utxo_req = build_verify_payment_req(wallet.handle, Some(dids[0]), &txo).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_verify_payment_response(&payment_method, &res).wait().unwrap(); + let res = parse_verify_payment_response(&res).unwrap(); let res_parsed: serde_json::Value = serde_json::from_str(&res).unwrap(); assert!(res_parsed.as_object().unwrap().get("sources").unwrap().as_array().unwrap().is_empty()); @@ -65,9 +119,9 @@ pub fn build_and_submit_verify_on_mint_with_empty_did() { //We need to wait a little before trying to verify txn sleep(1000); - let (get_utxo_req, payment_method) = indy::payments::build_verify_payment_req(wallet.handle, None, &txo).wait().unwrap(); + let get_utxo_req = build_verify_payment_req(wallet.handle, None, &txo).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_verify_payment_response(&payment_method, &res).wait().unwrap(); + let res = parse_verify_payment_response(&res).unwrap(); let res_parsed: serde_json::Value = serde_json::from_str(&res).unwrap(); assert!(res_parsed.as_object().unwrap().get("sources").unwrap().as_array().unwrap().is_empty()); @@ -108,9 +162,9 @@ pub fn build_and_submit_verify_on_xfer() { //We need to wait a little before trying to verify txn sleep(1000); - let (get_utxo_req, payment_method) = indy::payments::build_verify_payment_req(wallet.handle, Some(dids[0]), &new_utxo).wait().unwrap(); + let get_utxo_req = build_verify_payment_req(wallet.handle, Some(dids[0]), &new_utxo).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_verify_payment_response(&payment_method, &res).wait().unwrap(); + let res = parse_verify_payment_response(&res).unwrap(); let res_parsed: serde_json::Value = serde_json::from_str(&res).unwrap(); assert_eq!(res_parsed.as_object().unwrap().get("sources").unwrap().as_array().unwrap().get(0).unwrap().as_str().unwrap(), txo); @@ -156,9 +210,9 @@ pub fn build_and_submit_verify_on_fees() { //We need to wait a little before trying to verify txn sleep(1000); - let (get_utxo_req, payment_method) = indy::payments::build_verify_payment_req(wallet.handle, Some(dids[0]), &new_utxo).wait().unwrap(); + let get_utxo_req = build_verify_payment_req(wallet.handle, Some(dids[0]), &new_utxo).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let res = indy::payments::parse_verify_payment_response(&payment_method, &res).wait().unwrap(); + let res = parse_verify_payment_response(&res).unwrap(); let res_parsed: serde_json::Value = serde_json::from_str(&res).unwrap(); assert_eq!(res_parsed.as_object().unwrap().get("sources").unwrap().as_array().unwrap().get(0).unwrap().as_str().unwrap(), txo); @@ -184,11 +238,11 @@ pub fn build_and_submit_verify_req_for_unexistant_utxo() { //We need to wait a little before trying to verify txn sleep(1000); - let (get_utxo_req, payment_method) = indy::payments::build_verify_payment_req(wallet.handle, Some(dids[0]), &txo).wait().unwrap(); + let get_utxo_req = build_verify_payment_req(wallet.handle, Some(dids[0]), &txo).unwrap(); let res = indy::ledger::sign_and_submit_request(pool_handle, wallet.handle, dids[0], &get_utxo_req).wait().unwrap(); - let err = indy::payments::parse_verify_payment_response(&payment_method, &res).wait().unwrap_err(); + let err = parse_verify_payment_response(&res).unwrap_err(); - assert_eq!(err.error_code, ErrorCode::PaymentSourceDoesNotExistError); + assert_eq!(err, ErrorCode::PaymentSourceDoesNotExistError); } #[test] @@ -199,7 +253,7 @@ fn build_verify_req_works_for_invalid_utxo() { let receipt = "txo:sov:1234"; - let err = indy::payments::build_verify_payment_req(wallet.handle, Some(&did), receipt).wait().unwrap_err(); + let err = build_verify_payment_req(wallet.handle, Some(&did), receipt).unwrap_err(); - assert_eq!(err.error_code, ErrorCode::CommonInvalidStructure) + assert_eq!(err, ErrorCode::CommonInvalidStructure) } \ No newline at end of file diff --git a/libsovtoken/tests/create_payment_tests.rs b/libsovtoken/tests/create_payment_addres_handler_tests.rs similarity index 54% rename from libsovtoken/tests/create_payment_tests.rs rename to libsovtoken/tests/create_payment_addres_handler_tests.rs index 8eae8acb2..4f6c82c11 100644 --- a/libsovtoken/tests/create_payment_tests.rs +++ b/libsovtoken/tests/create_payment_addres_handler_tests.rs @@ -4,51 +4,52 @@ extern crate bs58; extern crate libc; -extern crate rand; -#[macro_use] extern crate log; -#[macro_use] extern crate serde_json; -#[macro_use] extern crate serde_derive; +#[macro_use] +extern crate log; +#[macro_use] +extern crate serde_json; +#[macro_use] +extern crate serde_derive; extern crate indyrs as indy; // lib-sdk project extern crate sovtoken; -use libc::c_char; -use rand::Rng; use std::ptr; use std::ffi::CString; use std::time::Duration; -use indy::future::Future; - use sovtoken::logic::config::payment_address_config::PaymentAddressConfig; use sovtoken::logic::address::unqualified_address_from_address; use sovtoken::utils::test::callbacks; use sovtoken::ErrorCode; + mod utils; // ***** HELPER TEST DATA ***** const WALLET_ID: i32 = 99; const COMMAND_HANDLE: i32 = 1; const TIMEOUT_SECONDS: u64 = 20; -static VALID_SEED_LEN: usize = 32; static INVALID_CONFIG_JSON: &'static str = r#"{ "horrible" : "only on tuedays"}"#; -static VALID_CONFIG_EMPTY_SEED_JSON: &'static str = r#"{}"#; // ***** HELPER METHODS ***** -// helper methods -fn rand_string(length : usize) -> String { - let s = rand::thread_rng() - .gen_ascii_chars() - .take(length) - .collect::(); - - return s; -} -extern "C" fn empty_create_payment_callback(_command_handle: i32, _err: i32, _payment_address: *const c_char) -> i32 { - return ErrorCode::Success as i32; +fn create_payment_address(wallet: &utils::wallet::Wallet, config: PaymentAddressConfig) -> String { + let (receiver, command_handle, cb) = callbacks::cb_ec_string(); + + let config_str = config.serialize_to_cstring().unwrap(); + let config_str_ptr = config_str.as_ptr(); + + let return_error = sovtoken::api::create_payment_address_handler(command_handle, wallet.handle, config_str_ptr, cb); + + assert_eq!(ErrorCode::Success, ErrorCode::from(return_error), "api call to create_payment_address_handler failed"); + + let (err, payment_address) = receiver.recv_timeout(Duration::from_secs(TIMEOUT_SECONDS)).unwrap(); + + assert_eq!(ErrorCode::Success, err, "Expected Success"); + + return payment_address; } @@ -57,7 +58,7 @@ extern "C" fn empty_create_payment_callback(_command_handle: i32, _err: i32, _pa // the create payment requires a callback and this test ensures we have // receive error when no callback is provided #[test] -fn errors_with_no_callback () { +fn errors_with_no_callback() { let return_error = sovtoken::api::create_payment_address_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), None); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting Callback for 'create_payment_address_handler'"); } @@ -67,8 +68,7 @@ fn errors_with_no_callback () { // a error is returned when no config is provided #[test] fn errors_with_no_config() { - let cb : Option i32> = Some(empty_create_payment_callback); - let return_error = sovtoken::api::create_payment_address_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), cb); + let return_error = sovtoken::api::create_payment_address_handler(COMMAND_HANDLE, WALLET_ID, ptr::null(), Some(utils::callbacks::empty_callback)); assert_eq!(return_error, ErrorCode::CommonInvalidStructure as i32, "Expecting Config for 'create_payment_address_handler'"); } @@ -78,84 +78,48 @@ fn errors_with_no_config() { // default empty is used instead #[test] fn success_with_invalid_config_json() { - let config_str = CString::new(INVALID_CONFIG_JSON).unwrap(); let config_str_ptr = config_str.as_ptr(); - let cb : Option i32> = Some(empty_create_payment_callback); - let return_error = sovtoken::api::create_payment_address_handler(COMMAND_HANDLE, WALLET_ID, config_str_ptr, cb); + let return_error = sovtoken::api::create_payment_address_handler(COMMAND_HANDLE, WALLET_ID, config_str_ptr, Some(utils::callbacks::empty_callback)); assert_eq!(return_error, ErrorCode::Success as i32, "Expecting Valid JSON for 'create_payment_address_handler'"); } - // this test passes valid parameters. The callback is invoked and a valid payment address // is returned in the call back. The payment address format is described in // create_payment_address_handler #[test] fn successfully_creates_payment_address_with_no_seed() { - debug!("logging started for successfully_creates_payment_address_with_no_seed"); - let (receiver, command_handle, cb) = callbacks::cb_ec_string(); - - let config_str = CString::new(VALID_CONFIG_EMPTY_SEED_JSON).unwrap(); - let config_str_ptr = config_str.as_ptr(); - let wallet = utils::wallet::Wallet::new(); - let return_error = sovtoken::api::create_payment_address_handler(command_handle, wallet.handle, config_str_ptr, cb); - - assert_eq!(ErrorCode::Success, ErrorCode::from(return_error), "api call to create_payment_address_handler failed"); + let config: PaymentAddressConfig = PaymentAddressConfig { seed: String::new() }; - let (err, payment_address) = receiver.recv_timeout(Duration::from_secs(TIMEOUT_SECONDS)).unwrap(); + let payment_address = create_payment_address(&wallet, config); debug!("******* got address of {}", payment_address); let unqual_address = unqualified_address_from_address(&payment_address).unwrap(); assert_eq!(bs58::decode(unqual_address).into_vec().unwrap().len(), 36); - assert_eq!(ErrorCode::Success, err, "Expected Success"); } - -// this test passes valid parameters including a seed value for the key. The callback is invoked and a valid payment address -// is returned in the call back. The payment address format is described in +// this test passes a valid seed value for the key. The callback is invoked and an expected valid +// payment address is returned in the call back. The payment address format is described in // create_payment_address_handler #[test] -fn success_callback_is_called() { +fn successfully_creates_payment_address_with_seed() { + trace!("logging started for successfully_creates_payment_address_with_seed"); - trace!("logging started for success_callback_is_called"); - - let (receiver, command_handle, cb) = callbacks::cb_ec_string(); - - let seed = rand_string(VALID_SEED_LEN); - let config: PaymentAddressConfig = PaymentAddressConfig { seed, }; - - let config_str = config.serialize_to_cstring().unwrap(); - let config_str_ptr = config_str.as_ptr(); + let config: PaymentAddressConfig = PaymentAddressConfig { seed: "00000000000000000000000000000000".to_string() }; let wallet = utils::wallet::Wallet::new(); - let return_error = sovtoken::api::create_payment_address_handler(command_handle, wallet.handle, config_str_ptr, cb); - assert_eq!(ErrorCode::Success, ErrorCode::from(return_error), "api call to create_payment_address_handler failed"); + let payment_address = create_payment_address(&wallet, config); - let (err, payment_address) = receiver.recv_timeout(Duration::from_secs(TIMEOUT_SECONDS)).unwrap(); + let expected_payment_address = "pay:sov:DB3eBYTCr9NvNVZNp1GwV12iDfqftoGrDKqBedRZV4SgdeTbi"; debug!("******* got address of {}", payment_address); - let unqual_address = unqualified_address_from_address(&payment_address).unwrap(); - assert_eq!(bs58::decode(unqual_address).into_vec().unwrap().len(), 36, "callback did not receive valid payment address"); - assert_eq!(ErrorCode::Success, err, "Expected Success"); - -} - -#[test] -pub fn create_address_two_times_with_the_same_seed() { - sovtoken::api::sovtoken_init(); - let wallet = utils::wallet::Wallet::new(); - - let seed = json!({"seed": "00000000000000000000000000000000"}).to_string(); - - let _pa1 = indy::payments::create_payment_address(wallet.handle, "sov", &seed).wait().unwrap(); - let err = indy::payments::create_payment_address(wallet.handle, "sov", &seed).wait().unwrap_err(); - assert_eq!(err.error_code, ErrorCode::WalletItemAlreadyExists); + assert_eq!(expected_payment_address, payment_address, "callback did not receive expected payment address"); } \ No newline at end of file diff --git a/libsovtoken/tests/parse_payment_response_test.rs b/libsovtoken/tests/parse_payment_response_test.rs deleted file mode 100644 index de1bc9569..000000000 --- a/libsovtoken/tests/parse_payment_response_test.rs +++ /dev/null @@ -1,95 +0,0 @@ -extern crate indyrs as indy; -extern crate libc; -extern crate serde_json; -extern crate sovtoken; - -use indy::future::Future; - -use sovtoken::ErrorCode; - -static PARSE_PAYMENT_RESPONSE_JSON: &'static str = r#"{ - "op": "REPLY", - "protocolVersion": 2, - "result": - { - "txn": - { - "data": - { - "inputs": - [ - { - "address": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "seqNo": 1 - } - ], - "outputs": - [ - { - "address": "2jS4PHWQJKcawRxdW6GVsjnZBa1ecGdCssn7KhWYJZGTXgL7Es", - "amount": 13 - }, - { - "address": "24xHHVDRq97Hss5BxiTciEDsve7nYNx1pxAMi9RAvcWMouviSY", - "amount": 13 - }, - { - "address": "mNYFWv9vvoQVCVLrSpbU7ZScthjNJMQxMs3gREQrwcJC1DsG5", - "amount": 13 - }, - { - "address": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "amount": 1 - } - ] - }, - "metadata": - { - "digest": "228af6a0c773cbbd575bf4e16f9144c2eaa615fa81fdcc3d06b83e20a92e5989", - "from": "6baBEYA94sAphWBA5efEsaA6X2wCdyaH7PXuBtv2H5S1", - "reqId": 152968241 - }, - "protocolVersion": 2, - "type": "10001" - }, - "reqSignature": - { - "type": "ED25519", - "values": - [ - { - "from": "dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q", - "value": "4fFVD1HSVLaVdMpjHU168eviqWDxKrWYx1fRxw4DDLjg4XZXwya7UdcvVty81pYFcng244tS36WbshCeznC8ZN5Z" - } - ] - }, - "txnMetadata": - { - "seqNo": 2, - "txnTime": 1529682415 - }, - "ver": "1", - "auditPath": ["5NtSQUXaZvETP1KEWi8LaxSb9gGa2Qj31xKQoimNxCAT"], - "rootHash": "GJFwiQt9r7n25PqM1oXBtRceXCeoqoCBcJmRH1c8fVTs" - } -}"#; - -#[test] -pub fn parse_payment_response_works() { - sovtoken::api::sovtoken_init(); - let resp = indy::payments::parse_payment_response("sov", PARSE_PAYMENT_RESPONSE_JSON).wait().unwrap(); - let resp: Vec = serde_json::from_str(&resp).unwrap(); - assert_eq!(resp.len(), 4); - for utxo in resp { - utxo["recipient"].as_str().unwrap(); - utxo["receipt"].as_str().unwrap(); - utxo["amount"].as_u64().unwrap(); - } -} - -#[test] -pub fn parse_payment_response_works_for_invalid() { - sovtoken::api::sovtoken_init(); - let resp = indy::payments::parse_payment_response("sov", "123").wait().unwrap_err(); - assert_eq!(resp.error_code, ErrorCode::CommonInvalidStructure); -} \ No newline at end of file diff --git a/libsovtoken/tests/utils/callbacks.rs b/libsovtoken/tests/utils/callbacks.rs new file mode 100644 index 000000000..8c577dd95 --- /dev/null +++ b/libsovtoken/tests/utils/callbacks.rs @@ -0,0 +1,9 @@ +extern crate libc; + +use self::libc::c_char; + +use sovtoken::ErrorCode; + +pub extern "C" fn empty_callback(_command_handle: i32, _err: i32, _req_json: *const c_char) -> i32 { + return ErrorCode::Success as i32; +} \ No newline at end of file diff --git a/libsovtoken/tests/utils/mod.rs b/libsovtoken/tests/utils/mod.rs index 1fa13082d..f3748a5c7 100644 --- a/libsovtoken/tests/utils/mod.rs +++ b/libsovtoken/tests/utils/mod.rs @@ -6,6 +6,7 @@ Without this, we are warned of all unused code in each integration test. */ pub mod anoncreds; +pub mod callbacks; pub mod did; pub mod environment; pub mod ledger; From 9eb4ba039a276a02228474b9d2d9b0c0aca84ca6 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 23 Apr 2019 13:20:52 +0300 Subject: [PATCH 04/25] ST-576: Updated Node version Signed-off-by: artem.ivanov --- devops/indy-pool/Dockerfile | 10 ++++------ libsovtoken/tests/utils/mint.rs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index 426d883e6..85af01993 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -22,13 +22,12 @@ ARG uid=1000 ARG indy_stream=master -ARG indy_plenum_ver=1.6.735 -ARG indy_node_ver=1.6.874 -ARG indy_anoncreds_ver=1.0.32 +ARG indy_plenum_ver=1.7.0~dev770 +ARG indy_node_ver=1.7.0~dev901 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.6~2 -ARG fees_ver=0.9.6~2 +ARG token_ver=0.9.6~15 +ARG fees_ver=0.9.6~15 # Install environment RUN apt-get update -y && apt-get install -y \ @@ -51,7 +50,6 @@ RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sourc RUN apt-get update && apt-get install -y --no-install-recommends \ indy-plenum=${indy_plenum_ver} \ indy-node=${indy_node_ver} \ - indy-anoncreds=${indy_anoncreds_ver} \ python3-indy-crypto=${python3_indy_crypto_ver} \ libindy-crypto=${indy_crypto_ver} \ sovtoken=${token_ver} \ diff --git a/libsovtoken/tests/utils/mint.rs b/libsovtoken/tests/utils/mint.rs index 2cf69171a..2bac40837 100644 --- a/libsovtoken/tests/utils/mint.rs +++ b/libsovtoken/tests/utils/mint.rs @@ -29,7 +29,7 @@ pub fn mint_tokens(cfg: HashMap, pool_handle: i32, wallet_handle: i let mint_req = Request::::multi_sign_request(wallet_handle, &mint_req, trustee_dids.to_vec()).unwrap(); - let result = indy::ledger::sign_and_submit_request(pool_handle, wallet_handle, did, &mint_req).wait().unwrap(); + let result = indy::ledger::submit_request(pool_handle, &mint_req).wait().unwrap(); utils::parse_mint_response::ParseMintResponse::from_json(&result).map_err(|_| ErrorCode::CommonInvalidStructure) } From ced7b9cad888aa196746be2688eebd8014e2d342 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 23 Apr 2019 14:10:56 +0300 Subject: [PATCH 05/25] Fixed broken set fees test Signed-off-by: artem.ivanov --- libsovtoken/tests/build_fees_txn_handler_test.rs | 9 +++++---- libsovtoken/tests/build_verify_req_test.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libsovtoken/tests/build_fees_txn_handler_test.rs b/libsovtoken/tests/build_fees_txn_handler_test.rs index fff3ee655..cd8b9643d 100644 --- a/libsovtoken/tests/build_fees_txn_handler_test.rs +++ b/libsovtoken/tests/build_fees_txn_handler_test.rs @@ -191,7 +191,7 @@ pub fn build_and_submit_set_fees() { assert_eq!(current_fees_value["100"].as_u64().unwrap(), 1); let fees = json!({ - "202": 0, + "100": 0, "101": 0 }).to_string(); @@ -233,7 +233,7 @@ pub fn build_and_submit_set_fees_with_names() { } #[test] -pub fn build_and_submit_set_fees_with_empty_did() { +pub fn build_and_submit_get_fees_with_empty_did() { let wallet = Wallet::new(); let setup = Setup::new(&wallet, SetupConfig { num_addresses: 0, @@ -250,7 +250,8 @@ pub fn build_and_submit_set_fees_with_empty_did() { "ATTRIB": 2 }).to_string(); - set_fees(pool_handle, wallet.handle, &fees, &dids, None); + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); + let current_fees = get_fees(&wallet, pool_handle, None); let current_fees_value: serde_json::Value = serde_json::from_str(¤t_fees).unwrap(); @@ -262,5 +263,5 @@ pub fn build_and_submit_set_fees_with_empty_did() { "ATTRIB": 0 }).to_string(); - set_fees(pool_handle, wallet.handle, &fees, &dids, None); + set_fees(pool_handle, wallet.handle, &fees, &dids, Some(dids[0])); } \ No newline at end of file diff --git a/libsovtoken/tests/build_verify_req_test.rs b/libsovtoken/tests/build_verify_req_test.rs index 854fc2fd9..db6afe84a 100644 --- a/libsovtoken/tests/build_verify_req_test.rs +++ b/libsovtoken/tests/build_verify_req_test.rs @@ -56,7 +56,7 @@ fn build_verify_payment_request() { let txo = "txo:sov:3x42qH8UkJac1BuorqjSEvuVjvYkXk8sUAqoVPn1fGCwjLPquu4CndzBHBQ5hX6RSmDVnXGdMPrnWDUN5S1ty4YQP87hW8ubMSzu9M56z1FbAQV6aMSX5h"; let expected_operation = json!({ "type": "3", - "ledgerId": "1001", + "ledgerId": 1001, "data": 28 }); From fa0b984161b4bc79cd4ae04b7622c13785e3e2b4 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Mon, 27 May 2019 18:32:34 +0300 Subject: [PATCH 06/25] Removed tests that isn't valid anymore Signed-off-by: artem.ivanov --- .../tests/build_fees_txn_handler_test.rs | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/libsovtoken/tests/build_fees_txn_handler_test.rs b/libsovtoken/tests/build_fees_txn_handler_test.rs index 64bf3487c..d309d115a 100644 --- a/libsovtoken/tests/build_fees_txn_handler_test.rs +++ b/libsovtoken/tests/build_fees_txn_handler_test.rs @@ -11,11 +11,7 @@ use libc::c_char; use std::ffi::CString; use std::ptr; -use indy::future::Future; - use sovtoken::ErrorCode; -use sovtoken::logic::request::Request; -use sovtoken::logic::config::set_fees_config::SetFees; use sovtoken::utils::ffi_support; use sovtoken::utils::test::callbacks; use sovtoken::utils::results::ResultHandler; @@ -48,16 +44,6 @@ fn build_get_fees(wallet_handle: i32, did: Option<&str>) -> Result Result { - let (receiver, command_handle, cb) = callbacks::cb_ec_string(); - - let response_pointer = ffi_support::c_pointer_from_str(response); - - let ec = sovtoken::api::parse_get_txn_fees_response_handler(command_handle, response_pointer, cb); - - return ResultHandler::one(ErrorCode::from(ec), receiver); -} - // ***** HELPER TEST DATA ***** const COMMAND_HANDLE: i32 = 10; const WALLET_ID: i32 = 10; @@ -142,12 +128,6 @@ fn build_get_fees_req() { assert_eq!(&expected_operation, request_value.get("operation").unwrap()); } -#[test] -fn build_get_fees_error_with_invalid_did() { - let err = build_get_fees(WALLET_ID, Some(FAKE_DID)).unwrap_err(); - assert_eq!(ErrorCode::CommonInvalidStructure, err); -} - #[test] fn add_fees_json_for_any_key() { sovtoken::api::sovtoken_init(); From 8c87003230c773016cbd4b6c41967e4a257a7847 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 5 Jun 2019 10:18:56 +0300 Subject: [PATCH 07/25] use AUTH_RULES command for Libsovtoken tests Signed-off-by: artem.ivanov --- devops/docker/ci/xenial/Dockerfile | 6 +- devops/indy-pool/Dockerfile | 8 +-- libsovtoken/tests/utils/payment/fees.rs | 76 ++++++++++--------------- 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index 1f30fbe75..e9e249f97 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -36,9 +36,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # or python3-rocksdb are not specified here) ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5} ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5} -ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.8.0~dev802} +ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.8.0~dev808} ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.32} -ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.8.0~dev943} +ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.8.0~dev987} ENV TOKEN_VER ${TOKEN_VER:-0.9.6~33} RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list RUN echo "deb https://repo.sovrin.org/deb xenial master" >> /etc/apt/sources.list \ @@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.58.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.59.0 diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index 6405d86dd..f0b720d64 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -22,13 +22,13 @@ ARG uid=1000 ARG indy_stream=master -ARG indy_plenum_ver=1.8.0~dev802 -ARG indy_node_ver=1.8.0~dev943 +ARG indy_plenum_ver=1.9.0~dev808 +ARG indy_node_ver=1.9.0~dev987 ARG indy_anoncreds_ver=1.0.32 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.6~33 -ARG fees_ver=0.9.6~33 +ARG token_ver=0.9.6~36 +ARG fees_ver=0.9.6~36 # Install environment RUN apt-get update -y && apt-get install -y \ diff --git a/libsovtoken/tests/utils/payment/fees.rs b/libsovtoken/tests/utils/payment/fees.rs index c91f88599..bc3abc34a 100644 --- a/libsovtoken/tests/utils/payment/fees.rs +++ b/libsovtoken/tests/utils/payment/fees.rs @@ -42,16 +42,22 @@ pub struct GetAuthRuleResult { /** Enum of the constraint type within the GAT_AUTH_RULE result data # parameters - ROLE - The final constraint - Combination - Combine multiple constraints all of them must be met - Empty - action is forbidden + Role - The final constraint + And - Combine multiple constraints all of them must be met + Or - Combine multiple constraints any of them must be met + Forbidden - action is forbidden */ #[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(untagged)] +#[serde(tag = "constraint_id")] pub enum Constraint { - CombinationConstraint(CombinationConstraint), + #[serde(rename = "OR")] + OrConstraint(CombinationConstraint), + #[serde(rename = "AND")] + AndConstraint(CombinationConstraint), + #[serde(rename = "ROLE")] RoleConstraint(RoleConstraint), - EmptyConstraint(EmptyConstraint), + #[serde(rename = "FORBIDDEN")] + ForbiddenConstraint(ForbiddenConstraint), } /** @@ -64,7 +70,6 @@ pub enum Constraint { */ #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RoleConstraint { - pub constraint_id: String, pub sig_count: Option, pub role: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -78,7 +83,7 @@ pub struct RoleConstraint { */ #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] -pub struct EmptyConstraint {} +pub struct ForbiddenConstraint {} /** The constraint metadata @@ -97,7 +102,6 @@ pub struct Metadata { */ #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CombinationConstraint { - pub constraint_id: String, pub auth_constraints: Vec } @@ -139,49 +143,27 @@ pub fn set_auth_rules_fee(pool_handle: i32, wallet_handle: i32, submitter_did: & let fees: HashMap = ::serde_json::from_str(txn_fees).unwrap(); - let mut responses: Vec>> = Vec::new(); + let mut auth_rules: Vec = auth_rules.clone(); - for (txn_, fee_alias) in fees { - for auth_rule in auth_rules.iter() { - if auth_rule.auth_type == txn_ { - let mut constraint = auth_rule.constraint.clone(); - _set_fee_to_constraint(&mut constraint, &fee_alias); - - match constraint { - Constraint::EmptyConstraint(_) => {} - mut constraint @ _ => { - responses.push(_send_auth_rule(pool_handle, wallet_handle, submitter_did, auth_rule, &constraint)); - } - } + auth_rules + .iter_mut() + .for_each(|auth_rule| { + if let Some(fee_alias) = fees.get(&auth_rule.auth_type) { + _set_fee_to_constraint(&mut auth_rule.constraint, &fee_alias); } - } - } + }); - let _response = responses - .into_iter() - .map(|response| _check_auth_rule_responses(response)) - .collect::>(); + _send_auth_rules(pool_handle, wallet_handle, submitter_did, &auth_rules) } -fn _send_auth_rule(pool_handle: i32, wallet_handle: i32, submitter_did: &str, - auth_rule: &AuthRule, constraint: &Constraint) -> Box> { - let constraint_json = ::serde_json::to_string(&constraint).unwrap(); - - let auth_rule_request = ::indy::ledger::build_auth_rule_request(submitter_did, - &auth_rule.auth_type, - &auth_rule.auth_action, - &auth_rule.field, - auth_rule.old_value.as_ref().map(String::as_str), - auth_rule.new_value.as_ref().map(String::as_str), - &constraint_json, - ).wait().unwrap(); +fn _send_auth_rules(pool_handle: i32, wallet_handle: i32, submitter_did: &str, data: &Vec) { + let data = ::serde_json::to_string(&data).unwrap(); - ::indy::ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, &auth_rule_request) -} + let auth_rules_request = ::indy::ledger::libindy_build_auth_rules_request(submitter_did, &data).wait().unwrap(); + + let auth_rules_response = ::indy::ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, &auth_rules_request).wait().unwrap(); -fn _check_auth_rule_responses(response: Box>) { - let response = response.wait().unwrap(); - let response: serde_json::Value = ::serde_json::from_str(&response).unwrap(); + let response: serde_json::Value = ::serde_json::from_str(&auth_rules_response).unwrap(); assert_eq!("REPLY", response["op"].as_str().unwrap()); } @@ -208,12 +190,12 @@ fn _set_fee_to_constraint(constraint: &mut Constraint, fee_alias: &str) { Constraint::RoleConstraint(constraint) => { constraint.metadata.as_mut().map(|meta| meta.fees = Some(fee_alias.to_string())); } - Constraint::CombinationConstraint(constraint) => { + Constraint::AndConstraint(constraint) | Constraint::OrConstraint(constraint) => { for mut constraint in constraint.auth_constraints.iter_mut() { _set_fee_to_constraint(&mut constraint, fee_alias) } } - Constraint::EmptyConstraint(_) => {} + Constraint::ForbiddenConstraint(_) => {} } } From f0c98ee7ce91cbc7f1633fbd26e0eb4ba24b33b7 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 5 Jun 2019 18:15:09 +0300 Subject: [PATCH 08/25] Updated Libindy version Signed-off-by: artem.ivanov --- devops/Makefile | 2 +- devops/aws-codebuild/Jenkinsfile.cd | 4 ++-- devops/aws-codebuild/Jenkinsfile.ci | 4 ++-- devops/docker/base/xenial/Dockerfile | 6 +++--- devops/docker/ci/xenial/Dockerfile | 2 +- libsovtoken/Cargo.toml | 4 ++-- libsovtoken/tests/utils/payment/fees.rs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/devops/Makefile b/devops/Makefile index 29bd7858d..86a91752b 100644 --- a/devops/Makefile +++ b/devops/Makefile @@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin FPM_P_DESCRIPTION := libsovtoken written in Rust FPM_P_NAME = $(PACKAGE_NAME) FPM_P_VERSION ?= $(SRC_VERSION) -FPM_P_DEPENDS = libindy(>=1.9.0~75) +FPM_P_DEPENDS = libindy(>=1.9.0~1125) FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR) FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/ diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd index e84eae49d..b0795e664 100644 --- a/devops/aws-codebuild/Jenkinsfile.cd +++ b/devops/aws-codebuild/Jenkinsfile.cd @@ -15,8 +15,8 @@ String srcVersion gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github' sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging' sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master' -LIBINDY_STREAM = "rc" -LIBINDY_VERSION = "1.9.0-75" +LIBINDY_STREAM = "master" +LIBINDY_VERSION = "1.9.0-1125" def downloadPackagingUtils() { git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo diff --git a/devops/aws-codebuild/Jenkinsfile.ci b/devops/aws-codebuild/Jenkinsfile.ci index e59ececd8..1bf1bfe33 100644 --- a/devops/aws-codebuild/Jenkinsfile.ci +++ b/devops/aws-codebuild/Jenkinsfile.ci @@ -7,8 +7,8 @@ def sovLibrary = library(identifier: 'sovrin-aws-codebuild@master', retriever: m logger = sovLibrary.Logger.new(this) notifier = sovLibrary.Notifier.new(this) logger.setGlobalLevel('TRACE') -LIBINDY_STREAM = "rc" -LIBINDY_VERSION = "1.9.0-75" +LIBINDY_STREAM = "master" +LIBINDY_VERSION = "1.9.0-1125" def nodeLabels = [ codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild', diff --git a/devops/docker/base/xenial/Dockerfile b/devops/docker/base/xenial/Dockerfile index ca81f21dd..2c70b22d2 100644 --- a/devops/docker/base/xenial/Dockerfile +++ b/devops/docker/base/xenial/Dockerfile @@ -21,9 +21,9 @@ RUN cd /tmp \ # need for libsodium to be reachable via pkg-config (sodiumoxide uses it) ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed -ENV LIBINDY_VERSION=1.9.0~75 +ENV LIBINDY_VERSION=1.9.0~1125 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \ - && echo "deb https://repo.sovrin.org/sdk/deb xenial rc" >> /etc/apt/sources.list \ + && echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ libindy=${LIBINDY_VERSION} \ @@ -47,4 +47,4 @@ RUN cd /tmp/libsovtoken \ # TODO CMD ENTRYPOINT ... -ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.23.0 +ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.24.0 diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index e9e249f97..0fb6b1f34 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -1,4 +1,4 @@ -FROM sovrin/libsovtoken:base-xenial-0.23.0 +FROM sovrin/libsovtoken:base-xenial-0.24.0 # TODO LABEL maintainer="Name " ARG LIBINDY_CRYPTO_VERSION diff --git a/libsovtoken/Cargo.toml b/libsovtoken/Cargo.toml index c1dd74f4c..c12670570 100644 --- a/libsovtoken/Cargo.toml +++ b/libsovtoken/Cargo.toml @@ -28,8 +28,8 @@ libc = "0.2.41" log = "0.4.6" openssl = "0.10.20" rand = "0.3" -indy-sys = "1.9.0-rc-75" -indy = "1.9.0-rc-75" +indy-sys = "1.9.0-dev-1125" +indy = "1.9.0-dev-1125" serde = "1.0.89" serde_derive = "1.0.89" serde_json = "1.0.39" diff --git a/libsovtoken/tests/utils/payment/fees.rs b/libsovtoken/tests/utils/payment/fees.rs index bc3abc34a..dfe35d7df 100644 --- a/libsovtoken/tests/utils/payment/fees.rs +++ b/libsovtoken/tests/utils/payment/fees.rs @@ -159,7 +159,7 @@ pub fn set_auth_rules_fee(pool_handle: i32, wallet_handle: i32, submitter_did: & fn _send_auth_rules(pool_handle: i32, wallet_handle: i32, submitter_did: &str, data: &Vec) { let data = ::serde_json::to_string(&data).unwrap(); - let auth_rules_request = ::indy::ledger::libindy_build_auth_rules_request(submitter_did, &data).wait().unwrap(); + let auth_rules_request = ::indy::ledger::build_auth_rules_request(submitter_did, &data).wait().unwrap(); let auth_rules_response = ::indy::ledger::sign_and_submit_request(pool_handle, wallet_handle, submitter_did, &auth_rules_request).wait().unwrap(); From db992af385f0548d169ff54944ae5827edf737ba Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Thu, 6 Jun 2019 11:57:15 +0300 Subject: [PATCH 09/25] Fix node/plenum dep version in pool Dockerfile Signed-off-by: Sergey Minaev --- devops/indy-pool/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index f0b720d64..84ad347e9 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -22,8 +22,8 @@ ARG uid=1000 ARG indy_stream=master -ARG indy_plenum_ver=1.9.0~dev808 -ARG indy_node_ver=1.9.0~dev987 +ARG indy_plenum_ver=1.8.0~dev808 +ARG indy_node_ver=1.8.0~dev987 ARG indy_anoncreds_ver=1.0.32 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 From 14497fccea33f9d156471adc537c16e449f62334 Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Fri, 7 Jun 2019 13:05:50 +0300 Subject: [PATCH 10/25] Bump deps versions. Signed-off-by: Sergey Minaev --- devops/docker/ci/xenial/Dockerfile | 8 ++++---- devops/indy-pool/Dockerfile | 8 ++++---- libsovtoken/Cargo.toml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index 0fb6b1f34..3c7baddb0 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -36,10 +36,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # or python3-rocksdb are not specified here) ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5} ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5} -ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.8.0~dev808} +ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.9.0~dev808} ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.32} -ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.8.0~dev987} -ENV TOKEN_VER ${TOKEN_VER:-0.9.6~33} +ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.9.0~dev987} +ENV TOKEN_VER ${TOKEN_VER:-0.9.13~41} RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list RUN echo "deb https://repo.sovrin.org/deb xenial master" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ @@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.59.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.60.0 diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index 84ad347e9..b0ba8a5d0 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -22,13 +22,13 @@ ARG uid=1000 ARG indy_stream=master -ARG indy_plenum_ver=1.8.0~dev808 -ARG indy_node_ver=1.8.0~dev987 +ARG indy_plenum_ver=1.9.0~dev808 +ARG indy_node_ver=1.9.0~dev987 ARG indy_anoncreds_ver=1.0.32 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.6~36 -ARG fees_ver=0.9.6~36 +ARG token_ver=0.9.13~41 +ARG fees_ver=0.9.13~41 # Install environment RUN apt-get update -y && apt-get install -y \ diff --git a/libsovtoken/Cargo.toml b/libsovtoken/Cargo.toml index c12670570..4f4112364 100644 --- a/libsovtoken/Cargo.toml +++ b/libsovtoken/Cargo.toml @@ -28,8 +28,8 @@ libc = "0.2.41" log = "0.4.6" openssl = "0.10.20" rand = "0.3" -indy-sys = "1.9.0-dev-1125" -indy = "1.9.0-dev-1125" +indy-sys = "=1.9.0-dev-1130" +indy = "=1.9.0-dev-1130" serde = "1.0.89" serde_derive = "1.0.89" serde_json = "1.0.39" From 73240d8f7b5b8ade118dda4adabb4b01fe5e2d5f Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Fri, 7 Jun 2019 17:35:11 +0300 Subject: [PATCH 11/25] Sync libindy versions in deps. Signed-off-by: Sergey Minaev --- devops/Makefile | 2 +- devops/aws-codebuild/Jenkinsfile.cd | 2 +- devops/aws-codebuild/Jenkinsfile.ci | 2 +- devops/docker/base/xenial/Dockerfile | 4 ++-- devops/docker/ci/xenial/Dockerfile | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/devops/Makefile b/devops/Makefile index 86a91752b..e4841fc15 100644 --- a/devops/Makefile +++ b/devops/Makefile @@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin FPM_P_DESCRIPTION := libsovtoken written in Rust FPM_P_NAME = $(PACKAGE_NAME) FPM_P_VERSION ?= $(SRC_VERSION) -FPM_P_DEPENDS = libindy(>=1.9.0~1125) +FPM_P_DEPENDS = libindy(>=1.9.0~1130) FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR) FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/ diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd index b0795e664..26ede5084 100644 --- a/devops/aws-codebuild/Jenkinsfile.cd +++ b/devops/aws-codebuild/Jenkinsfile.cd @@ -16,7 +16,7 @@ gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github' sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging' sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master' LIBINDY_STREAM = "master" -LIBINDY_VERSION = "1.9.0-1125" +LIBINDY_VERSION = "1.9.0-1130" def downloadPackagingUtils() { git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo diff --git a/devops/aws-codebuild/Jenkinsfile.ci b/devops/aws-codebuild/Jenkinsfile.ci index 1bf1bfe33..f0ea0951f 100644 --- a/devops/aws-codebuild/Jenkinsfile.ci +++ b/devops/aws-codebuild/Jenkinsfile.ci @@ -8,7 +8,7 @@ logger = sovLibrary.Logger.new(this) notifier = sovLibrary.Notifier.new(this) logger.setGlobalLevel('TRACE') LIBINDY_STREAM = "master" -LIBINDY_VERSION = "1.9.0-1125" +LIBINDY_VERSION = "1.9.0-1130" def nodeLabels = [ codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild', diff --git a/devops/docker/base/xenial/Dockerfile b/devops/docker/base/xenial/Dockerfile index 2c70b22d2..821d18291 100644 --- a/devops/docker/base/xenial/Dockerfile +++ b/devops/docker/base/xenial/Dockerfile @@ -21,7 +21,7 @@ RUN cd /tmp \ # need for libsodium to be reachable via pkg-config (sodiumoxide uses it) ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed -ENV LIBINDY_VERSION=1.9.0~1125 +ENV LIBINDY_VERSION=1.9.0~1130 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \ && echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ @@ -47,4 +47,4 @@ RUN cd /tmp/libsovtoken \ # TODO CMD ENTRYPOINT ... -ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.24.0 +ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.25.0 diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index 3c7baddb0..31ee37797 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -1,4 +1,4 @@ -FROM sovrin/libsovtoken:base-xenial-0.24.0 +FROM sovrin/libsovtoken:base-xenial-0.25.0 # TODO LABEL maintainer="Name " ARG LIBINDY_CRYPTO_VERSION @@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.60.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.61.0 From 566f7c8061383917909199961e1d8383110fe9ff Mon Sep 17 00:00:00 2001 From: Andrey Kononykhin Date: Fri, 14 Jun 2019 08:22:26 +0300 Subject: [PATCH 12/25] fixes windows publishing script for stable Signed-off-by: Andrey Kononykhin --- devops/aws-codebuild/Jenkinsfile.cd | 4 ++-- devops/windows/win-zip-and-upload.sh | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd index 26ede5084..a57ed3bc1 100644 --- a/devops/aws-codebuild/Jenkinsfile.cd +++ b/devops/aws-codebuild/Jenkinsfile.cd @@ -460,7 +460,7 @@ def getSuffix() { } - pipelineWrapper({ +pipelineWrapper({ //put code build containers inside a vpc under our dev account env.USE_VPC_CONFIG = true @@ -512,4 +512,4 @@ def getSuffix() { def setupRust() { shell("rustup default 1.32.0") -} \ No newline at end of file +} diff --git a/devops/windows/win-zip-and-upload.sh b/devops/windows/win-zip-and-upload.sh index e3c7ed38a..3670f8f3f 100755 --- a/devops/windows/win-zip-and-upload.sh +++ b/devops/windows/win-zip-and-upload.sh @@ -16,7 +16,6 @@ suffix="$4" [ -z $version ] && exit 1 [ -z $key ] && exit 2 [ -z $type ] && exit 3 -[ -z $suffix ] && exit 4 PACKAGE_NAME="libsovtoken" TEMP_ARCH_DIR=./${PACKAGE_NAME}-zip From a84e9252a19ff0aa1c49d566a5a36c85ed07aba2 Mon Sep 17 00:00:00 2001 From: Andrey Kononykhin Date: Fri, 14 Jun 2019 12:00:56 +0300 Subject: [PATCH 13/25] fixes android build to support non stable libindy Signed-off-by: Andrey Kononykhin --- devops/Makefile.android.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devops/Makefile.android.in b/devops/Makefile.android.in index 06f75f625..556e3256a 100644 --- a/devops/Makefile.android.in +++ b/devops/Makefile.android.in @@ -20,6 +20,7 @@ ANDROID_NDK_ARCHIVE_NAME := $(ANDROID_NDK_NAME)-$(call to_lower,$(shell uname))- LIBINDY_DEP_SPEC := $(subst =, ,$(call get_android_dependency,libindy,$(LIBSOVTOKEN_DEPS_FILE))) LIBINDY_VERSION ?= $(word 2,$(LIBINDY_DEP_SPEC)) +LIBINDY_VERSION_BASE ?= $(word 1,$(subst -, ,$(LIBINDY_VERSION))) LIBINDY_BRANCH ?= $(word 3,$(LIBINDY_DEP_SPEC)) ANDROID_ARCHS ?= arm armv7 arm64 x86 x86_64 @@ -42,9 +43,9 @@ $(ANDROID_PREBUILT_DIR)/openssl_%.zip: | $(ANDROID_PREBUILT_DIR) $(ANDROID_PREBUILT_DIR)/libsodium_%.zip: | $(ANDROID_PREBUILT_DIR) cd $(@D) && curl -fLO $(REPO_SOVRIN_ORG_ANDROID_PREBUILT_URL)/deps/sodium/libsodium_$*.zip -.PRECIOUS: $(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION).zip -$(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION).zip: | $(ANDROID_PREBUILT_DIR) - cd $(@D) && curl -fLO $(REPO_SOVRIN_ORG_ANDROID_PREBUILT_URL)/$(LIBINDY_BRANCH)/$(LIBINDY_VERSION)/libindy_android_$*_$(LIBINDY_VERSION).zip +.PRECIOUS: $(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION_BASE).zip +$(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION_BASE).zip: | $(ANDROID_PREBUILT_DIR) + cd $(@D) && curl -fLO $(REPO_SOVRIN_ORG_ANDROID_PREBUILT_URL)/$(LIBINDY_BRANCH)/$(LIBINDY_VERSION)/libindy_android_$*_$(LIBINDY_VERSION_BASE).zip .PRECIOUS: $(ANDROID_PREBUILT_DIR)/% $(ANDROID_PREBUILT_DIR)/%: $(ANDROID_PREBUILT_DIR)/%.zip @@ -52,7 +53,7 @@ $(ANDROID_PREBUILT_DIR)/%: $(ANDROID_PREBUILT_DIR)/%.zip touch $@ .PRECIOUS: $(ANDROID_PREBUILT_DIR)/libindy_% -$(ANDROID_PREBUILT_DIR)/libindy_%: $(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION).zip +$(ANDROID_PREBUILT_DIR)/libindy_%: $(ANDROID_PREBUILT_DIR)/libindy_android_%_$(LIBINDY_VERSION_BASE).zip unzip -o -qq -d $( Date: Fri, 14 Jun 2019 12:03:30 +0300 Subject: [PATCH 14/25] switches android builds to stable libindy Signed-off-by: Andrey Kononykhin --- .../android/libsovtoken/libsovtoken.dependencies.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt index 6a558ece2..528c8ad04 100644 --- a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt +++ b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt @@ -1 +1 @@ -libindy=1.9.0-75=rc +libindy=1.9.0=stable From 7e5c06e7519b9973e50a29d42125680c358bb358 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 25 Jun 2019 13:34:00 +0300 Subject: [PATCH 15/25] ST-605: Updated `set fees` document to reflect the current behavior Signed-off-by: artem.ivanov --- doc/fees.md | 94 +++++++++++++++++++++++++++++++++++++++++ doc/set_fees_process.md | 56 ------------------------ 2 files changed, 94 insertions(+), 56 deletions(-) create mode 100644 doc/fees.md delete mode 100644 doc/set_fees_process.md diff --git a/doc/fees.md b/doc/fees.md new file mode 100644 index 000000000..f5abd8a3b --- /dev/null +++ b/doc/fees.md @@ -0,0 +1,94 @@ +# Setting fees process + +### How to set fees for an action + +1) Send a SET_FEES txn with appropriate amount for required alias. +For example, we have an alias, like "add_new_steward" (and we want to set fees for adding new nym action). +For setting fees for this alias, we need to send a SET_FEES transaction with map {"add_new_steward": 42}. + +2) Add metadata into default auth constraint for action "add new nym". +For this example, constraint for changing metadata for default auth_rule will be looked as: +``` +{ + 'constraint_id': 'ROLE', + 'role': '0', + 'sig_count': 1, + 'need_to_be_owner': False, + 'metadata': {'fees': 'add_new_steward'} +} +``` + +#### Notes: +* The order of these steps is very important. First of all SET_FEES is required, then - AUTH_RULE. +* SET_FEES is "updating" transaction, so that it appends new aliases to the existing FEEs map (either adding or overriding aliases). For example, if current fees are {A: 1, B: 2} then after sending SET_FEES transaction with {A: 42, C:3}, the resulted map will look like {A: 42, B: 2, C:3}. +* Setting fees without adding or changing metadata in corresponding auth_rule doesn't have any effect. + +## How to set fees on an example of Indy CLI. + +### Prerequisites + +* libindy +* Indy CLI +* libsovtoken +* Wallet with Trustee DID +* Created pool in Indy CLI + +[Small guide](https://github.com/hyperledger/indy-sdk/tree/master/doc/design/001-cli#commands) to Indy CLI commands: + +### Creating a SET_FEES transaction. + +* Open `indy-cli` +* Open wallet: `wallet open key=` +* Load libsovtoken: `load-plugin library=libsovtoken.[so|dll] initializer=sovtoken_init` +* Make a transaction with a command `ledger set-fees-prepare payment_method=sov fees=add_new_steward:42` to set fees to 42 sovatom for add_new_steward. + +Indy CLI will print the transaction after these steps. Example output: + +```json +{"operation":{"type":"20000","fees":{"add_new_steward":42}},"reqId":3782930813,"protocolVersion":2,"identifier":"V4SGRU86Z58d6TV7PBUe6f"} +``` + +### Putting your signature on a prepared request + +This step should be made by multiple trustees. + +* Open `indy-cli` +* Load libsovtoken: `load-plugin library=libsovtoken.[so|dll] initializer=sovtoken_init` +* Open your wallet: `wallet open key=` +* Use your did: `did use ` +* Sign the transaction you created or received: `ledger sign-multi txn=` + +Indy CLI will print the transaction with your signature after these steps. Example output: + +```json +{"identifier":"V4SGRU86Z58d6TV7PBUe6f","operation":{"fees":{"add_new_steward":42},"type":"20000"},"protocolVersion":2,"reqId":3782930813,"signatures":{"V4SGRU86Z58d6TV7PBUe6f":"DpiKv5n5es9yTkPv1py8mMb6PtL1tWrYdpVS9qp5bJ6GtNPRfNME8ThAbxW7hFbAPfsDzQsBMMEarJ4qDS4CgEF"}} +``` + +The output should be send to the next trustee to sign it. + +### Sending the signed SET_FEES transaction to the ledger + +* Open `indy-cli` +* Connect to the pool: `pool connect ` +* Send transaction: `ledger custom ` + +Received ledger reply json will be printed in cli. Example output: + +```json +{"op":"REPLY","result":{"txn":{"type":"20000","metadata":{"from":"V4SGRU86Z58d6TV7PBUe6f","reqId":3782930813,"digest":"94952d32bd83f1b63fed28cb502b704fd225cb02dca3cb02f4ebab94f2168370"},"data":{"fees":{"1":1,"10001":2}},"protocolVersion":2},"reqSignature":{"type":"ED25519","values":[{"value":"CFvstbmLLbWL2dtNxPiDkSR2v4aB7ADX41t3hVk4uvsnjVRXSFSwGs7KXcVdVQU9Qgzpp7moLdfKbjsD2QbwW8q","from":"4kyq92WXWVPKARnou6kWr7"},{"value":"YsNUcj1Hkpjfiykqs4C2nRqr8P8Xet2AZthQWgtjKEFxotYR99zHXQxRTBfzD4BRzUx7eL19HvrGdP495wmcrAb","from":"FT5Rx4RZZrVF1SjXtwcX7g"},{"value":"DpiKv5n5es9yTkPv1py8mMb6PtL1tWrYdpVS9qp5bJ6GtNPRfNME8ThAbxW7hFbAPfsDzQsBMMEarJ4qDS4CgEF","from":"V4SGRU86Z58d6TV7PBUe6f"}]},"auditPath":["FXoJDLDmTtc8x4FuNUZyazMTnHeEdqRMrkqiaUg9BivZ","hya3KgvwSti8uwbMv3h4yog6pu7ufSaM37EQFoikyp5","SmgEKUnFjZhC4FbaGwVfipvQMVyHyDW4BxzLSWYhkY2","Hf3CrReW4qNNGrShjpru6VLkfr5eCQn1YCYtuTePX3BD","3JxvbWb6zv7Vsj152frDKezsMGEwgjxCu6AcbPhZM5rq"],"ver":"1","rootHash":"Fg8uKJozQUAgKhjLvNTdPk3ZbduhjRju9pVjcyvXo8n2","txnMetadata":{"txnTime":1536940234,"seqNo":317}}} +``` + +### Creating and Sending a AUTH_RULE transaction. + +* Open `indy-cli` +* Open wallet: `wallet open key=` +* Connect to the pool: `pool connect ` +* Use your did: `did use ` +* Send a transaction with a command `ledger auth-rule txn_type=NYM action=ADD field=role new_value=2 constraint="{"sig_count":1,"role":"0","metadata":{"fees":"add_new_steward"},"constraint_id":"ROLE","need_to_be_owner":false}"` to add fees metadata for the action. + +Indy CLI will print result of this transaction. + +After these steps adding of a new Steward to the ledger will require paying of the fee set above. +``` +ledger nym did=VsKV7grR1BUE29mG2Fm2kX role=2 fees_inputs=txo:sov:fkjZEd8eTBnYJsw7m7twMph3UYD6KZCuNwGWnmmtGVgkXafzy7fgaWrpKnwVbNnxTdHF5T4vsAZPe3BVkk3Pg5dYdnGedFHaFhWW2PsgqGAyTLfh4Vit fees_outputs=(pay:sov:dctKSXBbv2My3TGGUgTFjkxu1A9JM3Sscd5FydY4dkxnfwA7q,10) +``` \ No newline at end of file diff --git a/doc/set_fees_process.md b/doc/set_fees_process.md deleted file mode 100644 index 98b7313a7..000000000 --- a/doc/set_fees_process.md +++ /dev/null @@ -1,56 +0,0 @@ -# Setting fees process - -It will be explained on an example of Indy CLI. - -### Prerequisites - -* libindy -* Indy CLI -* libsovtoken -* Wallet with Trustee DID -* Created pool in Indy CLI - -[Small guide](https://github.com/hyperledger/indy-sdk/tree/master/doc/design/001-cli#commands) to Indy CLI commands: - -### Creating a SET_FEES transaction. - -* Open `indy-cli` -* Open wallet: `wallet open key=` -* Load libsovtoken: `load-plugin library=libsovtoken.[so|dll] initializer=sovtoken_init` -* Make a transaction with a command `ledger set-fees-prepare payment_method=sov fees=NYM:1,ATTRIB:2` to set fees to 1 sovatom for NYM and 2 sovatoms for ATTRIB - -Indy CLI will print the transaction after these steps. Example output: - -```json -{"operation":{"type":"20000","fees":{"10001":2,"1":1}},"reqId":3782930813,"protocolVersion":2,"identifier":"V4SGRU86Z58d6TV7PBUe6f"} -``` - -### Putting your signature on a prepared request - -This step should be made by multiple trustees. - -* Open `indy-cli` -* Load libsovtoken: `load-plugin library=libsovtoken.[so|dll] initializer=sovtoken_init` -* Open your wallet: `wallet open key=` -* Use your did: `did use ` -* Sign the transaction you created or received: `ledger sign-multi txn=` - -Indy CLI will print the transaction with your signature after these steps. Example output: - -```json -{"identifier":"V4SGRU86Z58d6TV7PBUe6f","operation":{"fees":{"1":1,"10001":2},"type":"20000"},"protocolVersion":2,"reqId":3782930813,"signatures":{"V4SGRU86Z58d6TV7PBUe6f":"DpiKv5n5es9yTkPv1py8mMb6PtL1tWrYdpVS9qp5bJ6GtNPRfNME8ThAbxW7hFbAPfsDzQsBMMEarJ4qDS4CgEF"}} -``` - -The output should be send to the next trustee to sign it. - -### Sending the signed transaction to the ledger - -* Open `indy-cli` -* Connect to the pool: `pool connect ` -* Send transaction: `ledger custom ` - -Received ledger reply json will be printed in cli. Example output: - -```json -{"op":"REPLY","result":{"txn":{"type":"20000","metadata":{"from":"V4SGRU86Z58d6TV7PBUe6f","reqId":3782930813,"digest":"94952d32bd83f1b63fed28cb502b704fd225cb02dca3cb02f4ebab94f2168370"},"data":{"fees":{"1":1,"10001":2}},"protocolVersion":2},"reqSignature":{"type":"ED25519","values":[{"value":"CFvstbmLLbWL2dtNxPiDkSR2v4aB7ADX41t3hVk4uvsnjVRXSFSwGs7KXcVdVQU9Qgzpp7moLdfKbjsD2QbwW8q","from":"4kyq92WXWVPKARnou6kWr7"},{"value":"YsNUcj1Hkpjfiykqs4C2nRqr8P8Xet2AZthQWgtjKEFxotYR99zHXQxRTBfzD4BRzUx7eL19HvrGdP495wmcrAb","from":"FT5Rx4RZZrVF1SjXtwcX7g"},{"value":"DpiKv5n5es9yTkPv1py8mMb6PtL1tWrYdpVS9qp5bJ6GtNPRfNME8ThAbxW7hFbAPfsDzQsBMMEarJ4qDS4CgEF","from":"V4SGRU86Z58d6TV7PBUe6f"}]},"auditPath":["FXoJDLDmTtc8x4FuNUZyazMTnHeEdqRMrkqiaUg9BivZ","hya3KgvwSti8uwbMv3h4yog6pu7ufSaM37EQFoikyp5","SmgEKUnFjZhC4FbaGwVfipvQMVyHyDW4BxzLSWYhkY2","Hf3CrReW4qNNGrShjpru6VLkfr5eCQn1YCYtuTePX3BD","3JxvbWb6zv7Vsj152frDKezsMGEwgjxCu6AcbPhZM5rq"],"ver":"1","rootHash":"Fg8uKJozQUAgKhjLvNTdPk3ZbduhjRju9pVjcyvXo8n2","txnMetadata":{"txnTime":1536940234,"seqNo":317}}} -``` \ No newline at end of file From b22606a9ac740eb0d87406c7a24de2cfad5a9357 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 25 Jun 2019 16:54:08 +0300 Subject: [PATCH 16/25] ST-605: Updated SET_FEES request building Signed-off-by: artem.ivanov --- doc/fees.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/fees.md b/doc/fees.md index f5abd8a3b..0a9526e29 100644 --- a/doc/fees.md +++ b/doc/fees.md @@ -40,6 +40,7 @@ For this example, constraint for changing metadata for default auth_rule will be * Open `indy-cli` * Open wallet: `wallet open key=` * Load libsovtoken: `load-plugin library=libsovtoken.[so|dll] initializer=sovtoken_init` +* Use your did: `did use ` * Make a transaction with a command `ledger set-fees-prepare payment_method=sov fees=add_new_steward:42` to set fees to 42 sovatom for add_new_steward. Indy CLI will print the transaction after these steps. Example output: From 85564bf934823d2710d0646e6ec32765a4f45b34 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 25 Jun 2019 14:18:56 +0300 Subject: [PATCH 17/25] ST-583 Updated documentation to reflect sovtoken installation Signed-off-by: artem.ivanov --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index e890fe3b8..892eb5524 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,41 @@ Adds Sovrin's token functionality to HyperLedger's Indy-SDK. +## Installing the Sovtoken + +### Release channels +The Sovtoken release process defines the following release channels: + +* `master` - development builds for each push to master branch. +* `stable` - stable releases. + +### Ubuntu based distributions (Ubuntu 16.04) +It is recommended to install the SDK packages with APT: + + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 + sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb xenial {release channel}" + sudo apt-get update + sudo apt-get install -y libsovtoken + +### Windows + +1. Go to `https://repo.sovrin.org/windows/libsovtoken/{release-channel}` +2. Download last version of libsovtoken. +3. Unzip archives to the directory where you want to save library. + +### iOS +1. Go to `https://repo.sovrin.org/ios/libsovtoken/{release-channel}/libsovtoken-core/`. +2. 5 target architecture are supported as of now aarch64-apple-ios, armv7-apple-ios, armv7s-apple-ios, i386-apple-ios, x86_64-apple-ios and universal. +3. Download latest version of libsovtoken. +4. Unzip archives to the directory where you want to save library. + +### Android + +1. Go to `https://repo.sovrin.org/android/libsovtoken/{release-channel}`. +2. 3 architecture are supported as of now arm,arm64 and x86. +3. Download latest version of libsovtoken. +4. Unzip archives to the directory where you want to save library. + ## How To Contribute Please follow the guide [here](./doc/pull-request.md). From 6e0a0f74caa0e98799bf7645354efe75c85b4836 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 26 Jun 2019 11:06:04 +0300 Subject: [PATCH 18/25] ST-579: Release LibSovToken 1.0.0 - preparation done Signed-off-by: artem.ivanov --- CHANGELOG.md | 3 +++ devops/Makefile | 2 +- devops/aws-codebuild/Jenkinsfile.cd | 4 ++-- devops/aws-codebuild/Jenkinsfile.ci | 4 ++-- devops/docker/base/xenial/Dockerfile | 6 +++--- devops/docker/ci/xenial/Dockerfile | 2 +- libsovtoken/Cargo.toml | 6 +++--- .../build_scripts/android/libsovtoken/build.nondocker.sh | 3 ++- .../android/libsovtoken/libsovtoken.dependencies.txt | 2 +- libsovtoken/build_scripts/ios/mac/shared.functions.sh | 2 +- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 623e68216..07d0b0058 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.0 +* bugfixes + ## 0.10.0 * Updated `build_set_txn_fees_handler` function to accept any aliases. * Updated `build_payment_req_handler` function to accept and to handle `Transaction Author Agreement` passed inside `extra_json`. diff --git a/devops/Makefile b/devops/Makefile index e4841fc15..26edf8b46 100644 --- a/devops/Makefile +++ b/devops/Makefile @@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin FPM_P_DESCRIPTION := libsovtoken written in Rust FPM_P_NAME = $(PACKAGE_NAME) FPM_P_VERSION ?= $(SRC_VERSION) -FPM_P_DEPENDS = libindy(>=1.9.0~1130) +FPM_P_DEPENDS = libindy(>=1.10.0~76) FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR) FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/ diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd index a57ed3bc1..a935790fc 100644 --- a/devops/aws-codebuild/Jenkinsfile.cd +++ b/devops/aws-codebuild/Jenkinsfile.cd @@ -15,8 +15,8 @@ String srcVersion gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github' sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging' sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master' -LIBINDY_STREAM = "master" -LIBINDY_VERSION = "1.9.0-1130" +LIBINDY_STREAM = "rc" +LIBINDY_VERSION = "1.10.0-76" def downloadPackagingUtils() { git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo diff --git a/devops/aws-codebuild/Jenkinsfile.ci b/devops/aws-codebuild/Jenkinsfile.ci index f0ea0951f..7f1039104 100644 --- a/devops/aws-codebuild/Jenkinsfile.ci +++ b/devops/aws-codebuild/Jenkinsfile.ci @@ -7,8 +7,8 @@ def sovLibrary = library(identifier: 'sovrin-aws-codebuild@master', retriever: m logger = sovLibrary.Logger.new(this) notifier = sovLibrary.Notifier.new(this) logger.setGlobalLevel('TRACE') -LIBINDY_STREAM = "master" -LIBINDY_VERSION = "1.9.0-1130" +LIBINDY_STREAM = "rc" +LIBINDY_VERSION = "1.10.0-76" def nodeLabels = [ codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild', diff --git a/devops/docker/base/xenial/Dockerfile b/devops/docker/base/xenial/Dockerfile index 821d18291..7cb749e31 100644 --- a/devops/docker/base/xenial/Dockerfile +++ b/devops/docker/base/xenial/Dockerfile @@ -21,9 +21,9 @@ RUN cd /tmp \ # need for libsodium to be reachable via pkg-config (sodiumoxide uses it) ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed -ENV LIBINDY_VERSION=1.9.0~1130 +ENV LIBINDY_VERSION=1.10.0~76 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \ - && echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list \ + && echo "deb https://repo.sovrin.org/sdk/deb xenial rc" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ libindy=${LIBINDY_VERSION} \ @@ -47,4 +47,4 @@ RUN cd /tmp/libsovtoken \ # TODO CMD ENTRYPOINT ... -ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.25.0 +ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.26.0 diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index 31ee37797..cd22dea88 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -1,4 +1,4 @@ -FROM sovrin/libsovtoken:base-xenial-0.25.0 +FROM sovrin/libsovtoken:base-xenial-0.26.0 # TODO LABEL maintainer="Name " ARG LIBINDY_CRYPTO_VERSION diff --git a/libsovtoken/Cargo.toml b/libsovtoken/Cargo.toml index 4f4112364..b3471dc20 100644 --- a/libsovtoken/Cargo.toml +++ b/libsovtoken/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libsovtoken" -version = "0.10.0" +version = "1.0.0" authors = [ "Matt Raffel /dev/null - curl -sSLO https://repo.sovrin.org/android/libindy/$1/$2/libindy_android_$3_$2.zip + curl -sSLO https://repo.sovrin.org/android/libindy/$1/$2/libindy_android_$3_$base_version.zip unzip -o -qq "libindy_android_$3_$2.zip" rm "libindy_android_$3_$2.zip" command popd > /dev/null diff --git a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt index 528c8ad04..59ca982b5 100644 --- a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt +++ b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt @@ -1 +1 @@ -libindy=1.9.0=stable +libindy=1.10.0-76=rc diff --git a/libsovtoken/build_scripts/ios/mac/shared.functions.sh b/libsovtoken/build_scripts/ios/mac/shared.functions.sh index e6784ff2e..51480aa81 100644 --- a/libsovtoken/build_scripts/ios/mac/shared.functions.sh +++ b/libsovtoken/build_scripts/ios/mac/shared.functions.sh @@ -1,6 +1,6 @@ #!/bin/sh -export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/rc/libindy-core/1.9.0-75/libindy.tar.gz" +export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/rc/libindy-core/1.10.0-76/libindy.tar.gz" export LIBINDY_FILE=$(basename ${LIBINDY_IOS_BUILD_URL}) export LIBINDY_VERSION=$(basename $(dirname ${LIBINDY_IOS_BUILD_URL})) export BUILD_CACHE=~/.build_libvxc/ioscache From 9a892954e48ea4d6583df457394bdae601796c51 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 26 Jun 2019 16:17:56 +0300 Subject: [PATCH 19/25] ST-605: Updated SET_FEES request building Signed-off-by: artem.ivanov --- doc/fees.md | 128 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 113 insertions(+), 15 deletions(-) diff --git a/doc/fees.md b/doc/fees.md index 0a9526e29..606ec67ca 100644 --- a/doc/fees.md +++ b/doc/fees.md @@ -1,27 +1,125 @@ # Setting fees process -### How to set fees for an action - -1) Send a SET_FEES txn with appropriate amount for required alias. -For example, we have an alias, like "add_new_steward" (and we want to set fees for adding new nym action). -For setting fees for this alias, we need to send a SET_FEES transaction with map {"add_new_steward": 42}. - -2) Add metadata into default auth constraint for action "add new nym". -For this example, constraint for changing metadata for default auth_rule will be looked as: +## How to set fees for an action + For setting fees for an action we need to make the following steps: + * Send a SET_FEES txn with appropriate amount for required alias. + For example, we have an alias, like "add_new_steward" (and we want to set fees for adding new nym action). For setting fees for this alias, we need to send a SET_FEES transaction with map {"add_new_steward": 42}. + Txn will be looked as: + ``` +{ + "reqId": , //random identifier + "protocolVersion": , // the version of the client/node communication protocol + "operation": { + "type": "20000", + "fees": { + "add_new_steward": 42,, + } + }, +} ``` + * After that, we need to add metadata into default auth constraint for action "add new nym". + For this example, txn for changing metadata for default auth_rule will be looked as: + ``` { - 'constraint_id': 'ROLE', - 'role': '0', - 'sig_count': 1, - 'need_to_be_owner': False, - 'metadata': {'fees': 'add_new_steward'} + 'operation': { + 'type':'120', + 'constraint':{ + 'constraint_id': 'ROLE', + 'role': '0', + 'sig_count': 1, + 'need_to_be_owner': False, + 'metadata': {'fees': 'add_new_steward'} + }, + 'field' :'role', + 'auth_type': '1', + 'auth_action': 'ADD', + 'new_value': '2' + }, + + 'identifier': , + 'reqId': , + 'protocolVersion': 1, + 'signature': } ``` -#### Notes: -* The order of these steps is very important. First of all SET_FEES is required, then - AUTH_RULE. +The pool performs the following validation for the given example: +* doDynamicValidation for "adding new steward" nym (_`from indy-node's side`_); + * making general role's authorization (_`from indy-node's side`_) + * making fees specific validation, using metadata field (_`from plugin's side`_) + * lookup through config state for getting amount of "add_new_steward" alias (_`from plugin's side`_) + * making can_pay_fees validation (_`from plugin's side`_) + +### Notes: +* The order of previous steps is very important. First of all SET_FEES is required, then - AUTH_RULE. * SET_FEES is "updating" transaction, so that it appends new aliases to the existing FEEs map (either adding or overriding aliases). For example, if current fees are {A: 1, B: 2} then after sending SET_FEES transaction with {A: 42, C:3}, the resulted map will look like {A: 42, B: 2, C:3}. * Setting fees without adding or changing metadata in corresponding auth_rule doesn't have any effect. + +## How to setup fees for whole pool +For setting fees for whole we need to make the following steps: +* Define all the actions which we would like to set fees for +* Repeat all the steps from [How to set fees for an action](#how-to-set-fees-for-an-action) for each action + +## How to change fees amount for alias +For changing amount of fees for existing alias, you need to send a SET_FEES (as described in [How to set fees for an action](#how-to-set-fees-for-an-action)) transaction with 'fees' value, like: +``` +{: } +``` +As was mentioned before, SET_FEES is "updating" transaction and this request will update whole fees map in state and new amount of fees_alias will be used for validation. +Full SET_FEES request: + ``` +{ + "reqId": , //random identifier + "protocolVersion": , // the version of the client/node communication protocol + "operation": { + "type": "20000", + "fees": { + : , + } + }, +} +``` + +## How to set fees for complex Auth Constraints +For example, we have a constraint like: +``` +(TRUSTEE, 2) or (STEWARD, 5) +``` +It means, that this action requires "2 signatures from 2 different TRUSTEEs" or "5 signatures from 5 different STEWARDs" and we want to set fees for steward's part of this constraint. +For this case, we need to: +* add new alias, 'some_action_by_steward' for example, as described in [How to set fees for an action](#how-to-set-fees-for-an-action) +* set this alias for corresponding auth_rule into steward's part of constraint: +``` +(TRUSTEE, 2) or (STEWARD, 5, 'fees': 'some_action_by_steward') +``` +After that, the next requests will be ordered: +* with 2 and more TRUSTEE's signatures +* with 5 and more STEWARD's signature and required amount of fees. + +Also, trustee's part of constraint can contains 'fees' field with different fees alias, like: +``` +(TRUSTEE, 2, 'fees': 'some_action_by_trustee') or (STEWARD, 5, 'fees': 'some_action_by_steward') +``` +'some_action_by_trustee' should exists before setting it in AUTH_RULE transaction. + +## Recommendation for setting fees. +* **If you want to set an alias for `AND` constraint, then make sure, that all of fees aliases will have the same amount.** +In the other words, fees aliases can be different, but amount should be the same. +For example, there is a constraint: +``` +(TRUSTEE, 1) and (STEWARD, 3) - it means, that 1 trustee's and 3 steward's signatures are required +``` +And we want to setup fees, like: +``` +(TRUSTEE, 1, {'fees': 'trustees_fees'}) and (STEWARD, 3, {'fees': 'steward_fees'}) +``` +And after all setup actions we try to send a request with fees, related to 'trustees_fees' alias and signatures from 1 TRUSTEE and 3 STEWARD. +In this case, if amount of 'trustees_fees' doesn't equal to amount of 'steward_fees' then RequestRejectedException will be raised (`AND` constraint and the second part will be failed). +* **Either do not set FEEs for NODE txn, or set equal amount of Fees for all fields (except service)** +For now, we can add only 1 fees field per request, but Node txn can contain several actions so that validation process (including fees validation) will be called for each action. +For example we can change ip address, port and alias in 1 txn, but 1 fees field would be used for each action validation. +If each of this actions cost 5 tokens, then Node request with 15 token will be rejected, because we don't summarize all action's tokens during validation process. +But Node request with 5 tokens will be ordered. ## How to set fees on an example of Indy CLI. From 27a9846ca12265c4d37e35f0ed4b0ed8fbc7dff1 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 2 Jul 2019 09:47:55 +0300 Subject: [PATCH 20/25] ST-605: Corrected extra comma Signed-off-by: artem.ivanov --- doc/fees.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fees.md b/doc/fees.md index 606ec67ca..9ab6df9fd 100644 --- a/doc/fees.md +++ b/doc/fees.md @@ -12,7 +12,7 @@ "operation": { "type": "20000", "fees": { - "add_new_steward": 42,, + "add_new_steward": 42, } }, } From 783aba1bc793f58fb65971ef8b1d0bb82978e25a Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 2 Jul 2019 11:54:20 +0300 Subject: [PATCH 21/25] ST-579: Release LibSovToken 1.0.0 - updated Libindy version Signed-off-by: artem.ivanov --- devops/Makefile | 2 +- devops/aws-codebuild/Jenkinsfile.cd | 2 +- devops/aws-codebuild/Jenkinsfile.ci | 2 +- devops/docker/base/xenial/Dockerfile | 2 +- .../android/libsovtoken/libsovtoken.dependencies.txt | 2 +- libsovtoken/build_scripts/ios/mac/shared.functions.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/devops/Makefile b/devops/Makefile index 26edf8b46..80f9a00b0 100644 --- a/devops/Makefile +++ b/devops/Makefile @@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin FPM_P_DESCRIPTION := libsovtoken written in Rust FPM_P_NAME = $(PACKAGE_NAME) FPM_P_VERSION ?= $(SRC_VERSION) -FPM_P_DEPENDS = libindy(>=1.10.0~76) +FPM_P_DEPENDS = libindy(>=1.10.0~77) FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR) FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/ diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd index a935790fc..dfc72df15 100644 --- a/devops/aws-codebuild/Jenkinsfile.cd +++ b/devops/aws-codebuild/Jenkinsfile.cd @@ -16,7 +16,7 @@ gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github' sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging' sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master' LIBINDY_STREAM = "rc" -LIBINDY_VERSION = "1.10.0-76" +LIBINDY_VERSION = "1.10.0-77" def downloadPackagingUtils() { git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo diff --git a/devops/aws-codebuild/Jenkinsfile.ci b/devops/aws-codebuild/Jenkinsfile.ci index 7f1039104..5d00d0ea8 100644 --- a/devops/aws-codebuild/Jenkinsfile.ci +++ b/devops/aws-codebuild/Jenkinsfile.ci @@ -8,7 +8,7 @@ logger = sovLibrary.Logger.new(this) notifier = sovLibrary.Notifier.new(this) logger.setGlobalLevel('TRACE') LIBINDY_STREAM = "rc" -LIBINDY_VERSION = "1.10.0-76" +LIBINDY_VERSION = "1.10.0-77" def nodeLabels = [ codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild', diff --git a/devops/docker/base/xenial/Dockerfile b/devops/docker/base/xenial/Dockerfile index 7cb749e31..65aca97c0 100644 --- a/devops/docker/base/xenial/Dockerfile +++ b/devops/docker/base/xenial/Dockerfile @@ -21,7 +21,7 @@ RUN cd /tmp \ # need for libsodium to be reachable via pkg-config (sodiumoxide uses it) ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed -ENV LIBINDY_VERSION=1.10.0~76 +ENV LIBINDY_VERSION=1.10.0~77 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \ && echo "deb https://repo.sovrin.org/sdk/deb xenial rc" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ diff --git a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt index 59ca982b5..1311d5d87 100644 --- a/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt +++ b/libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt @@ -1 +1 @@ -libindy=1.10.0-76=rc +libindy=1.10.0-77=rc diff --git a/libsovtoken/build_scripts/ios/mac/shared.functions.sh b/libsovtoken/build_scripts/ios/mac/shared.functions.sh index 51480aa81..becf7e3e2 100644 --- a/libsovtoken/build_scripts/ios/mac/shared.functions.sh +++ b/libsovtoken/build_scripts/ios/mac/shared.functions.sh @@ -1,6 +1,6 @@ #!/bin/sh -export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/rc/libindy-core/1.10.0-76/libindy.tar.gz" +export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/rc/libindy-core/1.10.0-77/libindy.tar.gz" export LIBINDY_FILE=$(basename ${LIBINDY_IOS_BUILD_URL}) export LIBINDY_VERSION=$(basename $(dirname ${LIBINDY_IOS_BUILD_URL})) export BUILD_CACHE=~/.build_libvxc/ioscache From 9894eed72ec61b2bafc9ad987ec87fe8015c36b8 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 2 Jul 2019 11:58:55 +0300 Subject: [PATCH 22/25] ST-579: Release LibSovToken 1.0.0 - incremented docker versions Signed-off-by: artem.ivanov --- devops/docker/ci/xenial/Dockerfile | 2 +- libsovtoken/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index cd22dea88..301543ce8 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.61.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.62.0 diff --git a/libsovtoken/Cargo.toml b/libsovtoken/Cargo.toml index b3471dc20..e14734da4 100644 --- a/libsovtoken/Cargo.toml +++ b/libsovtoken/Cargo.toml @@ -28,8 +28,8 @@ libc = "0.2.41" log = "0.4.6" openssl = "0.10.20" rand = "0.3" -indy-sys = "=1.10.0-rc-96" -indy = "=1.10.0-rc-96" +indy-sys = "=1.10.0-rc-77" +indy = "=1.10.0-rc-77" serde = "1.0.89" serde_derive = "1.0.89" serde_json = "1.0.39" From 22a1a1c7570a1e0363bf5d0b300939e487a2671e Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Tue, 2 Jul 2019 15:29:21 +0300 Subject: [PATCH 23/25] ST-579: Release LibSovToken 1.0.0 - incremented pool versions Signed-off-by: artem.ivanov --- devops/docker/ci/xenial/Dockerfile | 13 +++++-------- devops/indy-pool/Dockerfile | 11 +++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index 301543ce8..df71b4486 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -4,7 +4,6 @@ FROM sovrin/libsovtoken:base-xenial-0.26.0 ARG LIBINDY_CRYPTO_VERSION ARG PYTHON3_INDY_CRYPTO_VERSION ARG INDY_PLENUM_VERSION -ARG INDY_ANONCREDS_VERSION ARG INDY_NODE_VERSION ARG SOVRIN_REPO_IP @@ -36,17 +35,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # or python3-rocksdb are not specified here) ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5} ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5} -ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.9.0~dev808} -ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.32} -ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.9.0~dev987} -ENV TOKEN_VER ${TOKEN_VER:-0.9.13~41} +ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.9.0} +ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.9.0~rc3} +ENV TOKEN_VER ${TOKEN_VER:-0.9.14~rc11} RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list -RUN echo "deb https://repo.sovrin.org/deb xenial master" >> /etc/apt/sources.list \ +RUN echo "deb https://repo.sovrin.org/deb xenial rc" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ libindy-crypto=${LIBINDY_CRYPTO_VERSION} \ python3-indy-crypto=${PYTHON3_INDY_CRYPTO_VERSION} \ indy-plenum=${INDY_PLENUM_VERSION} \ - indy-anoncreds=${INDY_ANONCREDS_VERSION} \ indy-node=${INDY_NODE_VERSION} \ sovtoken=${TOKEN_VER} \ sovtokenfees=${TOKEN_VER} \ @@ -69,4 +66,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.62.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.63.0 diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index 8ac2e9749..f7d758b96 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -19,16 +19,15 @@ FROM camparra/ubuntu16.04-rocksdb ARG uid=1000 -ARG indy_stream=master +ARG indy_stream=rc -ARG indy_plenum_ver=1.9.0~dev808 -ARG indy_node_ver=1.9.0~dev987 -ARG indy_anoncreds_ver=1.0.32 +ARG indy_plenum_ver=1.9.0 +ARG indy_node_ver=1.9.0~rc3 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.13~41 -ARG fees_ver=0.9.13~41 +ARG token_ver=0.9.14~rc11 +ARG fees_ver=0.9.14~rc11 # Install environment RUN apt-get update -y && apt-get install -y \ From fe872d877cd87f7b8c71c5beb1ad0e024e6459da Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Tue, 2 Jul 2019 20:22:19 +0300 Subject: [PATCH 24/25] ST-519: increment pool plugin versions. Signed-off-by: Sergey Minaev --- devops/docker/ci/xenial/Dockerfile | 4 ++-- devops/indy-pool/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index df71b4486..c3f56b06f 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -37,7 +37,7 @@ ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5} ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5} ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.9.0} ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.9.0~rc3} -ENV TOKEN_VER ${TOKEN_VER:-0.9.14~rc11} +ENV TOKEN_VER ${TOKEN_VER:-0.9.14~rc12} RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list RUN echo "deb https://repo.sovrin.org/deb xenial rc" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ @@ -66,4 +66,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.63.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.64.0 diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index f7d758b96..2a6c13286 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -26,8 +26,8 @@ ARG indy_plenum_ver=1.9.0 ARG indy_node_ver=1.9.0~rc3 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.14~rc11 -ARG fees_ver=0.9.14~rc11 +ARG token_ver=0.9.14~rc12 +ARG fees_ver=0.9.14~rc12 # Install environment RUN apt-get update -y && apt-get install -y \ From ebe754ad5ab03079ebfb9ae406e3029ee1db9ae7 Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Wed, 3 Jul 2019 09:57:00 +0300 Subject: [PATCH 25/25] ST-519: Increment token plugin versions. Signed-off-by: artem.ivanov --- devops/docker/ci/xenial/Dockerfile | 4 ++-- devops/indy-pool/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile index c3f56b06f..2ca5cffbc 100644 --- a/devops/docker/ci/xenial/Dockerfile +++ b/devops/docker/ci/xenial/Dockerfile @@ -37,7 +37,7 @@ ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5} ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5} ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.9.0} ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.9.0~rc3} -ENV TOKEN_VER ${TOKEN_VER:-0.9.14~rc12} +ENV TOKEN_VER ${TOKEN_VER:-1.0.0~rc13} RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list RUN echo "deb https://repo.sovrin.org/deb xenial rc" >> /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ @@ -66,4 +66,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"] -ENV LIBSOVTOKEN_CI_ENV_VERSION=0.64.0 +ENV LIBSOVTOKEN_CI_ENV_VERSION=0.66.0 diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile index 2a6c13286..5da72beae 100644 --- a/devops/indy-pool/Dockerfile +++ b/devops/indy-pool/Dockerfile @@ -26,8 +26,8 @@ ARG indy_plenum_ver=1.9.0 ARG indy_node_ver=1.9.0~rc3 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 -ARG token_ver=0.9.14~rc12 -ARG fees_ver=0.9.14~rc12 +ARG token_ver=1.0.0~rc13 +ARG fees_ver=1.0.0~rc13 # Install environment RUN apt-get update -y && apt-get install -y \