Skip to content

Commit

Permalink
respond to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Dec 11, 2024
1 parent ba499a9 commit acaffb1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/test/app/TxQ_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ class TxQPosNegFlows_test : public beast::unit_test::suite

env.app().openLedger().modify(
[&](OpenView& view, beast::Journal j) {
auto result = ripple::apply(
auto const result = ripple::apply(
env.app(), view, *jt.stx, tapNONE, env.journal);
parsed.ter = result.ter;
return result.applied;
Expand Down
3 changes: 2 additions & 1 deletion src/test/consensus/NegativeUNL_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,8 @@ negUnlSizeTest(
bool
applyAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx, bool pass)
{
auto res = apply(env.app(), view, tx, ApplyFlags::tapNONE, env.journal);
auto const res =
apply(env.app(), view, tx, ApplyFlags::tapNONE, env.journal);
if (pass)
return res.ter == tesSUCCESS;
else
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/ledger/detail/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ LedgerMaster::applyHeldTransactions()
ApplyFlags flags = tapNONE;
auto const result =
app_.getTxQ().apply(app_, view, it.second, flags, j);
if (result.applied)
if (any | result.applied)
any = true;
}
return any;
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/ledger/detail/ApplyStateTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ ApplyStateTable::apply(
if (!isDryRun)
{
// add any new modified nodes to the modification set
for (auto& mod : newMod)
for (auto const& mod : newMod)
to.rawReplace(mod.second);
}

Expand Down
1 change: 1 addition & 0 deletions src/xrpld/net/detail/RPCCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ class RPCParser
{
jvRequest[jss::tx_blob] = jvParams[0u].asString();
}

if (jvParams.size() == 2)
{
if (!jvParams[1u].isString() || jvParams[1u].asString() != "binary")
Expand Down
5 changes: 5 additions & 0 deletions src/xrpld/rpc/detail/TransactionSign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,18 +716,22 @@ getBaseFee(Application const& app, Config const& config, Json::Value tx)
{
tx[jss::Fee] = "0";
}

if (!tx.isMember(jss::Sequence))
{
tx[jss::Sequence] = "0";
}

if (!tx.isMember(jss::SigningPubKey))
{
tx[jss::SigningPubKey] = "";
}

if (!tx.isMember(jss::TxnSignature))
{
tx[jss::TxnSignature] = "";
}

if (tx.isMember(jss::Signers))
{
if (!tx[jss::Signers].isArray())
Expand All @@ -745,6 +749,7 @@ getBaseFee(Application const& app, Config const& config, Json::Value tx)
}
}
}

STParsedJSONObject parsed(std::string(jss::tx_json), tx);
if (!parsed.object.has_value())
{
Expand Down
11 changes: 8 additions & 3 deletions src/xrpld/rpc/handlers/Simulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
return feeOrError;

Check warning on line 52 in src/xrpld/rpc/handlers/Simulate.cpp

View check run for this annotation

Codecov / codecov/patch

src/xrpld/rpc/handlers/Simulate.cpp#L52

Added line #L52 was not covered by tests
tx_json[jss::Fee] = feeOrError;
}

if (!tx_json.isMember(sfSigningPubKey.jsonName))
{
// autofill SigningPubKey
tx_json[sfSigningPubKey.jsonName] = "";
}

if (tx_json.isMember(jss::Signers))
{
if (!tx_json[jss::Signers].isArray())
Expand All @@ -81,6 +83,7 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
}
}
}

if (!tx_json.isMember(sfTxnSignature.jsonName))
{
// autofill TxnSignature
Expand All @@ -91,6 +94,7 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
// Transaction must not be signed
return rpcError(rpcTX_SIGNED);
}

if (!tx_json.isMember(jss::Sequence))
{
// autofill Sequence
Expand All @@ -101,13 +105,15 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
// sanity check, should fail earlier
return RPC::invalid_field_error("tx.Account"); // LCOV_EXCL_LINE
}

auto const srcAddressID =
parseBase58<AccountID>(tx_json[jss::Account].asString());
if (!srcAddressID.has_value())
{
return RPC::make_error(
rpcSRC_ACT_MALFORMED, RPC::invalid_field_message("tx.Account"));
}

std::shared_ptr<SLE const> sle =
context.app.openLedger().current()->read(
keylet::account(*srcAddressID));
Expand All @@ -119,6 +125,7 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)

return rpcError(rpcSRC_ACT_NOT_FOUND);
}

tx_json[jss::Sequence] = hasTicketSeq
? 0
: context.app.getTxQ().nextQueuableSeq(sle).value();
Expand All @@ -128,11 +135,9 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
}

// {
// tx_blob: <string>,
// tx_json: <object>,
// tx_blob: <string> XOR tx_json: <object>,
// binary: <bool>
// }
// tx_blob XOR tx_json
Json::Value
doSimulate(RPC::JsonContext& context)
{
Expand Down

0 comments on commit acaffb1

Please sign in to comment.