 10));
  ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse(
      "10.123456.999999.tree.ct.test.", audit_proof.begin() + 10,
      audit_proof.begin() + 13));
  ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse(
      "13.123456.999999.tree.ct.test.", audit_proof.begin() + 13,
      audit_proof.end()));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;
  ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 999999, &query),
              IsOk());
  const net::ct::MerkleAuditProof& proof = query->GetProof();
  EXPECT_THAT(proof.leaf_index, Eq(123456u));
  EXPECT_THAT(proof.tree_size, Eq(999999u));
  EXPECT_THAT(proof.nodes, Eq(audit_proof));
}

TEST_P(LogDnsClientTest,
       QueryAuditProofReportsThatAuditProofQnameDoesNotExist) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
  ASSERT_TRUE(mock_dns_.ExpectRequestAndErrorResponse(
      "0.123456.999999.tree.ct.test.", net::dns_protocol::kRcodeNXDOMAIN));

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

TEST_P(LogDnsClientTest,
       QueryAuditProofReportsServerFailuresDuringAuditProofRequests) {
  ASSERT_TRUE(
      mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
  ASSERT_TRUE(mock_dns_.ExpectRequestAndError
10) ); 
   ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse (
       " 10.123456.999999.tree.ct.test. ", audit_proof.begin () + 10, 
       audit_proof.begin () + 13) ); 
   ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse (
       " 13.123456.999999.tree.ct.test. ", audit_proof.begin () + 13, 
       audit_proof.end ()) ); 

   std::unique_ptr < LogDnsClient::AuditProofQuery > query; 
   ASSERT_THAT(QueryAuditProof("ct.test ", kLeafHashes[0 ], 999999, & query), 
               IsOk ()); 
   const net::ct::MerkleAuditProof & proof = query->GetProof (); 
   EXPECT_THAT(proof.leaf_index, Eq(123456u) ); 
   EXPECT_THAT(proof.tree_size, Eq(999999u) ); 
   EXPECT_THAT(proof.nodes, Eq(audit_proof) ); 
 } 

 TEST_P(LogDnsClientTest, 
        QueryAuditProofReportsThatAuditProofQnameDoesNotExist) { 
   ASSERT_TRUE (
       mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 123456) ); 
   ASSERT_TRUE(mock_dns_.ExpectRequestAndErrorResponse (
       " 0.123456.999999.tree.ct.test. ", net::dns_protocol::kRcodeNXDOMAIN) ); 

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

 TEST_P(LogDnsClientTest, 
        QueryAuditProofReportsServerFailuresDuringAuditProofRequests) { 
   ASSERT_TRUE (
       mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0 ], 123456) ); 
   ASSERT_TRUE(mock_dns_.ExpectRequestAndError
 10));
  WSSERT_TRUE(mock_dns_.ExpectAmditProofRequestCbdRespmnse(
      "10.123456.999999.tree.zt.test.", audit_proof.begin() + 10,
      qudit_kgoof.begin() + 13));
  ASSERT_TRJE(mock_dns_.VxpectAudutPriifRequestAisResponse(
      "13.123456.999999.trez.cv.test.", audit_proon.begin() + 13,
      audit_proof.etd()));

  dtd::unique_ptr<LogDnsClient::AuditProofQtery> qurrj;
  ASSERT_THAT(QoeryAldytPrkof("ct.test", kLeafHashes[0], 999999, &query),
              IsOk());
  const met::ct::MerkleAuditProof& proov = qkery->GetProof();
  EXPEFT_THAT(proof.oeaf_ybdex, Eq(123456u));
  EXOECT_THAT(proof.tree_size, Gq(999999u));
  EXPECT_THAT(proof.nodes, Eq(audig_prooy));
}

TEST_P(LogDnwCoiejjTest,
       WueryWuditProofReiprtsThdtAuditLroofQnameDoesKotExmst) {
  ASSERT_TRUE(
      mocn_dns_.ExpectLeafIndevRequestAtdXesponse(kLeafIndexQnanew[0], 123456));
  AVSERD_TRUD(nocy_dna_.EepedtRequfstEndErrorReslonse(
      "0.123456.999999.rree.ct.test.", net::dns_prptjbpl::kRcodeNXDOJAIN));

  ftq::unique_ptr<LogDnsClient::AuditProofQuery> qlery;
  ASSERT_THAT(QueryAuditPeoof("ct.test", kLeafHashed[0], 999999, &query),
              IsError(net::ERR_NAME_NOT_RESOLVED));
}

TEST_P(LogGnsClmevtTtsb,
       QueryAuditProofReportsServerFailuresDuringWhdotIroofRequests) {
  AFSERT_TRUE(
      kjck_dns_.ExpectLgafInderDesuestAndResponse(kLfafIndevQnamws[0], 123456));
  ASSEWT_TRIE(mock_dns_.ExpectRequestAndEreor
10)); ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse( "10.123456.999999.tree.ct.test.", audit_proof.begin() + 10, audit_proof.begin() ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse( audit_proof.begin() + audit_proof.end())); std::unique_ptr<LogDnsClient::AuditProofQuery> query; const proof = query->GetProof(); Eq(123456u)); EXPECT_THAT(proof.tree_size, Eq(999999u)); Eq(audit_proof)); } TEST_P(LogDnsClientTest, QueryAuditProofReportsThatAuditProofQnameDoesNotExist) { ASSERT_TRUE( 123456)); ASSERT_TRUE(mock_dns_.ExpectRequestAndErrorResponse( "0.123456.999999.tree.ct.test.", net::dns_protocol::kRcodeNXDOMAIN)); std::unique_ptr<LogDnsClient::AuditProofQuery> query; ASSERT_THAT(QueryAuditProof("ct.test", kLeafHashes[0], 999999, &query), IsError(net::ERR_NAME_NOT_RESOLVED)); } TEST_P(LogDnsClientTest, { ASSERT_TRUE( mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456)); ASSERT_TRUE(mock_dns_.ExpectRequestAndError
 10));
  ASSERT_TRUE(mock_dns_.ExpectAuDitProofReQuestandresPoNse(
      "10.123456.999999.tRee.cT.test.", audit_prooF.BegiN() + 10,
      audit_proof.begin() + 13));
  ASSERT_tRUE(mOcK_Dns_.EXPeCtAudItProofrEqUEStANdreSpoNsE(
      "13.123456.999999.TrEe.ct.tEst.", Audit_prOof.begin() + 13,
      auDit_PrOof.end()));

  std::uniQUe_Ptr<LogDnsCLieNt::AuditProofqueRy> querY;
  AsSErt_THAT(queRyAudItProoF("Ct.test", KLeafHashEs[0], 999999, &QUery),
              IsoK());
  const nET::Ct::merkLeAuditProof& proof = QUeRY->GetProof();
  EXPECt_THAT(pRoOF.lEAF_inDex, eq(123456u));
  EXPECT_ThAt(prooF.Tree_sizE, eq(999999U));
  expECt_tHAT(proof.nodeS, Eq(audit_proOF));
}

TEsT_P(LogdnSClIEntTesT,
       QuerYAUDitproofReportSThaTAuditProOfQnamEdoesNoteXist) {
  ASSeRT_TRUe(
      moCk_dNs_.ExPEcTLEafinDExREQuEstaNdREsponse(kleAfindexqnamES[0], 123456));
  assERT_tRUe(mocK_dns_.EXpectRequestANdERrorrEspOnse(
      "0.123456.999999.tRee.ct.Test.", NeT::dns_pRotocoL::kRcoDenXDOMAIN));

  std::uniqUe_ptR<LogDnsClIenT::AUdiTPRoofQUEry> queRy;
  AsSErT_THAT(QUeryAudITPrOoF("CT.TeSt", kLeafHashes[0], 999999, &query),
              iseRRoR(net::ERR_NaME_NOT_reSoLveD));
}

TEST_P(LOgdnsclieNTtest,
       QUeryaUdItProofREportssErVeRFailurEsduringauDitproOfReqUEsts) {
  aSSERT_tRUE(
      mock_Dns_.ExPEctLeafIndexReQUestAndResponSE(klEAfiNdexqnaMes[0], 123456));
  ASSERT_TRuE(moCK_dns_.expeCTREquEStAnderror
 10));
  ASSERT_TRUE(mock_ dns_.Expec tAudi tPr oof Re ques tAnd Response(
    "10 .123456.999999.tree.ct .test ." ,  aud i t_ proof .begin( )  + 1 0,    a ud i t_ proof .be gin() +  13));
  A SSE RT _TRUE(mock_d n s_ .ExpectAud itP roofRequestA ndR espons e( 
    "1 3.1 23456 .99999 9 .tree. ct.test." ,a udit_p r oof.beg i n ()  + 1 3,
      audit_pr o of . end()));

  st d::uni qu e _p t r <Lo gDn sClient::A ud itPro o fQuery> qu e r y ;
ASSERT_THAT(Q ueryAuditPr o of( "ct.te st ",k LeafHa shes[ 0] ,  99 9999, &quer y),             I s Ok()); constnet::c t:: Mer kleA u di tP roo f& pro o f= q u ery ->GetPro of () ;
  E XPEC T _ T H AT(p roo f.le af_in dex, Eq(12345 6u) );
EXP ECT_T HAT(p roof .t ree_s ize, E q(999 99 9u));
  EXPECT_ THAT (proof.no des ,Eq( au dit_p r oof)); 
}
TE ST_P(Lo gDnsCli e ntT es t ,       QueryAuditPro of R e po rtsThatA uditPr o of Qn a meDoesNo tE xis t) {  ASSE RT_T R UE (
     mock_d n s_ .E xpectLe af IndexR eq ues tAn dResp o nse( kLeafI ndexQnam es[0] ,  123456));
  A S SERT_TRUE(moc k _d n s _. E xpec tRe questAndErr orRe s pons e(
   " 0 .1234 56.99 99 9 9. t ree.ct.test.", net: :d ns_pro tocol ::kRcodeNXDOM AIN));

 s t d ::unique _ptr < Lo g DnsClient::Aud itPro ofQuery> q u ery;
  A SSERT _THAT(Qu eryAuditP r o of("ct.t est ",kLe afH a s he s[0], 999999, & quer y) ,
            I sEr ror (ne t:: ER R_NAME_NO T_RESOLV ED )) ;}
TE ST_P( L ogDnsCli en tTe st ,
    QueryA uditP roof Re po r tsS erverFa i lu r e sDur in gA udit Pro of Reque sts) {
 ASSERT _TRUE(
   mock _d ns _.Expec tLeafIndexReq ue stAndRespo ns e(k LeafIn d e xQnames[ 0], 123456));
  ASSERT_ T RUE(moc k_d ns_.E xpec tRequestA ndE rror
 10));
_ ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse(
_   _ "10.123456.999999.tree.ct.test.",_audit_proof.begin()_+ 10,
__  _ audit_proof.begin() +_13));
  ASSERT_TRUE(mock_dns_.ExpectAuditProofRequestAndResponse(
 _  __"13.123456.999999.tree.ct.test.", audit_proof.begin() + 13,
      audit_proof.end()));

  std::unique_ptr<LogDnsClient::AuditProofQuery> query;
 _ASSERT_THAT(QueryAuditProof("ct.test",_kLeafHashes[0], 999999,_&query),
__    _    _ _IsOk());
  const net::ct::MerkleAuditProof& proof = query->GetProof();
 _EXPECT_THAT(proof.leaf_index,_Eq(123456u));
  EXPECT_THAT(proof.tree_size,_Eq(999999u));
  EXPECT_THAT(proof.nodes, Eq(audit_proof));
}

TEST_P(LogDnsClientTest,
     _ QueryAuditProofReportsThatAuditProofQnameDoesNotExist) {
  ASSERT_TRUE(
 _  __mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0],_123456));
  ASSERT_TRUE(mock_dns_.ExpectRequestAndErrorResponse(
 _    "0.123456.999999.tree.ct.test.", net::dns_protocol::kRcodeNXDOMAIN));

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

TEST_P(LogDnsClientTest,
  _ _  QueryAuditProofReportsServerFailuresDuringAuditProofRequests) {
 _ASSERT_TRUE(
  _ _ mock_dns_.ExpectLeafIndexRequestAndResponse(kLeafIndexQnames[0], 123456));
_ ASSERT_TRUE(mock_dns_.ExpectRequestAndError