Relax STTx test failure criterion:

FIXES: #3106

Different versions of protobuf produce subtly different
results when given invalid message payloads. This leads to
subtly different behavior when we try to deserialize these
invalid messages. As such, we can't tie success to a
particular exception.
This commit is contained in:
Mike Ellery
2019-10-16 15:30:01 -07:00
committed by Manoj doshi
parent b2317f8b41
commit cd01502d17

View File

@@ -1419,16 +1419,27 @@ public:
try
{
protocol::TMTransaction tx2;
tx2.ParseFromArray(payload1, sizeof(payload1));
// In all versions of protobuf, the parsing of this payload fails.
// However, different versions of protobuf will leave the parsed
// message (tx2) in different states. Versions 3.10+ seem to clear
// the message, whereas earlier versions would leave the message
// in a partial state. The varying nature of the failed-parsed
// message means that the STTx constructor will throw slightly
// different exceptions: for version 3.10+ we get
// "Transaction length invalid" whereas the half-parsed message
// from earlier versions results in "Unknown field". Either way,
// we expect an exception from STTx, but the specific message will
// vary.
BEAST_EXPECT(! tx2.ParseFromArray(payload1, sizeof(payload1)));
ripple::SerialIter sit (ripple::makeSlice(tx2.rawtransaction()));
auto stx = std::make_shared<ripple::STTx const>(sit);
fail("An exception should have been thrown");
}
catch (std::exception const& ex)
catch (std::exception const&)
{
BEAST_EXPECT(strcmp(ex.what(), "Unknown field") == 0);
pass();
}
try