diff --git a/src/ripple/rpc/handlers/AccountTx.cpp b/src/ripple/rpc/handlers/AccountTx.cpp index 052b8ae9edb..4514f8e2a3b 100644 --- a/src/ripple/rpc/handlers/AccountTx.cpp +++ b/src/ripple/rpc/handlers/AccountTx.cpp @@ -340,6 +340,12 @@ populateJsonResponse( jvObj[jss::ledger_hash] = to_string(context.ledgerMaster.getHashBySeq( txn->getLedger())); + + if (auto closeTime = + context.ledgerMaster.getCloseTimeBySeq( + txn->getLedger())) + jvObj[jss::close_time_iso] = + to_string_iso(*closeTime); } else jvObj[json_tx] = txn->getJson( @@ -356,11 +362,6 @@ populateJsonResponse( insertDeliveredAmount( jvObj[jss::meta], context, txn, *txnMeta); insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); - if (auto closeTime = - context.ledgerMaster.getCloseTimeBySeq( - txnMeta->getIndex())) - jvObj[jss::close_time_iso] = - to_string_iso(*closeTime); } } } diff --git a/src/test/rpc/AccountTx_test.cpp b/src/test/rpc/AccountTx_test.cpp index 3cfcda75847..3834d623dca 100644 --- a/src/test/rpc/AccountTx_test.cpp +++ b/src/test/rpc/AccountTx_test.cpp @@ -137,17 +137,36 @@ class AccountTx_test : public beast::unit_test::suite j[jss::result][jss::transactions][1u][jss::tx] [jss::DeliverMax]); case 2: - return j.isMember(jss::result) && + 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) && - (j[jss::result][jss::transactions][1u][jss::tx_json] - [jss::TransactionType] == jss::Payment) && - (j[jss::result][jss::transactions][1u][jss::tx_json] - [jss::DeliverMax] == "10000000010") && - (!j[jss::result][jss::transactions][1u][jss::tx_json] - .isMember(jss::Amount)); + [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; }