Disallow both single- and multi-signing in RPC (RIPD-1713):

The ledger already declared a transaction that is both single-
and multi-signing malformed.  This just adds some checking in
the signing RPC commands (like submit and sign_for) which allows
that sort of error to be identified a bit closer to the user.

In the process of adding this code a bug was found in the
RPCCall unit test.  That bug is fixed as well.
This commit is contained in:
Scott Schurr
2019-01-23 16:29:20 -08:00
committed by Nik Bougalis
parent d8c450d272
commit 36d6758945
5 changed files with 184 additions and 88 deletions

View File

@@ -6970,10 +6970,20 @@ public:
Json::Value exp;
Json::Reader{}.parse (rpcCallTest.exp, exp);
// If there is an "error_code" field, remove it. Error codes
// are not expected to stay stable between releases.
got.removeMember ("error_code");
exp.removeMember ("error_code");
// Lambda to remove the "params[0u]:error_code" field if present.
// Error codes are not expected to be stable between releases.
auto rmErrorCode = [] (Json::Value& json)
{
if (json.isMember (jss::params) &&
json[jss::params].isArray() &&
json[jss::params].size() > 0 &&
json[jss::params][0u].isObject())
{
json[jss::params][0u].removeMember (jss::error_code);
}
};
rmErrorCode (got);
rmErrorCode (exp);
// Pass if we didn't expect a throw and we got what we expected.
if ((rpcCallTest.throwsWhat == RPCCallTestData::no_exception) &&