/* -*- 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/>.
 */

#ifndef NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP
#define NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP

#include "face/face.hpp"

namespace nfd::tests {

class DummyLinkService;

/** \brief A Face for unit testing.
 *
 *  The DummyFace has no underlying transport, but allows observing outgoing packets
 *  and injecting incoming packets at network layer.
 *  It's primarily used for forwarding test suites, but can be used in other tests as well.
 *
 *  Outgoing network-layer packets sent through the DummyFace are recorded in sent* vectors,
 *  which can be observed in test cases.
 *  Incoming network-layer packets can be injected from test cases through receive* method.
 */
class DummyFace : public Face
{
public:
  explicit
  DummyFace(const std::string& localUri = "dummy://", const std::string& remoteUri = "dummy://",
            ndn::nfd::FaceScope scope = ndn::nfd::FACE_SCOPE_NON_LOCAL,
            ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
            ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_POINT_TO_POINT);

  /** \brief changes face state
   *  \throw std::runtime_error state transition is invalid
   */
  void
  setState(face::FaceState state);

  /** \brief causes the face to receive an Interest
   */
  void
  receiveInterest(const Interest& interest, const EndpointId& endpointId = {});

  /** \brief causes the face to receive a Data
   */
  void
  receiveData(const Data& data, const EndpointId& endpointId = {});

  /** \brief causes the face to receive a Nack
   */
  void
  receiveNack(const lp::Nack& nack, const EndpointId& endpointId = {});

  /** \brief Emitted after a network-layer packet is sent.
   *
   *  The packet type is reported via the argument, whose value will be one of
   *  tlv::Interest, tlv::Data, or lp::tlv::Nack. Signal handlers may retrieve
   *  the packet via `sentInterests.back()`, `sentData.back()`, or `sentNacks.back()`.
   */
  signal::Signal<DummyLinkService, uint32_t>& afterSend;

private:
  DummyLinkService*
  getDummyLinkService() const;

public:
  std::vector<Interest>& sentInterests;
  std::vector<Data>& sentData;
  std::vector<lp::Nack>& sentNacks;
};

} // namespace nfd::tests

#endif // NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP
