20 #include <ripple/net/DatabaseDownloader.h>
22 #include <test/jtx/TrustedPublisherServer.h>
23 #include <test/unit_test/FileDirGuard.h>
24 #include <boost/filesystem/operations.hpp>
25 #include <boost/predef.h>
52 boost::filesystem::path
dest;
58 dest = std::move(dst);
65 using namespace std::chrono_literals;
67 auto constexpr timeout = 4s;
69 auto constexpr timeout = 2s;
88 , ptr_ {std::make_shared<DatabaseDownloader>(
89 env.app().getIOService(), journal_, env.app().config())}
103 (
verify ?
"Verify" :
"No Verify");
112 if ((cfg->SSL_VERIFY =
verify))
113 cfg->SSL_VERIFY_FILE = cert.file().string();
125 *
this,
"downloads",
"data",
"",
false,
false};
128 auto stat = downloader->download(
129 server.local_endpoint().address().to_string(),
134 std::function<
void(boost::filesystem::path)> {std::ref(cb)});
135 if (!BEAST_EXPECT(stat))
137 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
142 log <<
"Failed. LOGS:\n" + downloader.sink_.messages().str();
145 BEAST_EXPECT(
cb.
dest == data.file());
146 if (!BEAST_EXPECT(boost::filesystem::exists(data.file())))
148 BEAST_EXPECT(boost::filesystem::file_size(data.file()) > 0);
154 testcase(
"Error conditions");
162 boost::system::error_code ec;
164 auto const results = resolver.resolve(
"badhostname",
"443", ec);
173 *
this,
"downloads",
"data",
"",
false,
false};
174 BEAST_EXPECT(dl->download(
180 std::function<
void(boost::filesystem::path)> {std::ref(cb)}));
182 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
184 dl.sink_.messages().str().find(
"async_resolve")
185 != std::string::npos,
186 dl.sink_.messages().str());
193 *
this,
"downloads",
"data",
"",
false,
false};
195 auto host = server.local_endpoint().address().to_string();
198 BEAST_EXPECT(dl->download(
204 std::function<
void(boost::filesystem::path)> {std::ref(cb)}));
206 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
208 dl.sink_.messages().str().find(
"async_connect")
209 != std::string::npos,
210 dl.sink_.messages().str());
216 *
this,
"downloads",
"data",
"",
false,
false};
218 BEAST_EXPECT(dl->download(
219 server.local_endpoint().address().to_string(),
224 std::function<
void(boost::filesystem::path)> {std::ref(cb)}));
226 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
228 dl.sink_.messages().str().find(
"async_handshake")
229 != std::string::npos,
230 dl.sink_.messages().str());
236 *
this,
"downloads",
"data",
"",
false,
false};
238 BEAST_EXPECT(dl->download(
239 server.local_endpoint().address().to_string(),
244 std::function<
void(boost::filesystem::path)> {std::ref(cb)}));
246 BEAST_EXPECT(!boost::filesystem::exists(datafile.file()));
248 dl.sink_.messages().str().find(
"Insufficient disk space")
249 != std::string::npos,
250 dl.sink_.messages().str());