message: Implement retry to send get requests for CLI tests.
diff: @@ -1832,32 +1832,50 @@ pub mod tests {
  fn _ensure_nym_added(ctx: &CommandContext, did: &str) {
  let request = Ledger::build_get_nym_request(DID_TRUSTEE, did).unwrap();
  - let pool_handle = ensure_connected_pool_handle(&ctx).unwrap();
  - let response = Ledger::submit_request(pool_handle, &request).unwrap();
  + _submit_retry(ctx, &request, |response| {
  serde_json::from_str::<Response<ReplyResult<String>>>(&response)
  - .and_then(|response| serde_json::from_str::<NymData>(&response.result.unwrap().data)).unwrap();
  + .and_then(|response| serde_json::from_str::<NymData>(&response.result.unwrap().data))
  + }).unwrap();
  }
  fn _ensure_attrib_added(ctx: &CommandContext, did: &str) {
  let request = Ledger::build_get_attrib_request(DID_MY1, did, "endpoint").unwrap();
  - let pool_handle = ensure_connected_pool_handle(&ctx).unwrap();
  - let response = Ledger::submit_request(pool_handle, &request).unwrap();
  + _submit_retry(ctx, &request, |response| {
  serde_json::from_str::<Response<ReplyResult<String>>>(&response)
  - .and_then(|response| serde_json::from_str::<AttribData>(&response.result.unwrap().data)).unwrap();
  + .and_then(|response| serde_json::from_str::<AttribData>(&response.result.unwrap().data))
  + }).unwrap();
  }
  fn _ensure_schema_added(ctx: &CommandContext, did: &str) {
  let data = r#"{"name":"gvt", "version":"1.0"}"#;
  let request = Ledger::build_get_schema_request(DID_TRUSTEE, did, data).unwrap();
  - let pool_handle = ensure_connected_pool_handle(&ctx).unwrap();
  - let response = Ledger::submit_request(pool_handle, &request).unwrap();
  - serde_json::from_str::<Response<ReplyResult<SchemaData>>>(&response).unwrap();
  + _submit_retry(ctx, &request, |response| {
  + serde_json::from_str::<Response<ReplyResult<SchemaData>>>(&response)
  + }).unwrap();
  }
  fn _ensure_claim_def_added(ctx: &CommandContext, did: &str) {
  let request = Ledger::build_get_claim_def_txn(DID_TRUSTEE, 1, "CL", did).unwrap();
  - let pool_handle = ensure_connected_pool_handle(&ctx).unwrap();
  - let response = Ledger::submit_request(pool_handle, &request).unwrap();
  - serde_json::from_str::<Response<ReplyResult<ClaimDefData>>>(&response).unwrap();
  + _submit_retry(ctx, &request, |response| {
  + serde_json::from_str::<Response<ReplyResult<ClaimDefData>>>(response)
  + }).unwrap();
  + }
  +
  + fn _submit_retry<F, T, E>(ctx: &CommandContext, request: &str, parser: F) -> Result<(), ()>
  + where F: Fn(&str) -> Result<T, E> {
  + const SUBMIT_RETRY_CNT: usize = 3;
  + const SUBMIT_TIMEOUT_SEC: u64 = 2;
  +
  + let pool_handle = ensure_connected_pool_handle(ctx).unwrap();
  +
  + for _ in 0..SUBMIT_RETRY_CNT {
  + let response = Ledger::submit_request(pool_handle, request).unwrap();
  + if parser(&response).is_ok() {
  + return Ok(());
  + }
  + ::std::thread::sleep(::std::time::Duration::from_secs(SUBMIT_TIMEOUT_SEC));
  + }
  +
  + return Err(());
  }
  }
  \ No newline at end of file
  