mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Unify JSON serialization format of transactions (#4775)
* Remove include <ranges> * Formatting fix * Output for subscriptions * Output from sign, submit etc. * Output from ledger * Output from account_tx * Output from transaction_entry * Output from tx * Store close_time_iso in API v2 output * Add small APIv2 unit test for subscribe * Add unit test for transaction_entry * Add unit test for tx * Remove inLedger from API version 2 * Set ledger_hash and ledger_index * Move isValidated from RPCHelpers to LedgerMaster * Store closeTime in LedgerFill * Time formatting fix * additional tests for Subscribe unit tests * Improved comments * Rename mInLedger to mLedgerIndex * Minor fixes * Set ledger_hash on closed ledger, even if not validated * Update API-CHANGELOG.md * Add ledger_hash, ledger_index to transaction_entry * Fix validated and close_time_iso in account_tx * Fix typos * Improve getJson for Transaction and STTx * Minor improvements * Replace class enum JsonOptions with struct We may consider turning this into a general-purpose template and using it elsewhere * simplify the extraction of transactionID from Transaction object * Remove obsolete comments * Unconditionally set validated in account_tx output * Minor improvements * Minor fixes --------- Co-authored-by: Chenna Keshava <ckeshavabs@gmail.com>
This commit is contained in:
@@ -120,22 +120,56 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
// All other ledgers have no txs
|
||||
|
||||
auto hasTxs = [apiVersion](Json::Value const& j) {
|
||||
return j.isMember(jss::result) &&
|
||||
(j[jss::result][jss::status] == "success") &&
|
||||
(j[jss::result][jss::transactions].size() == 2) &&
|
||||
(j[jss::result][jss::transactions][0u][jss::tx]
|
||||
[jss::TransactionType] == jss::AccountSet) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::TransactionType] == jss::Payment) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::DeliverMax] == "10000000010") &&
|
||||
((apiVersion > 1 &&
|
||||
!j[jss::result][jss::transactions][1u][jss::tx].isMember(
|
||||
jss::Amount)) ||
|
||||
(apiVersion <= 1 &&
|
||||
j[jss::result][jss::transactions][1u][jss::tx][jss::Amount] ==
|
||||
j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::DeliverMax]));
|
||||
switch (apiVersion)
|
||||
{
|
||||
case 1:
|
||||
return j.isMember(jss::result) &&
|
||||
(j[jss::result][jss::status] == "success") &&
|
||||
(j[jss::result][jss::transactions].size() == 2) &&
|
||||
(j[jss::result][jss::transactions][0u][jss::tx]
|
||||
[jss::TransactionType] == jss::AccountSet) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::TransactionType] == jss::Payment) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::DeliverMax] == "10000000010") &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::Amount] ==
|
||||
j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::DeliverMax]);
|
||||
case 2:
|
||||
if (j.isMember(jss::result) &&
|
||||
(j[jss::result][jss::status] == "success") &&
|
||||
(j[jss::result][jss::transactions].size() == 2) &&
|
||||
(j[jss::result][jss::transactions][0u][jss::tx_json]
|
||||
[jss::TransactionType] == jss::AccountSet))
|
||||
{
|
||||
auto const& payment =
|
||||
j[jss::result][jss::transactions][1u];
|
||||
|
||||
return (payment.isMember(jss::tx_json)) &&
|
||||
(payment[jss::tx_json][jss::TransactionType] ==
|
||||
jss::Payment) &&
|
||||
(payment[jss::tx_json][jss::DeliverMax] ==
|
||||
"10000000010") &&
|
||||
(!payment[jss::tx_json].isMember(jss::Amount)) &&
|
||||
(!payment[jss::tx_json].isMember(jss::hash)) &&
|
||||
(payment[jss::hash] ==
|
||||
"9F3085D85F472D1CC29627F260DF68EDE59D42D1D0C33E345"
|
||||
"ECF0D4CE981D0A8") &&
|
||||
(payment[jss::validated] == true) &&
|
||||
(payment[jss::ledger_index] == 3) &&
|
||||
(payment[jss::ledger_hash] ==
|
||||
"5476DCD816EA04CBBA57D47BBF1FC58A5217CC93A5ADD79CB"
|
||||
"580A5AFDD727E33") &&
|
||||
(payment[jss::close_time_iso] ==
|
||||
"2000-01-01T00:00:10Z");
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
auto noTxs = [](Json::Value const& j) {
|
||||
|
||||
Reference in New Issue
Block a user