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;
88 env.app().getIOService(),
110 (
verify ?
"Verify" :
"No Verify");
118 if ((cfg->SSL_VERIFY =
verify))
119 cfg->SSL_VERIFY_FILE = cert.file().string();
131 *
this,
"downloads",
"data",
"",
false,
false};
134 auto stat = downloader->download(
135 server->local_endpoint().address().to_string(),
141 if (!BEAST_EXPECT(stat))
143 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
148 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
151 BEAST_EXPECT(
cb.
dest == data.file());
152 if (!BEAST_EXPECT(boost::filesystem::exists(data.file())))
154 BEAST_EXPECT(boost::filesystem::file_size(data.file()) > 0);
160 testcase(
"Error conditions");
168 boost::system::error_code ec;
170 auto const results = resolver.resolve(
"badhostname",
"443", ec);
179 *
this,
"downloads",
"data",
"",
false,
false};
180 BEAST_EXPECT(dl->download(
189 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
191 dl.sink_.messages().str().find(
"async_resolve") !=
193 dl.sink_.messages().str());
200 *
this,
"downloads",
"data",
"",
false,
false};
202 auto host = server->local_endpoint().address().to_string();
205 BEAST_EXPECT(dl->download(
211 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
213 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
215 dl.sink_.messages().str().find(
"async_connect") !=
217 dl.sink_.messages().str());
223 *
this,
"downloads",
"data",
"",
false,
false};
225 BEAST_EXPECT(dl->download(
226 server->local_endpoint().address().to_string(),
231 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
233 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
235 dl.sink_.messages().str().find(
"async_handshake") !=
237 dl.sink_.messages().str());
243 *
this,
"downloads",
"data",
"",
false,
false};
245 BEAST_EXPECT(dl->download(
246 server->local_endpoint().address().to_string(),
251 std::function<
void(boost::filesystem::path)>{std::ref(cb)}));
253 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
255 dl.sink_.messages().str().find(
"Insufficient disk space") !=
257 dl.sink_.messages().str());