Skip to content

Commit

Permalink
fixup! fixup! Cycle through more test ports to avoid slow close colli…
Browse files Browse the repository at this point in the history
…sions:
  • Loading branch information
ximinez committed Nov 12, 2024
1 parent 938a730 commit 0d78563
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/test/jtx/impl/JSONRPCClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ class JSONRPCClient : public AbstractClient
explicit JSONRPCClient(Config const& cfg, unsigned rpc_version)
: ep_(getEndpoint(cfg)), stream_(ios_), rpc_version_(rpc_version)
{
using namespace std::chrono_literals;
using namespace ripple::test::jtx;

Env::retry(
[&]() { stream_.connect(ep_); }, "JSONRPCClient connect", 250ms);
stream_.connect(ep_);
}

~JSONRPCClient() override
Expand Down Expand Up @@ -170,7 +166,15 @@ class JSONRPCClient : public AbstractClient
std::unique_ptr<AbstractClient>
makeJSONRPCClient(Config const& cfg, unsigned rpc_version)
{
return std::make_unique<JSONRPCClient>(cfg, rpc_version);
using namespace std::chrono_literals;
using namespace ripple::test::jtx;

std::unique_ptr<JSONRPCClient> ret;
Env::retry(
[&]() { ret = std::make_unique<JSONRPCClient>(cfg, rpc_version); },
"makeJSONRPCClient",
250ms);
return ret;
}

} // namespace test
Expand Down
19 changes: 13 additions & 6 deletions src/test/jtx/impl/WSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ class WSClientImpl : public WSClient
{
try
{
using namespace std::chrono_literals;
using namespace ripple::test::jtx;

auto const ep = getEndpoint(cfg, v2);
Env::retry(
[&]() { stream_.connect(ep); }, "WSClient connect", 250ms);
stream_.connect(ep);
ws_.set_option(boost::beast::websocket::stream_base::decorator(
[&](boost::beast::websocket::request_type& req) {
for (auto const& h : headers)
Expand Down Expand Up @@ -312,7 +308,18 @@ makeWSClient(
unsigned rpc_version,
std::unordered_map<std::string, std::string> const& headers)
{
return std::make_unique<WSClientImpl>(cfg, v2, rpc_version, headers);
using namespace std::chrono_literals;
using namespace ripple::test::jtx;

std::unique_ptr<WSClientImpl> ret;

Env::retry(
[&]() {
ret = std::make_unique<WSClientImpl>(cfg, v2, rpc_version, headers);
},
"makeWSClient",
250ms);
return ret;
}

} // namespace test
Expand Down

0 comments on commit 0d78563

Please sign in to comment.