Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/test/overlay/compression_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,37 @@ class compression_test : public beast::unit_test::Suite
"TMValidatorListCollection");
}

void
testMtSquelchUncompressed()
{
testcase("mtSQUELCH is uncompressed");

//construct >70 so should be eligible for compression
auto squelch = std::make_shared<protocol::TMSquelch>();
squelch->set_squelch(true);
// Use a large validatorPubKey to push the message over the 70-byte
// threshold that triggers compression
std::string largePubKey(256, 'A');
squelch->set_validatorpubkey(largePubKey);
squelch->set_squelchduration(600);

Message m(*squelch, protocol::mtSQUELCH);

auto const& compressed = m.getBuffer(Compressed::On);
auto const& uncompressed = m.getBuffer(Compressed::Off);

BEAST_EXPECT(compressed.size() == uncompressed.size());
BEAST_EXPECT(compressed == uncompressed);

log << " Uncompressed size: " << uncompressed.size() << " bytes\n";
log << " 'Compressed' size: " << compressed.size() << " bytes\n";
log << " Buffers are identical: "
<< (compressed == uncompressed
? "YES (mtSQUELCH is non-compressible)"
: "NO — REGRESSION")
<< std::endl;
}

void
testHandshake()
{
Expand Down Expand Up @@ -455,6 +486,7 @@ class compression_test : public beast::unit_test::Suite
{
testProtocol();
testHandshake();
testMtSquelchUncompressed();
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/xrpld/overlay/detail/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Message::compress()
if (messageBytes <= 70)
return false;

// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
switch (type)
{
case protocol::mtMANIFESTS:
Expand All @@ -97,6 +96,11 @@ Message::compress()
case protocol::mtPROOF_PATH_RESPONSE:
case protocol::mtREPLAY_DELTA_REQ:
case protocol::mtHAVE_TRANSACTIONS:
case protocol::mtSQUELCH:
break;
default:
XRPL_ASSERT(
false, "xrpl::Message::compress : unknown message type");
break;
}
return false;
Expand Down