TEST_F(EncryptedRecordTest, TestSkipAndRead) {
  Sequence s;
  read_.setSkipFailedDecryption(true);
  addToQueue("1703010005012345678917030100050123456789170301000501234567aa");
  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
      .InSequence(s)
      .WillOnce(
          Invoke([](std::unique_ptr<IOBuf>& /*buf*/, const IOBuf*, uint64_t) {
            return folly::none;
          }));
  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
      .InSequence(s)
      .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
        expectSame(buf, "0123456789");
        return getBuf("1234abcd17");
      }));
  auto msg = read_.read(queue_);
  EXPECT_EQ(msg->type, ContentType::application_data);
  expectSame(msg->fragment, "1234abcd");
  EXPECT_EQ(queue_.chainLength(), 10);
  EXPECT_CALL(*readAead_, _decrypt(_, _, 1))
      .InSequence(s)
      .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
        expectSame(buf, "01234567aa");
        return getBuf("1234abaa17");
      }));
  msg = read_.read(queue_);
  EXPECT_EQ(msg->type, ContentType::application_data);
  expectSame(msg->fragment, "1234abaa");
  EXPECT_TRUE(queue_.empty());
}
TEST_F(EncryptedRecordTest, TestSkipAndRead) {
  Sequence s;
  read_.setSkipFailedDecryption(true);
  addToQueue("1703010005012345678917030100050123456789170301000501234567aa");
  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
      .InSequence(s)
      .WillOnce(
          Invoke([](std::unique_ptr<IOBuf>&  , const IOBuf*, uint64_t) {
            return folly::none;
          }));
  EXPECT_CALL(*readAead_, _tryDecrypt(_, _, 0))
      .InSequence(s)
      .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
        expectSame(buf, "0123456789");
        return getBuf("1234abcd17");
      }));
  auto msg = read_.read(queue_);
  EXPECT_EQ(msg->type, ContentType::application_data);
  expectSame(msg->fragment, "1234abcd");
  EXPECT_EQ(queue_.chainLength(), 10);
  EXPECT_CALL(*readAead_, _decrypt(_, _, 1))
      .InSequence(s)
      .WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
        expectSame(buf, "01234567aa");
        return getBuf("1234abaa17");
      }));
  msg = read_.read(queue_);
  EXPECT_EQ(msg->type, ContentType::application_data);
  expectSame(msg->fragment, "1234abaa");
  EXPECT_TRUE(queue_.empty());
}