mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
Fix account_tx response both both ledger range and ledger index/hash are specified (#904)
Fix mismatch with rippled
This commit is contained in:
@@ -105,15 +105,21 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
||||
if (input.ledgerHash || input.ledgerIndex || input.usingValidatedLedger)
|
||||
{
|
||||
if (ctx.apiVersion > 1u && (input.ledgerIndexMax || input.ledgerIndexMin))
|
||||
{
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "containsLedgerSpecifierAndRange"}};
|
||||
}
|
||||
else if (!input.ledgerIndexMax && !input.ledgerIndexMin)
|
||||
{
|
||||
// mimic rippled, when both range and index specified, respect the range.
|
||||
// take ledger from ledgerHash or ledgerIndex only when range is not specified
|
||||
auto const lgrInfoOrStatus = getLedgerInfoFromHashOrSeq(
|
||||
*sharedPtrBackend_, ctx.yield, input.ledgerHash, input.ledgerIndex, range->maxSequence);
|
||||
|
||||
auto const lgrInfoOrStatus = getLedgerInfoFromHashOrSeq(
|
||||
*sharedPtrBackend_, ctx.yield, input.ledgerHash, input.ledgerIndex, range->maxSequence);
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
maxIndex = minIndex = std::get<ripple::LedgerHeader>(lgrInfoOrStatus).seq;
|
||||
maxIndex = minIndex = std::get<ripple::LedgerHeader>(lgrInfoOrStatus).seq;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<data::TransactionsCursor> cursor;
|
||||
@@ -195,9 +201,6 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
||||
obj[JS(meta)] = ripple::strHex(txnPlusMeta.metadata);
|
||||
obj[JS(tx_blob)] = ripple::strHex(txnPlusMeta.transaction);
|
||||
obj[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
|
||||
if (ctx.apiVersion < 2u)
|
||||
obj[JS(inLedger)] = txnPlusMeta.ledgerSequence;
|
||||
}
|
||||
|
||||
obj[JS(validated)] = true;
|
||||
|
||||
@@ -371,14 +371,6 @@ TEST_P(AccountTxParameterTest, CheckParams)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (req.as_object().contains("ledger_hash"))
|
||||
{
|
||||
EXPECT_CALL(*rawBackendPtr, fetchLedgerByHash).WillOnce(testing::Return(ripple::LedgerHeader{}));
|
||||
}
|
||||
else if (req.as_object().contains("ledger_index"))
|
||||
{
|
||||
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).WillOnce(testing::Return(ripple::LedgerHeader{}));
|
||||
}
|
||||
EXPECT_CALL(*rawBackendPtr, fetchAccountTransactions);
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
@@ -660,7 +652,7 @@ TEST_F(RPCAccountTxHandlerTest, BinaryTrue)
|
||||
"144B4E9C06F24296074F7BC48F92A97916C6DC5EA98314D31252CF902EF8DD8451"
|
||||
"243869B38667CBD89DF3");
|
||||
EXPECT_FALSE(output->at("transactions").as_array()[0].as_object().contains("date"));
|
||||
|
||||
EXPECT_FALSE(output->at("transactions").as_array()[0].as_object().contains("inLedger"));
|
||||
EXPECT_FALSE(output->as_object().contains("limit"));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user