/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "table/pit-entry.hpp"

#include "tests/test-common.hpp"
#include "tests/daemon/global-io-fixture.hpp"
#include "tests/daemon/face/dummy-face.hpp"

#include <boost/test/data/test_case.hpp>

namespace bdata = boost::unit_test::data;

namespace nfd {
namespace pit {
namespace tests {

using namespace nfd::tests;

BOOST_AUTO_TEST_SUITE(Table)
BOOST_FIXTURE_TEST_SUITE(TestPitEntry, GlobalIoFixture)

BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(CanMatch, 1)
BOOST_AUTO_TEST_CASE(CanMatch)
{
  auto interest0 = makeInterest("/A");
  Entry entry(*interest0);

  auto interest1 = makeInterest("/B");
  BOOST_CHECK_EQUAL(entry.canMatch(*interest1), false);

  auto interest2 = makeInterest("/A", false, std::nullopt, 27956);
  BOOST_CHECK_EQUAL(entry.canMatch(*interest2), true);

  auto interest3 = makeInterest("/A", false, 6210_ms);
  BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true);

  auto interest4 = makeInterest("/A");
  interest4->setForwardingHint({"/telia/terabits", "/ucla/cs"});
  BOOST_CHECK_EQUAL(entry.canMatch(*interest4), false); // expected failure until #3162

  auto interest5 = makeInterest("/A", true);
  BOOST_CHECK_EQUAL(entry.canMatch(*interest5), false);
}

BOOST_AUTO_TEST_CASE(InOutRecords)
{
  auto face1 = make_shared<DummyFace>();
  auto face2 = make_shared<DummyFace>();

  Name name("/KuYfjtRq");
  auto interest = makeInterest(name);
  auto interest1 = makeInterest(name, false, 2528_ms, 25559);
  auto interest2 = makeInterest(name, false, 6464_ms, 19004);
  auto interest3 = makeInterest(name, false, 3585_ms, 24216);
  auto interest4 = makeInterest(name, false, 8795_ms, 17365);

  Entry entry(*interest);

  BOOST_CHECK_EQUAL(entry.getInterest().getName(), name);
  BOOST_CHECK_EQUAL(entry.getName(), name);

  const InRecordCollection& inRecords1 = entry.getInRecords();
  BOOST_CHECK_EQUAL(inRecords1.size(), 0);
  const OutRecordCollection& outRecords1 = entry.getOutRecords();
  BOOST_CHECK_EQUAL(outRecords1.size(), 0);

  // insert in-record
  auto before1 = time::steady_clock::now();
  InRecordCollection::iterator in1 = entry.insertOrUpdateInRecord(*face1, *interest1);
  auto after1 = time::steady_clock::now();
  const InRecordCollection& inRecords2 = entry.getInRecords();
  BOOST_CHECK_EQUAL(inRecords2.size(), 1);
  BOOST_CHECK(in1 == inRecords2.begin());
  BOOST_CHECK_EQUAL(&in1->getFace(), face1.get());
  BOOST_CHECK_EQUAL(in1->getLastNonce(), interest1->getNonce());
  BOOST_CHECK_GE(in1->getLastRenewed(), before1);
  BOOST_CHECK_LE(in1->getLastRenewed(), after1);
  BOOST_CHECK_LE(in1->getExpiry() - in1->getLastRenewed() - interest1->getInterestLifetime(),
                 after1 - before1);
  BOOST_CHECK(in1 == entry.getInRecord(*face1));

  // insert out-record
  auto before2 = time::steady_clock::now();
  OutRecordCollection::iterator out1 = entry.insertOrUpdateOutRecord(*face1, *interest1);
  auto after2 = time::steady_clock::now();
  const OutRecordCollection& outRecords2 = entry.getOutRecords();
  BOOST_CHECK_EQUAL(outRecords2.size(), 1);
  BOOST_CHECK(out1 == outRecords2.begin());
  BOOST_CHECK_EQUAL(&out1->getFace(), face1.get());
  BOOST_CHECK_EQUAL(out1->getLastNonce(), interest1->getNonce());
  BOOST_CHECK_GE(out1->getLastRenewed(), before2);
  BOOST_CHECK_LE(out1->getLastRenewed(), after2);
  BOOST_CHECK_LE(out1->getExpiry() - out1->getLastRenewed() - interest1->getInterestLifetime(),
                 after2 - before2);
  BOOST_CHECK(out1 == entry.getOutRecord(*face1));

  // update in-record
  auto before3 = time::steady_clock::now();
  InRecordCollection::iterator in2 = entry.insertOrUpdateInRecord(*face1, *interest2);
  auto after3 = time::steady_clock::now();
  const InRecordCollection& inRecords3 = entry.getInRecords();
  BOOST_CHECK_EQUAL(inRecords3.size(), 1);
  BOOST_CHECK(in2 == inRecords3.begin());
  BOOST_CHECK_EQUAL(&in2->getFace(), face1.get());
  BOOST_CHECK_EQUAL(in2->getLastNonce(), interest2->getNonce());
  BOOST_CHECK_LE(in2->getExpiry() - in2->getLastRenewed() - interest2->getInterestLifetime(),
                 after3 - before3);

  // insert another in-record
  InRecordCollection::iterator in3 = entry.insertOrUpdateInRecord(*face2, *interest3);
  const InRecordCollection& inRecords4 = entry.getInRecords();
  BOOST_CHECK_EQUAL(inRecords4.size(), 2);
  BOOST_CHECK_EQUAL(&in3->getFace(), face2.get());

  // get in-record
  InRecordCollection::iterator in4 = entry.getInRecord(*face1);
  BOOST_REQUIRE(in4 != entry.in_end());
  BOOST_CHECK_EQUAL(&in4->getFace(), face1.get());

  // delete in-record
  entry.deleteInRecord(*face1);
  BOOST_CHECK_EQUAL(entry.getInRecords().size(), 1);
  BOOST_CHECK(entry.getInRecord(*face1) == entry.in_end());

  // clear in-records
  entry.clearInRecords();
  BOOST_CHECK_EQUAL(entry.getInRecords().size(), 0);
  BOOST_CHECK(entry.getInRecord(*face1) == entry.in_end());
  BOOST_CHECK(entry.getInRecord(*face2) == entry.in_end());

  // insert another out-record
  OutRecordCollection::iterator out2 = entry.insertOrUpdateOutRecord(*face2, *interest4);
  const OutRecordCollection& outRecords3 = entry.getOutRecords();
  BOOST_CHECK_EQUAL(outRecords3.size(), 2);
  BOOST_CHECK_EQUAL(&out2->getFace(), face2.get());

  // get out-record
  OutRecordCollection::iterator out3 = entry.getOutRecord(*face1);
  BOOST_REQUIRE(out3 != entry.out_end());
  BOOST_CHECK_EQUAL(&out3->getFace(), face1.get());

  // delete out-record
  entry.deleteOutRecord(*face2);
  const OutRecordCollection& outRecords4 = entry.getOutRecords();
  BOOST_REQUIRE_EQUAL(outRecords4.size(), 1);
  BOOST_CHECK_EQUAL(&outRecords4.begin()->getFace(), face1.get());
  BOOST_CHECK(entry.getOutRecord(*face2) == entry.out_end());
}

const time::milliseconds lifetimes[] = {
  -1_ms, // unset
  1_ms,
  ndn::DEFAULT_INTEREST_LIFETIME,
  8624_ms,
  86400_s,
  time::milliseconds(std::numeric_limits<time::milliseconds::rep>::max()),
};

BOOST_DATA_TEST_CASE(Lifetime, bdata::make(lifetimes), lifetime)
{
  auto interest = makeInterest("/7oIEurbgy6");
  if (lifetime >= 0_ms) {
    interest->setInterestLifetime(lifetime);
  }

  auto expectedLifetime = lifetime;
  if (lifetime < 0_ms) {
    expectedLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
  }
  else if (lifetime > 10_days) {
    expectedLifetime = 10_days;
  }

  auto face = make_shared<DummyFace>();
  Entry entry(*interest);

  auto inIt = entry.insertOrUpdateInRecord(*face, *interest);
  auto expiryFromNow = inIt->getExpiry() - time::steady_clock::now();
  BOOST_CHECK_GT(expiryFromNow, 0_ms);
  BOOST_CHECK_LT(time::abs(expiryFromNow - expectedLifetime), 100_ms);

  auto outIt = entry.insertOrUpdateOutRecord(*face, *interest);
  expiryFromNow = outIt->getExpiry() - time::steady_clock::now();
  BOOST_CHECK_GT(expiryFromNow, 0_ms);
  BOOST_CHECK_LT(time::abs(expiryFromNow - expectedLifetime), 100_ms);
}

BOOST_AUTO_TEST_CASE(OutRecordNack)
{
  auto face1 = make_shared<DummyFace>();
  OutRecord outR(*face1);
  BOOST_CHECK(outR.getIncomingNack() == nullptr);

  auto interest1 = makeInterest("/uWiapGjYL");
  interest1->setNonce(165);
  outR.update(*interest1);
  BOOST_CHECK(outR.getIncomingNack() == nullptr);

  auto interest2 = makeInterest("/uWiapGjYL");
  interest2->setNonce(996);
  lp::Nack nack2(*interest2);
  nack2.setReason(lp::NackReason::CONGESTION);
  BOOST_CHECK_EQUAL(outR.setIncomingNack(nack2), false);
  BOOST_CHECK(outR.getIncomingNack() == nullptr);

  lp::Nack nack1(*interest1);
  nack1.setReason(lp::NackReason::DUPLICATE);
  BOOST_CHECK_EQUAL(outR.setIncomingNack(nack1), true);
  BOOST_REQUIRE(outR.getIncomingNack() != nullptr);
  BOOST_CHECK_EQUAL(outR.getIncomingNack()->getReason(), lp::NackReason::DUPLICATE);

  outR.clearIncomingNack();
  BOOST_CHECK(outR.getIncomingNack() == nullptr);
}

BOOST_AUTO_TEST_SUITE_END() // TestPitEntry
BOOST_AUTO_TEST_SUITE_END() // Table

} // namespace tests
} // namespace pit
} // namespace nfd
