mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Add delivered amount to GetAccountTransactionHistory responses
This commit is contained in:
@@ -373,19 +373,21 @@ populateProtoResponse(
|
|||||||
closeTime->time_since_epoch().count());
|
closeTime->time_since_epoch().count());
|
||||||
if (txnMeta)
|
if (txnMeta)
|
||||||
{
|
{
|
||||||
if (!txnMeta->hasDeliveredAmount())
|
RPC::convert(*txnProto->mutable_meta(), txnMeta);
|
||||||
|
if (!txnProto->meta().has_delivered_amount())
|
||||||
{
|
{
|
||||||
std::optional<STAmount> amount = getDeliveredAmount(
|
if (auto amt = getDeliveredAmount(
|
||||||
context,
|
context,
|
||||||
txn->getSTransaction(),
|
txn->getSTransaction(),
|
||||||
*txnMeta,
|
*txnMeta,
|
||||||
txn->getLedger());
|
txn->getLedger()))
|
||||||
if (amount)
|
|
||||||
{
|
{
|
||||||
txnMeta->setDeliveredAmount(*amount);
|
RPC::convert(
|
||||||
|
*txnProto->mutable_meta()
|
||||||
|
->mutable_delivered_amount(),
|
||||||
|
*amt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RPC::convert(*txnProto->mutable_meta(), txnMeta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1567,6 +1567,9 @@ convert(org::xrpl::rpc::v1::Meta& to, std::shared_ptr<TxMeta> const& from)
|
|||||||
to.mutable_transaction_result()->set_result(
|
to.mutable_transaction_result()->set_result(
|
||||||
transToken(from->getResultTER()));
|
transToken(from->getResultTER()));
|
||||||
|
|
||||||
|
if (from->hasDeliveredAmount())
|
||||||
|
convert(*to.mutable_delivered_amount(), from->getDeliveredAmount());
|
||||||
|
|
||||||
STArray& nodes = from->getNodes();
|
STArray& nodes = from->getNodes();
|
||||||
for (auto it = nodes.begin(); it != nodes.end(); ++it)
|
for (auto it = nodes.begin(); it != nodes.end(); ++it)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -505,6 +505,25 @@ class Tx_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GrpcAccountTxClient : public GRPCTestClientBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
org::xrpl::rpc::v1::GetAccountTransactionHistoryRequest request;
|
||||||
|
org::xrpl::rpc::v1::GetAccountTransactionHistoryResponse reply;
|
||||||
|
|
||||||
|
explicit GrpcAccountTxClient(std::string const& port)
|
||||||
|
: GRPCTestClientBase(port)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountTx()
|
||||||
|
{
|
||||||
|
status =
|
||||||
|
stub_->GetAccountTransactionHistory(&context, request, &reply);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
testTxGrpc()
|
testTxGrpc()
|
||||||
{
|
{
|
||||||
@@ -674,22 +693,65 @@ class Tx_test : public beast::unit_test::suite
|
|||||||
cmpPaymentTx(result.second.transaction(), tx);
|
cmpPaymentTx(result.second.transaction(), tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ledger && !b)
|
if (!ledger || b)
|
||||||
{
|
continue;
|
||||||
auto rawMeta = ledger->txRead(id).second;
|
|
||||||
if (rawMeta)
|
|
||||||
{
|
|
||||||
auto txMeta = std::make_shared<TxMeta>(
|
|
||||||
id, ledger->seq(), *rawMeta);
|
|
||||||
|
|
||||||
cmpMeta(result.second.meta(), txMeta);
|
auto rawMeta = ledger->txRead(id).second;
|
||||||
cmpDeliveredAmount(
|
if (!rawMeta)
|
||||||
result.second.meta(),
|
continue;
|
||||||
result.second.transaction(),
|
|
||||||
txMeta,
|
auto txMeta =
|
||||||
tx);
|
std::make_shared<TxMeta>(id, ledger->seq(), *rawMeta);
|
||||||
}
|
|
||||||
}
|
cmpMeta(result.second.meta(), txMeta);
|
||||||
|
cmpDeliveredAmount(
|
||||||
|
result.second.meta(),
|
||||||
|
result.second.transaction(),
|
||||||
|
txMeta,
|
||||||
|
tx);
|
||||||
|
|
||||||
|
auto grpcAccountTx = [&grpcPort](
|
||||||
|
uint256 const& id,
|
||||||
|
bool binary,
|
||||||
|
AccountID const& account)
|
||||||
|
-> std::
|
||||||
|
pair<bool, org::xrpl::rpc::v1::GetTransactionResponse> {
|
||||||
|
GrpcAccountTxClient client(grpcPort);
|
||||||
|
client.request.set_binary(binary);
|
||||||
|
client.request.mutable_account()->set_address(
|
||||||
|
toBase58(account));
|
||||||
|
client.AccountTx();
|
||||||
|
org::xrpl::rpc::v1::GetTransactionResponse res;
|
||||||
|
|
||||||
|
for (auto const& tx : client.reply.transactions())
|
||||||
|
{
|
||||||
|
if (uint256::fromVoid(tx.hash().data()) == id)
|
||||||
|
{
|
||||||
|
return {client.status.ok(), tx};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {false, res};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Compare result to result from account_tx
|
||||||
|
auto mentioned = tx->getMentionedAccounts();
|
||||||
|
|
||||||
|
if (!BEAST_EXPECT(mentioned.size()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto account = *mentioned.begin();
|
||||||
|
auto const accountTxResult = grpcAccountTx(id, b, account);
|
||||||
|
|
||||||
|
if (!BEAST_EXPECT(accountTxResult.first))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cmpPaymentTx(accountTxResult.second.transaction(), tx);
|
||||||
|
cmpMeta(accountTxResult.second.meta(), txMeta);
|
||||||
|
cmpDeliveredAmount(
|
||||||
|
accountTxResult.second.meta(),
|
||||||
|
accountTxResult.second.transaction(),
|
||||||
|
txMeta,
|
||||||
|
tx);
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user