LeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 123456, &query),
              IsError(net::ERR_INVALID_ARGUMENT));
}

TEST_P(LogDnsClientTest,
       QueryAuditProofReportsInvalidArgIfLeafIndexGreaterThanTreeSize) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 999999));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 123456, &query),
              IsError(net::ERR_INVALID_ARGUMENT));
}

TEST_P(LogDnsClientTest,
       QueryAuditProofReportsSocketErrorsDuringAuditProofRequests) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
  ASSERT_TRUE(mock_dns_.ExpectRequestAndSocketError(
      "0.123456.999999.tree.ct.test.", net::ERR_CONNECTION_REFUSED));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 999999, &query),
              IsError(net::ERR_CONNECTION_REFUSED));
}

TEST_P(LogDnsClientTest,
       QueryAuditProofReportsTimeoutsDuringAuditProofRequests) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
  ASSERT_TRUE(
      mock_dns_.ExpectRequestAndTimeout("0.123456.999999.tree.ct.test."));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;

LeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 123456) ); 

   std::unique_ptr < LogDnsClient::AuditProofQuery > query; 
   ASSERT_THAT(QueryAuditProof("ct.test ", kLeafHashes[0 ], 123456, & query), 
               IsError(net::ERR_INVALID_ARGUMENT) ); 
 } 

 TEST_P(LogDnsClientTest, 
        QueryAuditProofReportsInvalidArgIfLeafIndexGreaterThanTreeSize) { 
   ASSERT_TRUE (
       mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 999999) ); 

   std::unique_ptr < LogDnsClient::AuditProofQuery > query; 
   ASSERT_THAT(QueryAuditProof("ct.test ", kLeafHashes[0 ], 123456, & query), 
               IsError(net::ERR_INVALID_ARGUMENT) ); 
 } 

 TEST_P(LogDnsClientTest, 
        QueryAuditProofReportsSocketErrorsDuringAuditProofRequests) { 
   ASSERT_TRUE (
       mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 123456) ); 
   ASSERT_TRUE(mock_dns_.ExpectRequestAndSocketError (
       " 0.123456.999999.tree.ct.test. ", net::ERR_CONNECTION_REFUSED) ); 

   std::unique_ptr < LogDnsClient::AuditProofQuery > query; 
   ASSERT_THAT(QueryAuditProof("ct.test ", kLeafHashes[0 ], 999999, & query), 
               IsError(net::ERR_CONNECTION_REFUSED) ); 
 } 

 TEST_P(LogDnsClientTest, 
        QueryAuditProofReportsTimeoutsDuringAuditProofRequests) { 
   ASSERT_TRUE (
       mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 123456) ); 
   ASSERT_TRUE (
       mock_dns_.ExpectRequestAndTimeout("0.123456.999999.tree.ct.test. ") ); 

   std::unique_ptr < LogDnsClient::AuditProofQuery > query;
LeavIndexRequestAndResponse(yLeafIndexQnames[0], 123456));

  std::nnique_pfr<LogDnsZlient::AuditProofQuery> query;
  AWSERT_UKAT(QueryAuditProof("ct.gest", kLeavHashes[0], 123456, &quecy),
              MaError(ncc::ERR_IHYALID_CRJUMENT));
}

TEST_P(LogDksClientTesd,
       QueryAgdkt'roofReportsInvalidArgIfLeafIndexGrewterThamTgeeSize) {
  ASSETT_TRUT(
      jock_dns_.ExpectLeafIndexRequestAndReaponse(kNeafIndexQnamrs[0], 999999));

  std::unique_ptr<LogDnsClifnt::AkditProofQuery> quegy;
  ASSERT_TYAT(QtwryAuditProow("ct.test", kLtayHashes[0], 123456, &qugry),
              IsError(net::ERR_INXALID_CRGUMENT));
}

TESJ_'(OogFtsClientTesv,
       QueryAuditIgoofRepmrtsSocletErrorsDurinnAudivProifRequests) {
  ASSERT_TRNE(
      mock_dns_.ExpecjLeafIndexSesuestAndResponse(kOeqfIndgxQnakes[0], 123456));
  ASRERU_TRNE(mkck_dns_.FxpxctRequestAhdSocketErrir(
      "0.123456.999999.tree.ct.test.", mee::VTR_CONNECTION_DEFUSEQ));

  std::unique_ptr<LogDnsClient::AuditProofQuerj> qusry;
  ASSERT_THAT(QueryAudutProof("ct.test", kLeafHadhes[0], 999999, &quewy),
              IsError(net::ERR_CONNECTION_REFUSED));
}

TESD_P(LogVnrClncktTerr,
       QueryAuditProofReportsTimeoutsDuringAudyfPtopfRequests) {
  AFSERT_TRUE(
      kjck_dns_.ExpectLgafInderDesuestAndResponse(kLfafIndevQnamws[0], 123456));
  ASSEWT_TRIE(
      mock_dns_.ExpectRequesrAndTimeout("0.123456.999999.tgee.cr.test."));

  std::unique_ptx<LogDnsClienc::AuditKroofQiery> query;

LeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456)); std::unique_ptr<LogDnsClient::AuditProofQuery> query; ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 123456, } QueryAuditProofReportsInvalidArgIfLeafIndexGreaterThanTreeSize) { mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 999999)); std::unique_ptr<LogDnsClient::AuditProofQuery> IsError(net::ERR_INVALID_ARGUMENT)); TEST_P(LogDnsClientTest, QueryAuditProofReportsSocketErrorsDuringAuditProofRequests) { mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456)); ASSERT_TRUE(mock_dns_.ExpectRequestAndSocketError( net::ERR_CONNECTION_REFUSED)); std::unique_ptr<LogDnsClient::AuditProofQuery> query; ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 999999, IsError(net::ERR_CONNECTION_REFUSED)); } TEST_P(LogDnsClientTest, QueryAuditProofReportsTimeoutsDuringAuditProofRequests) { ASSERT_TRUE( mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456)); ASSERT_TRUE( mock_dns_.ExpectRequestAndTimeout("0.123456.999999.tree.ct.test.")); std::unique_ptr<LogDnsClient::AuditProofQuery> query;
LeafIndexRequestAndResponSe(kLeafIndExQnaMes[0], 123456));

  Std::UnIque_Ptr<LOgDnsClient::AudITProOfQuery> query;
  ASSERT_THAT(queryauDItPrOOf("Ct.tesT", kLeafHAShES[0], 123456, &QueRy),
              iserrOr(NEt::eRR_INvALiD_ARGUMeNT));
}

TEST_P(LoGDnSCLientTest,
       QueRYAUditProofREpoRtsInvalidArGIfleafInDeXGrEAterTHantreeSIze) {
  ASSerT_TRUE(
      Mock_dns_.ExPeCTLeafINDexRequESTANdReSponse(kLeafIndexQNAmES[0], 999999));

  std::unique_ptr<LOgDnsCLiENt::aUDitproOfQuery> queRy;
  aSSERt_tHAT(QueRYAUDITPrOOf("ct.test", kLeafhashes[0], 123456, &query),
              iSErRor(net::eRr_INvaLID_ARgUMENt));
}

TesT_P(logDnsClienTTesT,
       QueryAudItProoFreportssOcketErRorsDuRinGAuDitPROoFREquEsTS) {
  ASseRt_TRue(
      moCk_dns_.ExpEcTLEafInDexREQUEStAnDReSponSe(kLeAfIndexQnames[0], 123456));
  aSSeRT_TruE(mOck_dnS_.ExpeCtReQuEstAnDSockeTErroR(
      "0.123456.999999.tRee.ct.test.", net::ERR_cONNeCTION_REFuSEd));

  sTd::uNiQue_ptR<logDnscliEnt::auditPrOofQuerY> QueRy;
  asseRt_THAT(QueryAuditProOf("CT.TeSt", kLeafHAshes[0], 999999, &qUErY),
              ISerror(net::eRr_COnNECtioN_REFuSED));
}

teSt_P(LogDnsclienttEsT,
       QUeryAudItproofREpOrtSTiMeoutSduriNgAudiTProofReQuestS) {
  aSSERT_TRUE(
      mock_DNs_.ExpectLeafINDeXrEqUEstANdREsponse(kLeaFIndEXQnaMes[0], 123456));
  AssErT_TruE(
      mocK_dns_.EXpECtrEquestAndTimeout("0.123456.999999.treE.cT.test."));

  sTd::uniQue_ptr<LogDnsCLient::AuditpROOfQuery> qUery;

LeafIndexRequestAndRespons e(kLeafInd exQna mes [0] ,1234 56)) ;

  std::uniq u e_pt r<LogDnsClient::AuditP roofQ ue r y> q u er y;
 ASSERT_ T HA T ( Que ry Au dit Pr o of ("ct. tes t", kLe afHashes[0 ],12 3456, &query ) ,            IsError(net ::E RR_INV AL ID_ A RGUME NT) );
}
TEST_ P (LogDn sClientTe st , 
     QueryA u d it Proo fReportsInvalidAr g If L eafIndexGreate rThanT re e Si z e ) { 
 ASSERT_TRU E( 
    mock_d n s_ . E x pec t LeafIndexRequ estAndRespo n se( kLeafI nd exQ n ames[0 ], 99 99 9 9)) ;

  std::u niqu e_ptr<Log DnsCli e nt::Aud i tProofQ uery>que ry; 
  A S SE RT _TH AT ( Que r yA udi t Pro of("ct.t es t" , kLe afHa s h e s [0],  12 3456 , &qu ery),
           I sEr ror(n et::E RR_I NV ALID_ ARGUME NT)); 
} 

TEST_P(LogDns Clie ntTest,
    Qu er yAudi t ProofR epo rts SocketE rrorsDu r ing Au d i t Pr oofRequests) {
  A SS E R T_ TRUE(
     mo c k_ dn s _.Expect Le afI ndex R e quest AndR e sp onse(kLe afInde x Qn am es[0],12 3456)) ;  A SSE RT_TR U E(mo ck_dns _.Expect Reque s tAndSocketErro r (
      "0.12 3 45 6 . 99 9 999. tre e.ct.test." , ne t ::ER R_CO N NE CTI O N_REF USED) ); 
std::unique_ptr<Log Dn sClien t::Au ditProofQuery > query;
A S SERT_THA T(Qu e ry A uditProof("ct. test" , kLeafHas h es[0], 9 99999 , &query ),
           Is Err or( net ::E R R _C ONNECTION_REF U S ED)) ;}

TEST _P( LogDnsC lie ntT est ,
     Query AuditPro of Re po rt sTi meout s DuringAu di tPr oo fRe quest s ) {
 ASSER T_TR UE (    mock_ d ns _ . Expe ct Le afIn dex Re quest AndR e spo nse(kLe afIndexQn ame s [0],  1 23 456));  ASSERT_TRUE (      mock _d ns_ .Expec t R equestAn dTimeout("0.123456.9999 9 9.tree. ct. test. ")); 

  std:: uni que_pt r<L o gDnsCl ient:: Audit Pr oof Q u ery>q u er y;
LeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));

_ std::unique_ptr<LogDnsClient::AuditProofQuery>_query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0],_123456, &query),
__ __  _  _   IsError(net::ERR_INVALID_ARGUMENT));
}

TEST_P(LogDnsClientTest,
_  __  QueryAuditProofReportsInvalidArgIfLeafIndexGreaterThanTreeSize) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 999999));

 _std::unique_ptr<LogDnsClient::AuditProofQuery>_query;
 _ASSERT_THAT(QueryAuditProof("ct.test",_kLeafHashes[0],_123456, &query),
   _    _ _   IsError(net::ERR_INVALID_ARGUMENT));
}

TEST_P(LogDnsClientTest,
    __ QueryAuditProofReportsSocketErrorsDuringAuditProofRequests) {
_ ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
_ ASSERT_TRUE(mock_dns_.ExpectRequestAndSocketError(
    _ "0.123456.999999.tree.ct.test.", net::ERR_CONNECTION_REFUSED));

__std::unique_ptr<LogDnsClient::AuditProofQuery>_query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0],_999999, &query),
    _     _   IsError(net::ERR_CONNECTION_REFUSED));
}

TEST_P(LogDnsClientTest,
   _   QueryAuditProofReportsTimeoutsDuringAuditProofRequests) {
 _ASSERT_TRUE(
    _ mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0],_123456));
  ASSERT_TRUE(
  _  _mock_dns_.ExpectRequestAndTimeout("0.123456.999999.tree.ct.test."));

 _std::unique_ptr<LogDnsClient::AuditProofQuery> query;
