void expectFill ( std::string const& label, Type status, Status::Strings messages, std::string const& message) { value_.clear (); fillJson (Status (status, messages)); auto prefix = label + ": "; expect (!value_.empty(), prefix + "No value"); auto error = value_[jss::error]; expect (!error.empty(), prefix + "No error."); auto code = error[jss::code].asInt(); expect (status == code, prefix + "Wrong status " + std::to_string (code) + " != " + std::to_string (status)); auto m = error[jss::message].asString (); expect (m == message, m + " != " + message); auto d = error[jss::data]; size_t s1 = d.size(), s2 = messages.size(); expect (s1 == s2, prefix + "Data sizes differ " + std::to_string (s1) + " != " + std::to_string (s2)); for (auto i = 0; i < std::min (s1, s2); ++i) { auto ds = d[i].asString(); expect (ds == messages[i], prefix + ds + " != " + messages[i]); } }
void addJson (Json::Value& json, LedgerFill const& fill) { auto&& object = Json::addObject (json, jss::ledger); fillJson (object, fill); if ((fill.options & LedgerFill::dumpQueue) && !fill.txQueue.empty()) fillJsonQueue(json, fill); }
void test_OK () { testcase ("OK"); fillJson (Status ()); expect (value_.empty(), "Value for empty status"); fillJson (0); expect (value_.empty(), "Value for 0 status"); fillJson (Status::OK); expect (value_.empty(), "Value for OK status"); fillJson (tesSUCCESS); expect (value_.empty(), "Value for tesSUCCESS"); fillJson (rpcSUCCESS); expect (value_.empty(), "Value for rpcSUCCESS"); }
Json::Value getJson (LedgerFill const& fill) { Json::Value json; fillJson (json, fill); return json; }