2019-01-26 12:33:34 +00:00
|
|
|
#ifndef TEST_LLARP_DHT_MOCK_CONTEXT
|
|
|
|
#define TEST_LLARP_DHT_MOCK_CONTEXT
|
2019-01-22 23:50:26 +00:00
|
|
|
|
|
|
|
#include <dht/context.hpp>
|
|
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace test
|
|
|
|
{
|
|
|
|
struct MockContext final : public dht::AbstractContext
|
|
|
|
{
|
2019-07-19 17:21:20 +00:00
|
|
|
MOCK_CONST_METHOD1(StoreRC, void(const RouterContact));
|
|
|
|
|
2019-01-22 23:50:26 +00:00
|
|
|
MOCK_METHOD2(LookupRouter, bool(const RouterID&, RouterLookupHandler));
|
|
|
|
|
2019-04-12 15:29:48 +00:00
|
|
|
MOCK_METHOD5(LookupRouterRecursive,
|
|
|
|
void(const RouterID&, const dht::Key_t&, uint64_t,
|
|
|
|
const dht::Key_t&, RouterLookupHandler));
|
|
|
|
|
2020-02-20 18:18:05 +00:00
|
|
|
MOCK_METHOD6(LookupIntroSetRelayed,
|
2020-01-27 21:30:41 +00:00
|
|
|
void(const dht::Key_t&, const dht::Key_t&, uint64_t,
|
2020-02-20 18:18:05 +00:00
|
|
|
const dht::Key_t&, uint64_t,
|
2020-01-27 21:30:41 +00:00
|
|
|
service::EncryptedIntroSetLookupHandler));
|
2019-01-22 23:50:26 +00:00
|
|
|
|
2020-02-20 18:18:05 +00:00
|
|
|
MOCK_METHOD5(LookupIntroSetDirect,
|
2020-01-27 21:30:41 +00:00
|
|
|
void(const dht::Key_t&, const dht::Key_t&, uint64_t,
|
|
|
|
const dht::Key_t&,
|
|
|
|
service::EncryptedIntroSetLookupHandler));
|
2019-01-22 23:50:26 +00:00
|
|
|
|
2019-02-22 15:08:00 +00:00
|
|
|
MOCK_CONST_METHOD1(HasRouterLookup, bool(const RouterID& target));
|
|
|
|
|
|
|
|
MOCK_METHOD4(LookupRouterForPath,
|
|
|
|
void(const RouterID& target, uint64_t txid,
|
|
|
|
const PathID_t& path, const dht::Key_t& askpeer));
|
|
|
|
|
2020-02-20 18:18:05 +00:00
|
|
|
MOCK_METHOD5(LookupIntroSetForPath,
|
2020-01-27 21:30:41 +00:00
|
|
|
void(const dht::Key_t&, uint64_t, const PathID_t&,
|
2020-02-20 18:18:05 +00:00
|
|
|
const dht::Key_t&, uint64_t));
|
2019-02-22 15:08:00 +00:00
|
|
|
|
2019-01-22 23:50:26 +00:00
|
|
|
MOCK_METHOD3(DHTSendTo, void(const RouterID&, dht::IMessage*, bool));
|
|
|
|
|
2019-02-22 15:08:00 +00:00
|
|
|
MOCK_METHOD4(
|
|
|
|
HandleExploritoryRouterLookup,
|
|
|
|
bool(const dht::Key_t& requester, uint64_t txid,
|
|
|
|
const RouterID& target,
|
|
|
|
std::vector< std::unique_ptr< dht::IMessage > >& reply));
|
|
|
|
|
|
|
|
MOCK_METHOD5(
|
|
|
|
LookupRouterRelayed,
|
|
|
|
void(const dht::Key_t& requester, uint64_t txid,
|
|
|
|
const dht::Key_t& target, bool recursive,
|
|
|
|
std::vector< std::unique_ptr< dht::IMessage > >& replies));
|
|
|
|
|
|
|
|
MOCK_METHOD2(RelayRequestForPath,
|
2019-04-22 17:38:29 +00:00
|
|
|
bool(const PathID_t& localPath, const dht::IMessage& msg));
|
2019-02-22 15:08:00 +00:00
|
|
|
|
2019-03-27 12:36:27 +00:00
|
|
|
MOCK_CONST_METHOD2(GetRCFromNodeDB,
|
|
|
|
bool(const dht::Key_t& k, RouterContact& rc));
|
|
|
|
|
2020-03-01 17:30:05 +00:00
|
|
|
MOCK_METHOD5(PropagateIntroSetTo,
|
2019-02-22 15:08:00 +00:00
|
|
|
void(const dht::Key_t& source, uint64_t sourceTX,
|
2020-01-27 21:30:41 +00:00
|
|
|
const service::EncryptedIntroSet& introset,
|
2020-03-01 17:30:05 +00:00
|
|
|
const dht::Key_t& peer, uint64_t relayOrder));
|
|
|
|
MOCK_METHOD5(PropagateLocalIntroSet,
|
|
|
|
void(const PathID_t& source, uint64_t sourceTX,
|
|
|
|
const service::EncryptedIntroSet& introset,
|
|
|
|
const dht::Key_t& peer, uint64_t relayOrder));
|
2019-02-22 15:08:00 +00:00
|
|
|
|
2020-02-27 16:37:23 +00:00
|
|
|
MOCK_METHOD2(Init,
|
|
|
|
void(const dht::Key_t&, AbstractRouter*));
|
2019-02-22 15:08:00 +00:00
|
|
|
|
2020-01-27 21:30:41 +00:00
|
|
|
MOCK_CONST_METHOD1(GetIntroSetByLocation,
|
2020-02-19 21:58:01 +00:00
|
|
|
nonstd::optional< llarp::service::EncryptedIntroSet >(
|
2020-01-27 21:30:41 +00:00
|
|
|
const llarp::dht::Key_t&));
|
2019-02-22 15:08:00 +00:00
|
|
|
|
|
|
|
MOCK_CONST_METHOD0(ExtractStatus, util::StatusObject());
|
|
|
|
|
2019-01-22 23:50:26 +00:00
|
|
|
MOCK_CONST_METHOD0(Now, llarp_time_t());
|
|
|
|
|
2019-02-22 15:08:00 +00:00
|
|
|
MOCK_METHOD1(ExploreNetworkVia, void(const dht::Key_t& peer));
|
2019-01-22 23:50:26 +00:00
|
|
|
|
2019-01-29 02:16:31 +00:00
|
|
|
MOCK_CONST_METHOD0(GetRouter, llarp::AbstractRouter*());
|
2019-01-22 23:50:26 +00:00
|
|
|
|
|
|
|
MOCK_CONST_METHOD0(OurKey, const dht::Key_t&());
|
|
|
|
|
2019-02-22 15:08:00 +00:00
|
|
|
MOCK_CONST_METHOD0(pendingIntrosetLookups,
|
|
|
|
const PendingIntrosetLookups&());
|
|
|
|
MOCK_METHOD0(pendingIntrosetLookups, PendingIntrosetLookups&());
|
|
|
|
|
|
|
|
MOCK_METHOD0(pendingRouterLookups, PendingRouterLookups&());
|
|
|
|
|
|
|
|
MOCK_CONST_METHOD0(pendingRouterLookups, const PendingRouterLookups&());
|
|
|
|
|
|
|
|
MOCK_METHOD0(pendingExploreLookups, PendingExploreLookups&());
|
|
|
|
|
|
|
|
MOCK_CONST_METHOD0(pendingExploreLookups, const PendingExploreLookups&());
|
|
|
|
|
|
|
|
MOCK_METHOD0(services, dht::Bucket< dht::ISNode >*());
|
|
|
|
|
|
|
|
MOCK_CONST_METHOD0(AllowTransit, const bool&());
|
|
|
|
MOCK_METHOD0(AllowTransit, bool&());
|
|
|
|
|
2019-01-22 23:50:26 +00:00
|
|
|
MOCK_CONST_METHOD0(Nodes, dht::Bucket< dht::RCNode >*());
|
2019-06-26 21:39:29 +00:00
|
|
|
MOCK_METHOD1(PutRCNodeAsync, void(const dht::RCNode& val));
|
|
|
|
MOCK_METHOD1(DelRCNodeAsync, void(const dht::Key_t& val));
|
2020-01-21 17:31:48 +00:00
|
|
|
|
|
|
|
MOCK_METHOD2(FloodRCLater, void(const dht::Key_t, const RouterContact));
|
2019-01-22 23:50:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|