mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Get names of transactions and ledger types from jss
This commit is contained in:
committed by
Manoj doshi
parent
be139d9bde
commit
b39b0fef39
@@ -40,7 +40,7 @@ create (jtx::Account const& account,
|
||||
jv[sfAccount.jsonName] = account.human();
|
||||
jv[sfSendMax.jsonName] = sendMax.getJson(0);
|
||||
jv[sfDestination.jsonName] = dest.human();
|
||||
jv[sfTransactionType.jsonName] = "CheckCreate";
|
||||
jv[sfTransactionType.jsonName] = jss::CheckCreate;
|
||||
jv[sfFlags.jsonName] = tfUniversal;
|
||||
return jv;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ cash (jtx::Account const& dest,
|
||||
jv[sfAccount.jsonName] = dest.human();
|
||||
jv[sfAmount.jsonName] = amount.getJson(0);
|
||||
jv[sfCheckID.jsonName] = to_string (checkId);
|
||||
jv[sfTransactionType.jsonName] = "CheckCash";
|
||||
jv[sfTransactionType.jsonName] = jss::CheckCash;
|
||||
jv[sfFlags.jsonName] = tfUniversal;
|
||||
return jv;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ cash (jtx::Account const& dest,
|
||||
jv[sfAccount.jsonName] = dest.human();
|
||||
jv[sfDeliverMin.jsonName] = atLeast.value.getJson(0);
|
||||
jv[sfCheckID.jsonName] = to_string (checkId);
|
||||
jv[sfTransactionType.jsonName] = "CheckCash";
|
||||
jv[sfTransactionType.jsonName] = jss::CheckCash;
|
||||
jv[sfFlags.jsonName] = tfUniversal;
|
||||
return jv;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ cancel (jtx::Account const& dest, uint256 const& checkId)
|
||||
Json::Value jv;
|
||||
jv[sfAccount.jsonName] = dest.human();
|
||||
jv[sfCheckID.jsonName] = to_string (checkId);
|
||||
jv[sfTransactionType.jsonName] = "CheckCancel";
|
||||
jv[sfTransactionType.jsonName] = jss::CheckCancel;
|
||||
jv[sfFlags.jsonName] = tfUniversal;
|
||||
return jv;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class Discrepancy_test : public beast::unit_test::suite
|
||||
else if(an.isMember(sfDeletedNode.fieldName))
|
||||
node = an[sfDeletedNode.fieldName];
|
||||
|
||||
if(node && node[sfLedgerEntryType.fieldName] == "AccountRoot")
|
||||
if(node && node[sfLedgerEntryType.fieldName] == jss::AccountRoot)
|
||||
{
|
||||
Json::Value prevFields =
|
||||
node.isMember(sfPreviousFields.fieldName) ?
|
||||
|
||||
@@ -171,7 +171,7 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "EscrowCreate";
|
||||
jv[jss::TransactionType] = jss::EscrowCreate;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[jss::Destination] = to.human();
|
||||
@@ -185,7 +185,7 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
jtx::Account const& from, std::uint32_t seq)
|
||||
{
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "EscrowFinish";
|
||||
jv[jss::TransactionType] = jss::EscrowFinish;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfOwner.jsonName] = from.human();
|
||||
@@ -199,7 +199,7 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
jtx::Account const& from, std::uint32_t seq)
|
||||
{
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "EscrowCancel";
|
||||
jv[jss::TransactionType] = jss::EscrowCancel;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfOwner.jsonName] = from.human();
|
||||
|
||||
@@ -415,7 +415,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
|
||||
auto let =
|
||||
affected[0u][sfModifiedNode.fieldName][sfLedgerEntryType.fieldName];
|
||||
BEAST_EXPECT(let == "AccountRoot");
|
||||
BEAST_EXPECT(let == jss::AccountRoot);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -85,7 +85,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
retval.hashes = [&] {
|
||||
for(auto const& it : retval.ledger[jss::ledger][jss::accountState])
|
||||
{
|
||||
if(it[sfLedgerEntryType.fieldName] == "LedgerHashes")
|
||||
if(it[sfLedgerEntryType.fieldName] == jss::LedgerHashes)
|
||||
return it[sfHashes.fieldName];
|
||||
}
|
||||
return Json::Value {};
|
||||
|
||||
@@ -481,7 +481,7 @@ public:
|
||||
auto setup_tx = [&]() -> Json::Value {
|
||||
Json::Value jv;
|
||||
jv[jss::tx_json][jss::Account] = alice.human();
|
||||
jv[jss::tx_json][jss::TransactionType] = "AccountSet";
|
||||
jv[jss::tx_json][jss::TransactionType] = jss::AccountSet;
|
||||
jv[jss::tx_json][jss::Fee] = static_cast<uint32_t>(8 * baseFee);
|
||||
jv[jss::tx_json][jss::Sequence] = env.seq(alice);
|
||||
jv[jss::tx_json][jss::SigningPubKey] = "";
|
||||
@@ -951,7 +951,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = alice.human();
|
||||
cancelOffer[jss::OfferSequence] = offerSeq;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer, seq (aliceSeq),
|
||||
msig (becky, bogie), fee(3 * baseFee));
|
||||
env.close();
|
||||
@@ -1220,7 +1220,7 @@ public:
|
||||
jvSig1[jss::tx_json][jss::Destination] = env.master.human();
|
||||
jvSig1[jss::tx_json][jss::Fee] = 3 * baseFee;
|
||||
jvSig1[jss::tx_json][jss::Sequence] = env.seq(alice);
|
||||
jvSig1[jss::tx_json][jss::TransactionType] = "Payment";
|
||||
jvSig1[jss::tx_json][jss::TransactionType] = jss::Payment;
|
||||
|
||||
Json::Value jvSig2 = env.rpc (
|
||||
"json", "sign_for", to_string (jvSig1));
|
||||
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = alice.human();
|
||||
cancelOffer[jss::OfferSequence] = offer4Seq;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer);
|
||||
}
|
||||
env.close();
|
||||
@@ -1180,7 +1180,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = account_to_test.human();
|
||||
cancelOffer[jss::OfferSequence] = secondLegSeq;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer);
|
||||
env.require (offers (account_to_test, 0));
|
||||
|
||||
@@ -1432,7 +1432,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = env.master.human();
|
||||
cancelOffer[jss::OfferSequence] = nextOfferSeq;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer);
|
||||
BEAST_EXPECT(env.seq (env.master) == nextOfferSeq + 2);
|
||||
|
||||
@@ -1464,7 +1464,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = env.master.human();
|
||||
cancelOffer[jss::OfferSequence] = nextOfferSeq;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer);
|
||||
|
||||
cancelOffer[jss::OfferSequence] = env.seq (env.master);
|
||||
|
||||
@@ -109,7 +109,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "PaymentChannelCreate";
|
||||
jv[jss::TransactionType] = jss::PaymentChannelCreate;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human ();
|
||||
jv[jss::Destination] = to.human ();
|
||||
@@ -132,7 +132,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "PaymentChannelFund";
|
||||
jv[jss::TransactionType] = jss::PaymentChannelFund;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human ();
|
||||
jv["Channel"] = to_string (channel);
|
||||
@@ -153,7 +153,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = "PaymentChannelClaim";
|
||||
jv[jss::TransactionType] = jss::PaymentChannelClaim;
|
||||
jv[jss::Flags] = tfUniversal;
|
||||
jv[jss::Account] = account.human ();
|
||||
jv["Channel"] = to_string (channel);
|
||||
|
||||
@@ -40,7 +40,7 @@ struct SetAuth_test : public beast::unit_test::suite
|
||||
jv[jss::Account] = account.human();
|
||||
jv[jss::LimitAmount] = STAmount(
|
||||
{ to_currency(currency), dest }).getJson(0);
|
||||
jv[jss::TransactionType] = "TrustSet";
|
||||
jv[jss::TransactionType] = jss::TrustSet;
|
||||
jv[jss::Flags] = tfSetfAuth;
|
||||
return jv;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
Json::Value jv;
|
||||
jv[jss::Account] = a.human();
|
||||
jv[jss::LimitAmount] = amt.getJson(0);
|
||||
jv[jss::TransactionType] = "TrustSet";
|
||||
jv[jss::TransactionType] = jss::TrustSet;
|
||||
jv[jss::Flags] = 0;
|
||||
return jv;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Ticket_test : public beast::unit_test::suite
|
||||
{
|
||||
using namespace std::string_literals;
|
||||
auto const& tx = env.tx ()->getJson (0);
|
||||
bool is_cancel = tx[jss::TransactionType] == "TicketCancel";
|
||||
bool is_cancel = tx[jss::TransactionType] == jss::TicketCancel;
|
||||
|
||||
auto const& jvm = env.meta ()->getJson (0);
|
||||
std::array<Json::Value, 4> retval;
|
||||
@@ -61,32 +61,26 @@ class Ticket_test : public beast::unit_test::suite
|
||||
// a few different scenarios.
|
||||
// tuple is index, field name, and label (LedgerEntryType)
|
||||
std::vector<
|
||||
std::tuple<std::size_t, std::string, std::string>
|
||||
std::tuple<std::size_t, std::string, Json::StaticString>
|
||||
> expected_nodes;
|
||||
|
||||
if (is_cancel && other_target)
|
||||
{
|
||||
expected_nodes = {
|
||||
std::make_tuple(0, sfModifiedNode.fieldName, "AccountRoot"s),
|
||||
std::make_tuple(
|
||||
expiration ? 2: 1, sfModifiedNode.fieldName, "AccountRoot"s),
|
||||
std::make_tuple(
|
||||
expiration ? 1: 2, sfDeletedNode.fieldName, "Ticket"s),
|
||||
std::make_tuple(3, sfDeletedNode.fieldName, "DirectoryNode"s)
|
||||
{0, sfModifiedNode.fieldName, jss::AccountRoot},
|
||||
{expiration ? 2: 1, sfModifiedNode.fieldName, jss::AccountRoot},
|
||||
{expiration ? 1: 2, sfDeletedNode.fieldName, jss::Ticket},
|
||||
{3, sfDeletedNode.fieldName, jss::DirectoryNode}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
expected_nodes = {
|
||||
std::make_tuple(0, sfModifiedNode.fieldName, "AccountRoot"s),
|
||||
std::make_tuple(1,
|
||||
is_cancel ?
|
||||
sfDeletedNode.fieldName : sfCreatedNode.fieldName,
|
||||
"Ticket"s),
|
||||
std::make_tuple(2,
|
||||
is_cancel ?
|
||||
sfDeletedNode.fieldName : sfCreatedNode.fieldName,
|
||||
"DirectoryNode"s)
|
||||
{0, sfModifiedNode.fieldName, jss::AccountRoot},
|
||||
{1, is_cancel ? sfDeletedNode.fieldName :
|
||||
sfCreatedNode.fieldName, jss::Ticket},
|
||||
{2, is_cancel ? sfDeletedNode.fieldName :
|
||||
sfCreatedNode.fieldName, jss::DirectoryNode}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -241,7 +235,7 @@ class Ticket_test : public beast::unit_test::suite
|
||||
auto const& jticket = cr[1];
|
||||
BEAST_EXPECT(
|
||||
jacct[sfFinalFields.fieldName][sfOwnerCount.fieldName] == 1);
|
||||
BEAST_EXPECT(jticket[sfLedgerEntryType.fieldName] == "Ticket");
|
||||
BEAST_EXPECT(jticket[sfLedgerEntryType.fieldName] == jss::Ticket);
|
||||
BEAST_EXPECT(jticket[sfLedgerIndex.fieldName] ==
|
||||
"C231BA31A0E13A4D524A75F990CE0D6890B800FF1AE75E51A2D33559547AC1A2");
|
||||
BEAST_EXPECT(jticket[sfNewFields.fieldName][jss::Account] ==
|
||||
@@ -330,7 +324,7 @@ class Ticket_test : public beast::unit_test::suite
|
||||
auto const& jacct =
|
||||
jvm[sfAffectedNodes.fieldName][0u][sfModifiedNode.fieldName];
|
||||
BEAST_EXPECT(
|
||||
jacct[sfLedgerEntryType.fieldName] == "AccountRoot");
|
||||
jacct[sfLedgerEntryType.fieldName] == jss::AccountRoot);
|
||||
BEAST_EXPECT(jacct[sfFinalFields.fieldName][jss::Account] ==
|
||||
env.master.human());
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ class TrustAndBalance_test : public beast::unit_test::suite
|
||||
[](auto const& jv)
|
||||
{
|
||||
auto const& t = jv[jss::transaction];
|
||||
return t[jss::TransactionType] == "Payment";
|
||||
return t[jss::TransactionType] == jss::Payment;
|
||||
}));
|
||||
BEAST_EXPECT(wsc->findMsg(5s,
|
||||
[](auto const& jv)
|
||||
@@ -477,7 +477,7 @@ class TrustAndBalance_test : public beast::unit_test::suite
|
||||
{
|
||||
auto const& t = jv[jss::transaction];
|
||||
return
|
||||
t[jss::TransactionType] == "Payment" &&
|
||||
t[jss::TransactionType] == jss::Payment &&
|
||||
t[sfInvoiceID.fieldName] ==
|
||||
"0000000000000000"
|
||||
"0000000000000000"
|
||||
|
||||
@@ -1756,7 +1756,7 @@ public:
|
||||
Json::Value cancelOffer;
|
||||
cancelOffer[jss::Account] = alice.human();
|
||||
cancelOffer[jss::OfferSequence] = 3;
|
||||
cancelOffer[jss::TransactionType] = "OfferCancel";
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
auto const jtx = env.jt(cancelOffer,
|
||||
seq(1), fee(10));
|
||||
auto const pf = preflight(env.app(), env.current()->rules(),
|
||||
@@ -1798,7 +1798,7 @@ public:
|
||||
Json::Value cancelTicket;
|
||||
cancelTicket[jss::Account] = alice.human();
|
||||
cancelTicket["TicketID"] = to_string(uint256());
|
||||
cancelTicket[jss::TransactionType] = "TicketCancel";
|
||||
cancelTicket[jss::TransactionType] = jss::TicketCancel;
|
||||
auto const jtx = env.jt(cancelTicket,
|
||||
seq(1), fee(10));
|
||||
auto const pf = preflight(env.app(), env.current()->rules(),
|
||||
|
||||
Reference in New Issue
Block a user