message: fix error code associated with - propogate agency failure up
diff: @@ -368,7 +368,7 @@ pub fn create_agent_pairwise(handle: u32) -> Result<u32, ConnectionError> {
  .for_did(&pw_did)
  .for_verkey(&pw_verkey)
  .send_secure()
  - .or(Err(ConnectionError::InvalidWalletSetup()))?; // Throw a context specific error
  + .map_err(|e|ConnectionError::CommonError(e))?;
  debug!("create key for connection: {} with did/vk: {:?}", get_source_id(handle).unwrap_or_default(), result);
  set_agent_did(handle,&result[0]).err();
  set_agent_verkey(handle,&result[1]).err();
  @@ -434,7 +434,6 @@ fn init_connection(handle: u32) -> Result<u32, ConnectionError> {
  match create_agent_pairwise(handle) {
  Err(err) => {
  error!("Error while Creating Agent Pairwise: {}", err);
  - release(handle)?;
  return Err(err)
  },
  Ok(_) => debug!("created pairwise key on agent"),
  @@ -443,7 +442,6 @@ fn init_connection(handle: u32) -> Result<u32, ConnectionError> {
  match update_agent_profile(handle) {
  Err(x) => {
  error!("could not update profile on agent: {}", x);
  - release(handle)?;
  return Err(x)
  },
  Ok(_) => debug!("updated profile on agent"),
  @@ -801,6 +799,15 @@ pub mod tests {
  Some(ConnectionError::CommonError(error::INVALID_WALLET_HANDLE.code_num)));
  assert!(build_connection_with_invite("This Should Fail", "BadDetailsFoobar").is_err());
  }
  +
  + #[test]
  + fn test_create_connection_agency_failure() {
  + init!("indy");
  + ::utils::httpclient::set_next_u8_response(vec![]);
  + let rc = build_connection("invalid");
  + assert_eq!(rc.unwrap_err(),ConnectionError::CommonError(error::POST_MSG_FAILURE.code_num));
  + }
  +
  #[test]
  fn test_create_connection() {
  init!("true");
  