20 #include <ripple/net/DatabaseDownloader.h>
21 #include <boost/filesystem/operations.hpp>
22 #include <boost/predef.h>
26 #include <test/jtx/TrustedPublisherServer.h>
27 #include <test/unit_test/FileDirGuard.h>
53 boost::filesystem::path
dest;
60 dest = std::move(dst);
68 using namespace std::chrono_literals;
70 auto constexpr timeout = 4s;
72 auto constexpr timeout = 2s;
90 env.app().getIOService(),
112 (
verify ?
"Verify" :
"No Verify");
120 if ((cfg->SSL_VERIFY =
verify))
121 cfg->SSL_VERIFY_FILE = cert.file().string();
133 *
this,
"downloads",
"data",
"",
false,
false};
136 auto stat = downloader->download(
137 server->local_endpoint().address().to_string(),
143 if (!BEAST_EXPECT(stat))
145 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
150 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
153 BEAST_EXPECT(
cb.
dest == data.file());
154 if (!BEAST_EXPECT(boost::filesystem::exists(data.file())))
156 BEAST_EXPECT(boost::filesystem::file_size(data.file()) > 0);
162 testcase(
"Error conditions");
170 boost::system::error_code ec;
172 auto const results = resolver.resolve(
"badhostname",
"443", ec);
181 *
this,
"downloads",
"data",
"",
false,
false};
182 BEAST_EXPECT(dl->download(
191 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
193 dl.sink_.messages().str().find(
"async_resolve") !=
195 dl.sink_.messages().str());
202 *
this,
"downloads",
"data",
"",
false,
false};
204 auto host = server->local_endpoint().address().to_string();
207 BEAST_EXPECT(dl->download(
213 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
215 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
217 dl.sink_.messages().str().find(
"async_connect") !=
219 dl.sink_.messages().str());
225 *
this,
"downloads",
"data",
"",
false,
false};
227 BEAST_EXPECT(dl->download(
228 server->local_endpoint().address().to_string(),
233 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
235 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
237 dl.sink_.messages().str().find(
"async_handshake") !=
239 dl.sink_.messages().str());
245 *
this,
"downloads",
"data",
"",
false,
false};
247 BEAST_EXPECT(dl->download(
248 server->local_endpoint().address().to_string(),
253 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
255 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
257 dl.sink_.messages().str().find(
"Insufficient disk space") !=
259 dl.sink_.messages().str());