From 3e0d6b9cd293dc5a1b62539a2e25cabc34f0dc0c Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Tue, 10 Feb 2026 07:52:02 +0700 Subject: [PATCH] fix: increment mSeq on queue drop and fix flaky connection-refused test - Advance mSeq when dropping events so consumers can detect gaps via sequence numbers, and log the dropped seq - Use ephemeral port (bind + close) instead of hardcoded 19999 for the connection-refused test to avoid false negatives on busy machines --- src/ripple/net/impl/RPCSub.cpp | 6 ++++-- src/test/net/HTTPClient_test.cpp | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ripple/net/impl/RPCSub.cpp b/src/ripple/net/impl/RPCSub.cpp index 3ecaac405..465165521 100644 --- a/src/ripple/net/impl/RPCSub.cpp +++ b/src/ripple/net/impl/RPCSub.cpp @@ -80,8 +80,10 @@ public: if (mDeque.size() >= maxQueueSize) { - JLOG(j_.warn()) << "RPCCall::fromNetwork drop: queue full (" - << mDeque.size() << "), endpoint=" << mIp; + JLOG(j_.warn()) + << "RPCCall::fromNetwork drop: queue full (" << mDeque.size() + << "), seq=" << mSeq << ", endpoint=" << mIp; + ++mSeq; return; } diff --git a/src/test/net/HTTPClient_test.cpp b/src/test/net/HTTPClient_test.cpp index d30c101fa..142690e4b 100644 --- a/src/test/net/HTTPClient_test.cpp +++ b/src/test/net/HTTPClient_test.cpp @@ -321,14 +321,21 @@ class HTTPClient_test : public beast::unit_test::suite using namespace jtx; Env env{*this}; - // No server listening — connection refused. - // Use a port that's very unlikely to be in use. + // Bind a port, then close it — guarantees nothing is listening. + boost::asio::io_service tmp; + boost::asio::ip::tcp::acceptor acc( + tmp, + boost::asio::ip::tcp::endpoint( + boost::asio::ip::address::from_string("127.0.0.1"), 0)); + auto port = acc.local_endpoint().port(); + acc.close(); + std::atomic completed{0}; auto j = env.app().journal("HTTPClient"); { boost::asio::io_service ios; - fireRequest(ios, "127.0.0.1", 19999, completed, j); + fireRequest(ios, "127.0.0.1", port, completed, j); ios.run(); }