clang-format

This commit is contained in:
dangell7
2023-01-23 02:43:52 -05:00
committed by Richard Holland
parent 6569421524
commit 8a344a39e1
5 changed files with 93 additions and 70 deletions

View File

@@ -216,7 +216,8 @@ EscrowCreate::doApply()
std::shared_ptr<SLE> sleLine;
auto const balance = STAmount((*sle)[sfBalance]).xrp();
auto const reserve = ctx_.view().fees().accountReserve((*sle)[sfOwnerCount] + 1);
auto const reserve =
ctx_.view().fees().accountReserve((*sle)[sfOwnerCount] + 1);
bool isIssuer = amount.getIssuer() == account;
if (balance < reserve)
@@ -248,8 +249,7 @@ EscrowCreate::doApply()
ctx_.journal);
JLOG(ctx_.journal.trace())
<< "EscrowCreate::doApply trustTransferAllowed result="
<< result;
<< "EscrowCreate::doApply trustTransferAllowed result=" << result;
// perform the lock as a dry run before
// we modify anything on-ledger
@@ -272,8 +272,8 @@ EscrowCreate::doApply()
{
// perform the lock as a dry run before
// we modify anything on-ledger
sleLine = ctx_.view().peek(
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
sleLine = ctx_.view().peek(keylet::line(
account, amount.getIssuer(), amount.getCurrency()));
{
TER result = trustAdjustLockedBalance(
@@ -362,7 +362,8 @@ EscrowCreate::doApply()
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
JLOG(ctx_.journal.trace())
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) result="
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) "
"result="
<< result;
if (!isTesSuccess(result))
@@ -741,10 +742,13 @@ EscrowCancel::doApply()
// issuer does not need to lock anything
if (!isIssuer)
{
sleLine = ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
sleLine = ctx_.view().peek(keylet::line(
account, amount.getIssuer(), amount.getCurrency()));
// dry run before we make any changes to ledger
if (TER result = trustAdjustLockedBalance(ctx_.view(), sleLine, -amount, -1, ctx_.journal, DryRun); result != tesSUCCESS)
if (TER result = trustAdjustLockedBalance(
ctx_.view(), sleLine, -amount, -1, ctx_.journal, DryRun);
result != tesSUCCESS)
return result;
}
}
@@ -790,7 +794,8 @@ EscrowCancel::doApply()
ctx_.view(), sleLine, -amount, -1, ctx_.journal, WetRun);
JLOG(ctx_.journal.trace())
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) result="
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) "
"result="
<< result;
if (!isTesSuccess(result))

View File

@@ -285,9 +285,13 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
{
if (!isIssuer)
{
auto sleLine = ctx.view.read(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
TER result = trustAdjustLockedBalance(ctx.view, sleLine, amount, 1, ctx.j, DryRun);
JLOG(ctx.j.trace()) << "PayChanCreate::preclaim trustAdjustLockedBalance(dry) result=" << result;
auto sleLine = ctx.view.read(keylet::line(
account, amount.getIssuer(), amount.getCurrency()));
TER result = trustAdjustLockedBalance(
ctx.view, sleLine, amount, 1, ctx.j, DryRun);
JLOG(ctx.j.trace()) << "PayChanCreate::preclaim "
"trustAdjustLockedBalance(dry) result="
<< result;
if (!isTesSuccess(result))
return result;
}
@@ -385,7 +389,8 @@ PayChanCreate::doApply()
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return temDISABLED;
auto sleLine = ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
auto sleLine = ctx_.view().peek(
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
if (!sleLine && !isIssuer)
return tecNO_LINE;
@@ -395,7 +400,8 @@ PayChanCreate::doApply()
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
JLOG(ctx_.journal.trace())
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) result="
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) "
"result="
<< result;
if (!isTesSuccess(result))
@@ -470,7 +476,8 @@ PayChanFund::doApply()
// issuer does not need to lock anything
if (!isIssuer)
{
sleLine = ctx_.view().peek(keylet::line((*slep)[sfAccount], amount.getIssuer(), amount.getCurrency()));
sleLine = ctx_.view().peek(keylet::line(
(*slep)[sfAccount], amount.getIssuer(), amount.getCurrency()));
TER result = trustAdjustLockedBalance(
ctx_.view(), sleLine, amount, 1, ctx_.journal, DryRun);

View File

@@ -1009,8 +1009,7 @@ trustTransferLockedBalance(
return tecPRECISION_LOSS;
finalBalance = isIssuer ? -finalBalance
: dstHigh
? -finalBalance
: dstHigh ? -finalBalance
: finalBalance;
if constexpr (!dryRun)
sleDstLine->setFieldAmount(sfBalance, finalBalance);

View File

@@ -1932,8 +1932,7 @@ struct Escrow_test : public beast::unit_test::suite
env(pay(gw, george, USD(5000)));
env.close();
env(fset(george, asfDisallowXRP));
env(escrow(bob, george, USD(10)),
finish_time(env.now() + 1s));
env(escrow(bob, george, USD(10)), finish_time(env.now() + 1s));
}
{
// Ignore the "asfDisallowXRP" account flag, which we should
@@ -2152,8 +2151,7 @@ struct Escrow_test : public beast::unit_test::suite
// Removed 3 Account Reserve/Increment XRP tests
// See line 602
env(escrow(daniel, bob, USD(10)),
finish_time(env.now() + 1s));
env(escrow(daniel, bob, USD(10)), finish_time(env.now() + 1s));
env.close();
env(escrow(daniel, bob, USD(51)),
finish_time(env.now() + 1s),
@@ -3019,9 +3017,7 @@ struct Escrow_test : public beast::unit_test::suite
// Assemble finish that is missing the Condition or the Fulfillment
// since either both must be present, or neither can:
env(finish(bob, alice, seq), condition(cb3), ter(temMALFORMED));
env(finish(bob, alice, seq),
fulfillment(fb3),
ter(temMALFORMED));
env(finish(bob, alice, seq), fulfillment(fb3), ter(temMALFORMED));
// Now finish it.
env(finish(bob, alice, seq),
@@ -3035,7 +3031,6 @@ struct Escrow_test : public beast::unit_test::suite
env.require(balance(alice, USD(4000)));
env.require(balance(carol, XRP(5000)));
env.require(balance(carol, USD(6000)));
}
{ // Test a condition other than PreimageSha256, which
// would require a separate amendment
@@ -3506,11 +3501,18 @@ struct Escrow_test : public beast::unit_test::suite
env.close();
auto const seq1 = env.seq(gw);
auto const preAlice = env.balance(alice, USD.issue());
env(escrow(gw, alice, USD(1000)), condition(cb1), finish_time(env.now() + 1s), fee(1500));
env(escrow(gw, alice, USD(1000)),
condition(cb1),
finish_time(env.now() + 1s),
fee(1500));
env.close();
env(finish(alice, gw, seq1), condition(cb1), fulfillment(fb1), fee(1500));
env(finish(alice, gw, seq1),
condition(cb1),
fulfillment(fb1),
fee(1500));
env.close();
BEAST_EXPECT(env.balance(alice, USD.issue()) == preAlice + USD(1000));
BEAST_EXPECT(
env.balance(alice, USD.issue()) == preAlice + USD(1000));
}
{
// setup env
@@ -3521,12 +3523,19 @@ struct Escrow_test : public beast::unit_test::suite
// test create escrow from issuer with ic no dest tl
auto const seq1 = env.seq(gw);
auto const preAlice = env.balance(alice, USD.issue());
env(escrow(gw, alice, USD(1000)), condition(cb1), finish_time(env.now() + 1s), fee(1500));
env(escrow(gw, alice, USD(1000)),
condition(cb1),
finish_time(env.now() + 1s),
fee(1500));
env.close();
// test finish from dest account
env(finish(alice, gw, seq1), condition(cb1), fulfillment(fb1), fee(1500));
env(finish(alice, gw, seq1),
condition(cb1),
fulfillment(fb1),
fee(1500));
env.close();
BEAST_EXPECT(env.balance(alice, USD.issue()) == preAlice + USD(1000));
BEAST_EXPECT(
env.balance(alice, USD.issue()) == preAlice + USD(1000));
}
}

View File

@@ -4805,7 +4805,8 @@ struct PayChan_test : public beast::unit_test::suite
// bob can claim, increasing the limit amount
auto const preBobLimit = limitAmount(env, bob, gw, USD);
auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
auto const sig =
signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
env.close();
auto const postBobLimit = limitAmount(env, bob, gw, USD);
@@ -4854,9 +4855,9 @@ struct PayChan_test : public beast::unit_test::suite
env(claim(alice, chan, reqBal, authAmt));
env.close();
// bob can claim
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
// env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
// env.close();
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan,
// authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig),
// alice.pk())); env.close();
}
// test TransferRate
{
@@ -4896,20 +4897,21 @@ struct PayChan_test : public beast::unit_test::suite
// bob can claim, increasing the limit amount
// auto const preBobLimit = limitAmount(env, bob, gw, USD);
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
// env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
// env.close();
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan,
// authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig),
// alice.pk())); env.close();
auto const postLocked = lockedAmount(env, alice, gw, USD);
auto const aliceLimit = limitAmount(env, alice, gw, USD);
auto const bobLimit = limitAmount(env, bob, gw, USD);
// std::cout << "ALICE AMOUNT: " << env.balance(alice, USD.issue()) << "\n";
// std::cout << "BOB AMOUNT: " << env.balance(bob, USD.issue()) << "\n";
// std::cout << "ALICE LIMIT: " << aliceLimit << "\n";
// std::cout << "BOB LIMIT: " << bobLimit << "\n";
// std::cout << "ALICE AMOUNT: " << env.balance(alice, USD.issue())
// << "\n"; std::cout << "BOB AMOUNT: " << env.balance(bob,
// USD.issue()) << "\n"; std::cout << "ALICE LIMIT: " << aliceLimit
// << "\n"; std::cout << "BOB LIMIT: " << bobLimit << "\n";
// std::cout << "POST LOCKED: " << postLocked << "\n";
// std::cout << "CHAN BAL: " << channelBalance(*env.current(), chan) << "\n";
// std::cout << "CHAN AUTH: " << channelAmount(*env.current(), chan) << "\n";
// std::cout << "CHAN BAL: " << channelBalance(*env.current(), chan)
// << "\n"; std::cout << "CHAN AUTH: " <<
// channelAmount(*env.current(), chan) << "\n";
}
// test Global Freeze
{
@@ -4952,7 +4954,8 @@ struct PayChan_test : public beast::unit_test::suite
env(claim(alice, chan, reqBal, authAmt), ter(tecFROZEN));
// bob cannot claim - tl global freeze
auto sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), ter(tecFROZEN));
env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()),
ter(tecFROZEN));
env.close();
env(fclear(gw, asfGlobalFreeze));