@@ -74,12 +74,6 @@ struct Api final : public i::Client {
7474 void AddGateway (std::string_view) {}
7575 virtual ~Api () noexcept {}
7676};
77- std::vector<std::string> log_lines;
78- std::string all_log;
79- void save_log (std::string const & msg, char const *, int , il::Level) {
80- log_lines.push_back (msg);
81- all_log.append (msg).push_back (' ;' );
82- }
8377} // namespace
8478
8579TEST (IpnsRecordTest, AKnownKuboRecord) {
@@ -432,13 +426,17 @@ TEST(IpnsRecordTest, ValueMismatch) {
432426 auto real_validates = ipfs::ValidateIpnsRecord (i::as_bytes (xxd), cid, api);
433427 EXPECT_TRUE (real_validates);
434428 xxd[12 ]++;// cause a mismatch
435- il::SetLevel (il::Level::Error);
436- il::SetHandler (save_log);
429+ // il::SetLevel(il::Level::Error);
430+ // il::SetHandler(save_log);
431+ LogRecorder rec;
437432 auto modified_validates = ipfs::ValidateIpnsRecord (i::as_bytes (xxd), cid, api);
438- EXPECT_FALSE (modified_validates) << all_log;
439- il::SetHandler (il::DefaultHandler);
440- EXPECT_EQ (log_lines.size (),1UL ) << all_log;
441- auto & log_line = log_lines.at (0 );
442- EXPECT_LT (log_line.find (" Mismatch on Value" ),log_line.size ()) << all_log;
433+ EXPECT_FALSE (modified_validates);
434+ // il::SetHandler(il::DefaultHandler);
435+ // EXPECT_EQ(log_lines.size(),1UL);
436+ // auto& log_line = log_lines.at(0);
437+ // EXPECT_LT(log_line.find("Mismatch on Value"),log_line.size()) << all_log;
438+ auto is_expected = [](auto &m){return m.message .find (" Mismatch on Value" ) < m.message .size ();};
439+ auto expected_log = std::count_if (rec.messages .begin (), rec.messages .end (), is_expected);
440+ EXPECT_EQ (expected_log, 1 );
443441}
444442#endif
0 commit comments