Skip to content

Commit 1052f73

Browse files
committed
[WIP] Find everywhere Json is written to the log
* Get rid of operator<<(std::ostream&, const Value& root), and fix everything that breaks.
1 parent c4308b2 commit 1052f73

33 files changed

Lines changed: 300 additions & 232 deletions

include/xrpl/json/json_writer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ valueToQuotedString(const char* value);
211211

212212
/// \brief Output using the StyledStreamWriter.
213213
/// \see Json::operator>>()
214-
std::ostream&
215-
operator<<(std::ostream&, const Value& root);
214+
// std::ostream&
215+
// operator<<(std::ostream&, const Value& root);
216216

217217
//------------------------------------------------------------------------------
218218

include/xrpl/json/to_string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ to_string(Value const&);
3535
std::string
3636
pretty(Value const&);
3737

38-
/** Output using the StyledStreamWriter. @see Json::operator>>(). */
39-
std::ostream&
40-
operator<<(std::ostream&, const Value& root);
38+
///** Output using the StyledStreamWriter. @see Json::operator>>(). */
39+
// std::ostream&
40+
// operator<<(std::ostream&, const Value& root);
4141

4242
} // namespace Json
4343

include/xrpl/protocol/STBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class STBase
157157
virtual std::string
158158
getText() const;
159159

160-
virtual Json::Value getJson(JsonOptions /*options*/) const;
160+
virtual Json::Value getJson(
161+
JsonOptions = JsonOptions::none /*options*/) const;
161162

162163
virtual void
163164
add(Serializer& s) const;

include/xrpl/protocol/STValidation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <xrpl/basics/Log.h>
2424
#include <xrpl/beast/utility/instrumentation.h>
25+
#include <xrpl/json/to_string.h>
2526
#include <xrpl/protocol/FeeUnits.h>
2627
#include <xrpl/protocol/PublicKey.h>
2728
#include <xrpl/protocol/STObject.h>
@@ -190,7 +191,7 @@ STValidation::STValidation(
190191
if (checkSignature && !isValid())
191192
{
192193
JLOG(debugLog().error()) << "Invalid signature in validation: "
193-
<< getJson(JsonOptions::none);
194+
<< to_string(getJson(JsonOptions::none));
194195
Throw<std::runtime_error>("Invalid signature in validation");
195196
}
196197

src/test/app/NFTokenBurn_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class NFTokenBurnBaseUtil_test : public beast::unit_test::suite
416416
Json::Value jrr = env.rpc(
417417
"json",
418418
"ledger_data",
419-
boost::lexical_cast<std::string>(jvParams));
419+
boost::lexical_cast<std::string>(to_string(jvParams)));
420420

421421
Json::Value& state = jrr[jss::result][jss::state];
422422

@@ -463,7 +463,7 @@ class NFTokenBurnBaseUtil_test : public beast::unit_test::suite
463463
Json::Value jrr = env.rpc(
464464
"json",
465465
"ledger_data",
466-
boost::lexical_cast<std::string>(jvParams));
466+
boost::lexical_cast<std::string>(to_string(jvParams)));
467467

468468
Json::Value& state = jrr[jss::result][jss::state];
469469

src/test/app/NFTokenDir_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class NFTokenDir_test : public beast::unit_test::suite
5050
Json::Value jrr = env.rpc(
5151
"json",
5252
"ledger_data",
53-
boost::lexical_cast<std::string>(jvParams));
53+
boost::lexical_cast<std::string>(to_string(jvParams)));
5454

5555
// Iterate the state and print all NFTokenPages.
5656
if (!jrr.isMember(jss::result) ||

src/test/app/Oracle_test.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <test/jtx/Oracle.h>
2121

22+
#include <xrpl/json/to_string.h>
2223
#include <xrpl/protocol/jss.h>
2324

2425
namespace ripple {
@@ -580,10 +581,8 @@ struct Oracle_test : public beast::unit_test::suite
580581
jvParams[field] = value;
581582
jvParams[jss::binary] = false;
582583
jvParams[jss::type] = jss::oracle;
583-
Json::Value jrr = env.rpc(
584-
"json",
585-
"ledger_data",
586-
boost::lexical_cast<std::string>(jvParams));
584+
Json::Value jrr =
585+
env.rpc("json", "ledger_data", to_string(jvParams));
587586
BEAST_EXPECT(jrr[jss::result][jss::state].size() == 2);
588587
};
589588
verifyLedgerData(jss::ledger_index, index);

src/test/json/json_value_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <xrpl/json/json_reader.h>
2323
#include <xrpl/json/json_value.h>
2424
#include <xrpl/json/json_writer.h>
25+
#include <xrpl/json/to_string.h>
2526

2627
#include <algorithm>
2728
#include <regex>
@@ -833,7 +834,8 @@ struct json_value_test : beast::unit_test::suite
833834
BEAST_EXPECT(r.parse(s, j));
834835
{
835836
std::stringstream ss;
836-
ss << j;
837+
// UNDO
838+
ss << pretty(j);
837839
BEAST_EXPECT(countLines(ss.str()) > 1);
838840
}
839841
{

src/test/jtx/TestSuite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RIPPLE_BASICS_TESTSUITE_H_INCLUDED
2222

2323
#include <xrpl/beast/unit_test.h>
24+
#include <xrpl/json/to_string.h>
2425

2526
#include <string>
2627

src/test/jtx/impl/Env.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Env::sign_and_submit(JTx const& jt, Json::Value params)
355355
if (params.isNull())
356356
{
357357
// Use the command line interface
358-
auto const jv = boost::lexical_cast<std::string>(jt.jv);
358+
auto const jv = boost::lexical_cast<std::string>(to_string(jt.jv));
359359
jr = rpc("submit", passphrase, jv);
360360
}
361361
else

0 commit comments

Comments
 (0)