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>
51 boost::filesystem::path
dest;
58 dest = std::move(dst);
66 using namespace std::chrono_literals;
68 auto constexpr timeout = 4s;
70 auto constexpr timeout = 2s;
89 , ptr_{std::make_shared<DatabaseDownloader>(
90 env.app().getIOService(),
107 (
verify ?
"Verify" :
"No Verify");
115 if ((cfg->SSL_VERIFY =
verify))
116 cfg->SSL_VERIFY_FILE = cert.file().string();
128 *
this,
"downloads",
"data",
"",
false,
false};
131 auto stat = downloader->download(
132 server.local_endpoint().address().to_string(),
138 if (!BEAST_EXPECT(stat))
140 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
145 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
148 BEAST_EXPECT(
cb.
dest == data.file());
149 if (!BEAST_EXPECT(boost::filesystem::exists(data.file())))
151 BEAST_EXPECT(boost::filesystem::file_size(data.file()) > 0);
157 testcase(
"Error conditions");
165 boost::system::error_code ec;
167 auto const results = resolver.resolve(
"badhostname",
"443", ec);
176 *
this,
"downloads",
"data",
"",
false,
false};
177 BEAST_EXPECT(dl->download(
186 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
188 dl.sink_.messages().str().find(
"async_resolve") !=
190 dl.sink_.messages().str());
197 *
this,
"downloads",
"data",
"",
false,
false};
199 auto host = server.local_endpoint().address().to_string();
202 BEAST_EXPECT(dl->download(
208 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
210 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
212 dl.sink_.messages().str().find(
"async_connect") !=
214 dl.sink_.messages().str());
220 *
this,
"downloads",
"data",
"",
false,
false};
222 BEAST_EXPECT(dl->download(
223 server.local_endpoint().address().to_string(),
228 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
230 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
232 dl.sink_.messages().str().find(
"async_handshake") !=
234 dl.sink_.messages().str());
240 *
this,
"downloads",
"data",
"",
false,
false};
242 BEAST_EXPECT(dl->download(
243 server.local_endpoint().address().to_string(),
248 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
250 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
252 dl.sink_.messages().str().find(
"Insufficient disk space") !=
254 dl.sink_.messages().str());