20 #include <ripple/net/DatabaseDownloader.h>
21 #include <boost/filesystem/operations.hpp>
25 #include <test/jtx/TrustedPublisherServer.h>
26 #include <test/unit_test/FileDirGuard.h>
31 #define REPORT_FAILURE(D) reportFailure(D, __FILE__, __LINE__)
54 boost::filesystem::path
dest;
61 dest = std::move(dst);
88 env.app().getIOService(),
116 ss <<
"Failed. LOGS:\n"
118 <<
"\nDownloadCompleter failure."
119 "\nDatabaseDownloader session active? "
124 fail(ss.
str(), file, line);
131 (
verify ?
"Verify" :
"No Verify");
139 if ((cfg->SSL_VERIFY =
verify))
140 cfg->SSL_VERIFY_FILE = cert.file().string();
152 *
this,
"downloads",
"data",
"",
false,
false};
155 auto stat = dl->download(
156 server->local_endpoint().address().to_string(),
162 if (!BEAST_EXPECT(stat))
172 BEAST_EXPECT(
cb.
dest == data.file());
173 if (!BEAST_EXPECT(boost::filesystem::exists(data.file())))
175 BEAST_EXPECT(boost::filesystem::file_size(data.file()) > 0);
181 testcase(
"Error conditions");
189 boost::system::error_code ec;
191 auto const results = resolver.resolve(
"badhostname",
"443", ec);
200 *
this,
"downloads",
"data",
"",
false,
false};
201 BEAST_EXPECT(dl->download(
213 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
215 dl.sink_.messages().str().find(
"async_resolve") !=
217 dl.sink_.messages().str());
224 *
this,
"downloads",
"data",
"",
false,
false};
226 auto host = server->local_endpoint().address().to_string();
229 BEAST_EXPECT(dl->download(
235 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
240 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
242 dl.sink_.messages().str().find(
"async_connect") !=
244 dl.sink_.messages().str());
250 *
this,
"downloads",
"data",
"",
false,
false};
252 BEAST_EXPECT(dl->download(
253 server->local_endpoint().address().to_string(),
258 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
263 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
265 dl.sink_.messages().str().find(
"async_handshake") !=
267 dl.sink_.messages().str());
273 *
this,
"downloads",
"data",
"",
false,
false};
275 BEAST_EXPECT(dl->download(
276 server->local_endpoint().address().to_string(),
281 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
286 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
288 dl.sink_.messages().str().find(
"Insufficient disk space") !=
290 dl.sink_.messages().str());
304 #undef REPORT_FAILURE