ipfs-chromium
Loading...
Searching...
No Matches
mock_gw_cfg.h
1#ifndef IPFS_CHROMIUM_MOCK_GW_CFG_H
2#define IPFS_CHROMIUM_MOCK_GW_CFG_H
3
4#include <ipfs_client/ctx/gateway_config.h>
5
6//NOLINT
7
8namespace i = ipfs;
9namespace ig = i::gw;
10
11namespace {
12struct MockGwCfg final : public ipfs::ctx::GatewayConfig {
13 std::vector<i::GatewaySpec> index_gettable_gateways;
14 std::optional<i::GatewaySpec> GetGateway(std::size_t i) const {
15 if (i < index_gettable_gateways.size()) {
16 return index_gettable_gateways.at(i);
17 }
18 return std::nullopt;
19 }
20 unsigned GetGatewayRate(std::string_view) { return 120U; }
21 std::vector<std::string> gateways_added;
22 void AddGateway(std::string_view g) { gateways_added.emplace_back(g); }
23 void AddGateway(std::string_view g, unsigned) {
24 gateways_added.emplace_back(g);
25 }
26 void SetGatewayRate(std::string_view, unsigned int) override {}
27 unsigned RoutingApiDiscoveryDefaultRate() const { return 9; }
28 virtual ~MockGwCfg() noexcept override {}
29 bool http_disc_ = true;
30 bool RoutingApiDiscoveryOfUnencryptedGateways() const { return http_disc_; }
31 int GetTypeAffinity(std::string_view url_prefix,
32 ig::GatewayRequestType) const {
33 return 0;
34 }
35 void SetTypeAffinity(std::string_view url_prefix,
36 ig::GatewayRequestType,
37 int) {}
38};
39} // namespace
40
41#endif // IPFS_CHROMIUM_MOCK_GW_CFG_H
Definition gateway_config.h:13