Skip to content

Commit 3ee78cd

Browse files
committed
address comments
1 parent fb8c04b commit 3ee78cd

File tree

9 files changed

+27
-24
lines changed

9 files changed

+27
-24
lines changed

src/test/jtx/domain.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
*/
1818
//==============================================================================
1919

20-
#ifndef RIPPLE_TEST_JTX_DOMAIN_H_INCLUDED
21-
#define RIPPLE_TEST_JTX_DOMAIN_H_INCLUDED
20+
#pragma once
2221

2322
#include <test/jtx/Env.h>
2423

@@ -44,5 +43,3 @@ class domain
4443
} // namespace jtx
4544
} // namespace test
4645
} // namespace ripple
47-
48-
#endif

src/test/jtx/impl/paths.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ paths::operator()(Env& env, JTx& jt) const
4040
std::optional<uint256> domain;
4141
if (jv.isMember(sfDomainID.jsonName))
4242
{
43+
if (!jv[sfDomainID.jsonName].isString())
44+
return;
4345
uint256 num;
4446
auto const s = jv[sfDomainID.jsonName].asString();
4547
if (num.parseHex(s))

src/test/ledger/Invariants_test.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ class Invariants_test : public beast::unit_test::suite
977977
}
978978

979979
void
980-
createPD(
980+
createPermissionedDomain(
981981
ApplyContext& ac,
982982
std::shared_ptr<SLE>& sle,
983983
test::jtx::Account const& A1,
@@ -1115,7 +1115,7 @@ class Invariants_test : public beast::unit_test::suite
11151115
auto slePd = std::make_shared<SLE>(pdKeylet);
11161116

11171117
// create PD
1118-
createPD(ac, slePd, A1, A2);
1118+
createPermissionedDomain(ac, slePd, A1, A2);
11191119

11201120
// update PD with empty rules
11211121
{
@@ -1139,7 +1139,7 @@ class Invariants_test : public beast::unit_test::suite
11391139
auto slePd = std::make_shared<SLE>(pdKeylet);
11401140

11411141
// create PD
1142-
createPD(ac, slePd, A1, A2);
1142+
createPermissionedDomain(ac, slePd, A1, A2);
11431143

11441144
// update PD
11451145
{
@@ -1174,7 +1174,7 @@ class Invariants_test : public beast::unit_test::suite
11741174
auto slePd = std::make_shared<SLE>(pdKeylet);
11751175

11761176
// create PD
1177-
createPD(ac, slePd, A1, A2);
1177+
createPermissionedDomain(ac, slePd, A1, A2);
11781178

11791179
// update PD
11801180
{
@@ -1209,7 +1209,7 @@ class Invariants_test : public beast::unit_test::suite
12091209
auto slePd = std::make_shared<SLE>(pdKeylet);
12101210

12111211
// create PD
1212-
createPD(ac, slePd, A1, A2);
1212+
createPermissionedDomain(ac, slePd, A1, A2);
12131213

12141214
// update PD
12151215
{
@@ -1271,7 +1271,7 @@ class Invariants_test : public beast::unit_test::suite
12711271
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
12721272
Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10);
12731273
auto slePd = std::make_shared<SLE>(pdKeylet);
1274-
createPD(ac, slePd, A1, A2);
1274+
createPermissionedDomain(ac, slePd, A1, A2);
12751275

12761276
Keylet const offerKey = keylet::offer(A2.id(), 10);
12771277
auto sleOffer = std::make_shared<SLE>(offerKey);
@@ -1296,7 +1296,7 @@ class Invariants_test : public beast::unit_test::suite
12961296
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
12971297
Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10);
12981298
auto slePd = std::make_shared<SLE>(pdKeylet);
1299-
createPD(ac, slePd, A1, A2);
1299+
createPermissionedDomain(ac, slePd, A1, A2);
13001300

13011301
Keylet const offerKey = keylet::offer(A2.id(), 10);
13021302
auto sleOffer = std::make_shared<SLE>(offerKey);
@@ -1323,7 +1323,7 @@ class Invariants_test : public beast::unit_test::suite
13231323
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
13241324
Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10);
13251325
auto slePd = std::make_shared<SLE>(pdKeylet);
1326-
createPD(ac, slePd, A1, A2);
1326+
createPermissionedDomain(ac, slePd, A1, A2);
13271327

13281328
Keylet const offerKey = keylet::offer(A2.id(), 10);
13291329
auto sleOffer = std::make_shared<SLE>(offerKey);
@@ -1344,12 +1344,12 @@ class Invariants_test : public beast::unit_test::suite
13441344
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
13451345
Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10);
13461346
auto slePd = std::make_shared<SLE>(pdKeylet);
1347-
createPD(ac, slePd, A1, A2);
1347+
createPermissionedDomain(ac, slePd, A1, A2);
13481348

13491349
Keylet const badDomainKeylet =
13501350
keylet::permissionedDomain(A1.id(), 20);
13511351
auto sleBadPd = std::make_shared<SLE>(badDomainKeylet);
1352-
createPD(ac, sleBadPd, A1, A2);
1352+
createPermissionedDomain(ac, sleBadPd, A1, A2);
13531353

13541354
Keylet const offerKey = keylet::offer(A2.id(), 10);
13551355
auto sleOffer = std::make_shared<SLE>(offerKey);
@@ -1378,7 +1378,7 @@ class Invariants_test : public beast::unit_test::suite
13781378
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
13791379
Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10);
13801380
auto slePd = std::make_shared<SLE>(pdKeylet);
1381-
createPD(ac, slePd, A1, A2);
1381+
createPermissionedDomain(ac, slePd, A1, A2);
13821382

13831383
Keylet const offerKey = keylet::offer(A2.id(), 10);
13841384
auto sleOffer = std::make_shared<SLE>(offerKey);

src/xrpld/app/ledger/OrderBookDB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ OrderBookDB::getBooksByTakerPays(
213213
ret.reserve(it->second.size());
214214

215215
for (auto const& gets : it->second)
216-
ret.emplace_back(Book(issue, gets));
216+
ret.emplace_back(issue, gets);
217217
}
218218
}
219219
else
@@ -224,7 +224,7 @@ OrderBookDB::getBooksByTakerPays(
224224
ret.reserve(it->second.size());
225225

226226
for (auto const& gets : it->second)
227-
ret.emplace_back(Book(issue, gets, domain));
227+
ret.emplace_back(issue, gets, domain);
228228
}
229229
}
230230
}

src/xrpld/app/misc/PermissionedDEXHelpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ offerInDomain(
7979
!sleOffer->isFieldPresent(sfAdditionalBooks))
8080
{
8181
JLOG(j.error()) << "Hybrid offer " << offerID
82-
<< " missing AdditionalBooks field"; // LCOV_EXCL_LINE
82+
<< " missing AdditionalBooks field";
83+
return false; // LCOV_EXCL_LINE
8384
}
8485

8586
return accountInDomain(view, sleOffer->getAccountID(sfAccount), domainID);

src/xrpld/app/paths/PathRequest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ PathRequest::parseJson(Json::Value const& jvParams)
441441
if (jvParams.isMember(jss::domain))
442442
{
443443
uint256 num;
444-
if (auto const s = jvParams[jss::domain].asString(); !num.parseHex(s))
444+
if (!jvParams[jss::domain].isString() ||
445+
!num.parseHex(jvParams[jss::domain].asString()))
445446
{
446447
jvStatus = rpcError(rpcDOMAIN_MALFORMED);
447448
return PFR_PJ_INVALID;

src/xrpld/app/tx/detail/CreateOffer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ CreateOffer::applyHybrid(
10131013

10141014
auto dir =
10151015
keylet::quality(keylet::book(book), getRate(saTakerGets, saTakerPays));
1016-
bool const bookExists = static_cast<bool>(sb.peek(dir));
1016+
bool const bookExists = static_cast<bool>(sb.exists(dir));
10171017

10181018
auto const bookNode = sb.dirAppend(dir, offerKey, [&](SLE::ref sle) {
10191019
// don't set domainID on the directory object since this directory is
@@ -1335,7 +1335,8 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
13351335
auto dir = keylet::quality(keylet::book(book), uRate);
13361336
bool const bookExisted = static_cast<bool>(sb.peek(dir));
13371337

1338-
auto setBookDir = [&](SLE::ref sle, std::optional<uint256> maybeDomain) {
1338+
auto setBookDir = [&](SLE::ref sle,
1339+
std::optional<uint256> const& maybeDomain) {
13391340
sle->setFieldH160(sfTakerPaysCurrency, saTakerPays.issue().currency);
13401341
sle->setFieldH160(sfTakerPaysIssuer, saTakerPays.issue().account);
13411342
sle->setFieldH160(sfTakerGetsCurrency, saTakerGets.issue().currency);

src/xrpld/rpc/detail/TransactionSign.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ checkPayment(
227227
if (tx_json.isMember(jss::domain))
228228
{
229229
uint256 num;
230-
if (auto const s = tx_json[jss::domain].asString(); !num.parseHex(s))
230+
if (!tx_json[jss::domain].isString() ||
231+
!num.parseHex(tx_json[jss::domain].asString()))
231232
{
232233
return RPC::make_error(
233234
rpcDOMAIN_MALFORMED, "Unable to parse 'domain'.");

src/xrpld/rpc/handlers/BookOffers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ doBookOffers(RPC::JsonContext& context)
176176
if (context.params.isMember(jss::domain))
177177
{
178178
uint256 num;
179-
if (auto const s = context.params[jss::domain].asString();
180-
!num.parseHex(s))
179+
if (!context.params[jss::domain].isString() ||
180+
!num.parseHex(context.params[jss::domain].asString()))
181181
{
182182
return RPC::make_error(
183183
rpcDOMAIN_MALFORMED, "Unable to parse domain.");

0 commit comments

Comments
 (0)