mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-19 10:05:48 +00:00
clang-format
This commit is contained in:
committed by
Richard Holland
parent
6569421524
commit
8a344a39e1
@@ -216,7 +216,8 @@ EscrowCreate::doApply()
|
|||||||
std::shared_ptr<SLE> sleLine;
|
std::shared_ptr<SLE> sleLine;
|
||||||
|
|
||||||
auto const balance = STAmount((*sle)[sfBalance]).xrp();
|
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;
|
bool isIssuer = amount.getIssuer() == account;
|
||||||
|
|
||||||
if (balance < reserve)
|
if (balance < reserve)
|
||||||
@@ -248,8 +249,7 @@ EscrowCreate::doApply()
|
|||||||
ctx_.journal);
|
ctx_.journal);
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustTransferAllowed result="
|
<< "EscrowCreate::doApply trustTransferAllowed result=" << result;
|
||||||
<< result;
|
|
||||||
|
|
||||||
// perform the lock as a dry run before
|
// perform the lock as a dry run before
|
||||||
// we modify anything on-ledger
|
// we modify anything on-ledger
|
||||||
@@ -272,8 +272,8 @@ EscrowCreate::doApply()
|
|||||||
{
|
{
|
||||||
// perform the lock as a dry run before
|
// perform the lock as a dry run before
|
||||||
// we modify anything on-ledger
|
// we modify anything on-ledger
|
||||||
sleLine = ctx_.view().peek(
|
sleLine = ctx_.view().peek(keylet::line(
|
||||||
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
account, amount.getIssuer(), amount.getCurrency()));
|
||||||
|
|
||||||
{
|
{
|
||||||
TER result = trustAdjustLockedBalance(
|
TER result = trustAdjustLockedBalance(
|
||||||
@@ -281,7 +281,7 @@ EscrowCreate::doApply()
|
|||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustAdjustLockedBalance (dry) "
|
<< "EscrowCreate::doApply trustAdjustLockedBalance (dry) "
|
||||||
"result="
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
@@ -362,7 +362,8 @@ EscrowCreate::doApply()
|
|||||||
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) result="
|
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) "
|
||||||
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
@@ -741,10 +742,13 @@ EscrowCancel::doApply()
|
|||||||
// issuer does not need to lock anything
|
// issuer does not need to lock anything
|
||||||
if (!isIssuer)
|
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
|
// 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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -790,7 +794,8 @@ EscrowCancel::doApply()
|
|||||||
ctx_.view(), sleLine, -amount, -1, ctx_.journal, WetRun);
|
ctx_.view(), sleLine, -amount, -1, ctx_.journal, WetRun);
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) result="
|
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) "
|
||||||
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
|
|||||||
@@ -285,9 +285,13 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
|||||||
{
|
{
|
||||||
if (!isIssuer)
|
if (!isIssuer)
|
||||||
{
|
{
|
||||||
auto sleLine = ctx.view.read(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
auto sleLine = ctx.view.read(keylet::line(
|
||||||
TER result = trustAdjustLockedBalance(ctx.view, sleLine, amount, 1, ctx.j, DryRun);
|
account, amount.getIssuer(), amount.getCurrency()));
|
||||||
JLOG(ctx.j.trace()) << "PayChanCreate::preclaim trustAdjustLockedBalance(dry) result=" << result;
|
TER result = trustAdjustLockedBalance(
|
||||||
|
ctx.view, sleLine, amount, 1, ctx.j, DryRun);
|
||||||
|
JLOG(ctx.j.trace()) << "PayChanCreate::preclaim "
|
||||||
|
"trustAdjustLockedBalance(dry) result="
|
||||||
|
<< result;
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -385,17 +389,19 @@ PayChanCreate::doApply()
|
|||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
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)
|
if (!sleLine && !isIssuer)
|
||||||
return tecNO_LINE;
|
return tecNO_LINE;
|
||||||
|
|
||||||
if (!isIssuer)
|
if (!isIssuer)
|
||||||
{
|
{
|
||||||
TER result = trustAdjustLockedBalance(
|
TER result = trustAdjustLockedBalance(
|
||||||
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) result="
|
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) "
|
||||||
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
@@ -470,7 +476,8 @@ PayChanFund::doApply()
|
|||||||
// issuer does not need to lock anything
|
// issuer does not need to lock anything
|
||||||
if (!isIssuer)
|
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(
|
TER result = trustAdjustLockedBalance(
|
||||||
ctx_.view(), sleLine, amount, 1, ctx_.journal, DryRun);
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, DryRun);
|
||||||
@@ -547,7 +554,7 @@ PayChanFund::doApply()
|
|||||||
if (!isIssuer)
|
if (!isIssuer)
|
||||||
{
|
{
|
||||||
TER result = trustAdjustLockedBalance(
|
TER result = trustAdjustLockedBalance(
|
||||||
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanFund::doApply trustAdjustLockedBalance(wet) result="
|
<< "PayChanFund::doApply trustAdjustLockedBalance(wet) result="
|
||||||
|
|||||||
@@ -1009,8 +1009,7 @@ trustTransferLockedBalance(
|
|||||||
return tecPRECISION_LOSS;
|
return tecPRECISION_LOSS;
|
||||||
|
|
||||||
finalBalance = isIssuer ? -finalBalance
|
finalBalance = isIssuer ? -finalBalance
|
||||||
: dstHigh
|
: dstHigh ? -finalBalance
|
||||||
? -finalBalance
|
|
||||||
: finalBalance;
|
: finalBalance;
|
||||||
if constexpr (!dryRun)
|
if constexpr (!dryRun)
|
||||||
sleDstLine->setFieldAmount(sfBalance, finalBalance);
|
sleDstLine->setFieldAmount(sfBalance, finalBalance);
|
||||||
|
|||||||
@@ -1932,8 +1932,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, george, USD(5000)));
|
env(pay(gw, george, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
env(fset(george, asfDisallowXRP));
|
env(fset(george, asfDisallowXRP));
|
||||||
env(escrow(bob, george, USD(10)),
|
env(escrow(bob, george, USD(10)), finish_time(env.now() + 1s));
|
||||||
finish_time(env.now() + 1s));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Ignore the "asfDisallowXRP" account flag, which we should
|
// 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
|
// Removed 3 Account Reserve/Increment XRP tests
|
||||||
// See line 602
|
// See line 602
|
||||||
|
|
||||||
env(escrow(daniel, bob, USD(10)),
|
env(escrow(daniel, bob, USD(10)), finish_time(env.now() + 1s));
|
||||||
finish_time(env.now() + 1s));
|
|
||||||
env.close();
|
env.close();
|
||||||
env(escrow(daniel, bob, USD(51)),
|
env(escrow(daniel, bob, USD(51)),
|
||||||
finish_time(env.now() + 1s),
|
finish_time(env.now() + 1s),
|
||||||
@@ -2224,7 +2222,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, alice, USD(1000)), finish_time(env.now() + 5s));
|
env(escrow(alice, alice, USD(1000)), finish_time(env.now() + 5s));
|
||||||
|
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
env.require(balance(alice, USD(5000)));
|
env.require(balance(alice, USD(5000)));
|
||||||
@@ -2264,7 +2262,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, bob, USD(1000)), finish_time(env.now() + 5s));
|
env(escrow(alice, bob, USD(1000)), finish_time(env.now() + 5s));
|
||||||
|
|
||||||
// Verify amounts
|
// Verify amounts
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
@@ -2313,7 +2311,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, bob, USD(1000)), finish_time(env.now() + 5s));
|
env(escrow(alice, bob, USD(1000)), finish_time(env.now() + 5s));
|
||||||
|
|
||||||
// Verify amounts
|
// Verify amounts
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
@@ -2414,7 +2412,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, alice, USD(5000)));
|
env(pay(gw, alice, USD(5000)));
|
||||||
env(pay(gw, bob, USD(5000)));
|
env(pay(gw, bob, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, alice, USD(1000)),
|
env(escrow(alice, alice, USD(1000)),
|
||||||
condition(cb2),
|
condition(cb2),
|
||||||
@@ -2470,17 +2468,17 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, alice, USD(5000)));
|
env(pay(gw, alice, USD(5000)));
|
||||||
env(pay(gw, bob, USD(5000)));
|
env(pay(gw, bob, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, alice, USD(1000)),
|
env(escrow(alice, alice, USD(1000)),
|
||||||
condition(cb3),
|
condition(cb3),
|
||||||
finish_time(env.now() + 5s));
|
finish_time(env.now() + 5s));
|
||||||
|
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
BEAST_EXPECT(preLocked == USD(1000));
|
BEAST_EXPECT(preLocked == USD(1000));
|
||||||
env.require(balance(alice, USD(5000)));
|
env.require(balance(alice, USD(5000)));
|
||||||
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// Finish is now possible but requires the cryptocondition.
|
// Finish is now possible but requires the cryptocondition.
|
||||||
@@ -2523,17 +2521,17 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, bob, USD(5000)));
|
env(pay(gw, bob, USD(5000)));
|
||||||
env(pay(gw, carol, USD(5000)));
|
env(pay(gw, carol, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
env(escrow(alice, alice, USD(1000)),
|
env(escrow(alice, alice, USD(1000)),
|
||||||
condition(cb3),
|
condition(cb3),
|
||||||
finish_time(env.now() + 5s));
|
finish_time(env.now() + 5s));
|
||||||
|
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
BEAST_EXPECT(preLocked == USD(1000));
|
BEAST_EXPECT(preLocked == USD(1000));
|
||||||
env.require(balance(alice, USD(5000)));
|
env.require(balance(alice, USD(5000)));
|
||||||
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// Alice preauthorizes Zelda for deposit, even though Alice has
|
// Alice preauthorizes Zelda for deposit, even though Alice has
|
||||||
@@ -2592,13 +2590,13 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, bob, USD(5000)));
|
env(pay(gw, bob, USD(5000)));
|
||||||
env(pay(gw, carol, USD(5000)));
|
env(pay(gw, carol, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 1);
|
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 1);
|
||||||
env(escrow(alice, carol, USD(1000)),
|
env(escrow(alice, carol, USD(1000)),
|
||||||
condition(cb1),
|
condition(cb1),
|
||||||
cancel_time(env.now() + 1s));
|
cancel_time(env.now() + 1s));
|
||||||
|
|
||||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 2);
|
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 2);
|
||||||
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
auto const preLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
@@ -2682,7 +2680,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, bob, USD(5000)));
|
env(pay(gw, bob, USD(5000)));
|
||||||
env(pay(gw, carol, USD(5000)));
|
env(pay(gw, carol, USD(5000)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const seq = env.seq(alice);
|
auto const seq = env.seq(alice);
|
||||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 1);
|
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 1);
|
||||||
env(escrow(alice, carol, USD(1000)),
|
env(escrow(alice, carol, USD(1000)),
|
||||||
@@ -2695,7 +2693,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env.require(balance(alice, USD(5000)));
|
env.require(balance(alice, USD(5000)));
|
||||||
// balance restored on cancel
|
// balance restored on cancel
|
||||||
env(cancel(bob, alice, seq));
|
env(cancel(bob, alice, seq));
|
||||||
|
|
||||||
auto const postLocked = lockedAmount(env, alice, gw, USD);
|
auto const postLocked = lockedAmount(env, alice, gw, USD);
|
||||||
env.require(balance(alice, XRP(5000) - drops(10)));
|
env.require(balance(alice, XRP(5000) - drops(10)));
|
||||||
BEAST_EXPECT(postLocked == USD(0));
|
BEAST_EXPECT(postLocked == USD(0));
|
||||||
@@ -3019,9 +3017,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
// Assemble finish that is missing the Condition or the Fulfillment
|
// Assemble finish that is missing the Condition or the Fulfillment
|
||||||
// since either both must be present, or neither can:
|
// since either both must be present, or neither can:
|
||||||
env(finish(bob, alice, seq), condition(cb3), ter(temMALFORMED));
|
env(finish(bob, alice, seq), condition(cb3), ter(temMALFORMED));
|
||||||
env(finish(bob, alice, seq),
|
env(finish(bob, alice, seq), fulfillment(fb3), ter(temMALFORMED));
|
||||||
fulfillment(fb3),
|
|
||||||
ter(temMALFORMED));
|
|
||||||
|
|
||||||
// Now finish it.
|
// Now finish it.
|
||||||
env(finish(bob, alice, seq),
|
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(alice, USD(4000)));
|
||||||
env.require(balance(carol, XRP(5000)));
|
env.require(balance(carol, XRP(5000)));
|
||||||
env.require(balance(carol, USD(6000)));
|
env.require(balance(carol, USD(6000)));
|
||||||
|
|
||||||
}
|
}
|
||||||
{ // Test a condition other than PreimageSha256, which
|
{ // Test a condition other than PreimageSha256, which
|
||||||
// would require a separate amendment
|
// would require a separate amendment
|
||||||
@@ -3506,11 +3501,18 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
env.close();
|
env.close();
|
||||||
auto const seq1 = env.seq(gw);
|
auto const seq1 = env.seq(gw);
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
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.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();
|
env.close();
|
||||||
BEAST_EXPECT(env.balance(alice, USD.issue()) == preAlice + USD(1000));
|
BEAST_EXPECT(
|
||||||
|
env.balance(alice, USD.issue()) == preAlice + USD(1000));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// setup env
|
// setup env
|
||||||
@@ -3521,12 +3523,19 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
// test create escrow from issuer with ic no dest tl
|
// test create escrow from issuer with ic no dest tl
|
||||||
auto const seq1 = env.seq(gw);
|
auto const seq1 = env.seq(gw);
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
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.close();
|
||||||
// test finish from dest account
|
// 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();
|
env.close();
|
||||||
BEAST_EXPECT(env.balance(alice, USD.issue()) == preAlice + USD(1000));
|
BEAST_EXPECT(
|
||||||
|
env.balance(alice, USD.issue()) == preAlice + USD(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3561,7 +3570,7 @@ struct Escrow_test : public beast::unit_test::suite
|
|||||||
public:
|
public:
|
||||||
void
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
using namespace test::jtx;
|
using namespace test::jtx;
|
||||||
FeatureBitset const all{supported_amendments()};
|
FeatureBitset const all{supported_amendments()};
|
||||||
testWithFeats(all);
|
testWithFeats(all);
|
||||||
|
|||||||
@@ -3604,7 +3604,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
.asString();
|
.asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to authorize without specifying a key type, expect an
|
// Try to authorize without specifying a key type, expect an
|
||||||
// error:
|
// error:
|
||||||
auto const rs = env.rpc(
|
auto const rs = env.rpc(
|
||||||
"channel_authorize",
|
"channel_authorize",
|
||||||
@@ -4655,7 +4655,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
auto const chan = channel(gw, alice, env.seq(gw));
|
auto const chan = channel(gw, alice, env.seq(gw));
|
||||||
env(create(gw, alice, USD(1000), settleDelay, pk));
|
env(create(gw, alice, USD(1000), settleDelay, pk));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// gw can not claim
|
// gw can not claim
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
auto const preAlice = env.balance(alice, USD.issue());
|
||||||
auto chanBal = channelBalance(*env.current(), chan);
|
auto chanBal = channelBalance(*env.current(), chan);
|
||||||
@@ -4677,7 +4677,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
auto const chan = channel(gw, alice, env.seq(gw));
|
auto const chan = channel(gw, alice, env.seq(gw));
|
||||||
env(create(gw, alice, USD(1000), settleDelay, pk));
|
env(create(gw, alice, USD(1000), settleDelay, pk));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// alice can claim
|
// alice can claim
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
auto const preAlice = env.balance(alice, USD.issue());
|
||||||
auto chanBal = channelBalance(*env.current(), chan);
|
auto chanBal = channelBalance(*env.current(), chan);
|
||||||
@@ -4707,7 +4707,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
auto const chan = channel(gw, alice, env.seq(gw));
|
auto const chan = channel(gw, alice, env.seq(gw));
|
||||||
env(create(gw, alice, USD(1000), settleDelay, pk));
|
env(create(gw, alice, USD(1000), settleDelay, pk));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// gw can claim
|
// gw can claim
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
auto const preAlice = env.balance(alice, USD.issue());
|
||||||
auto chanBal = channelBalance(*env.current(), chan);
|
auto chanBal = channelBalance(*env.current(), chan);
|
||||||
@@ -4739,7 +4739,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
env(fund(gw, chan, USD(1000)));
|
env(fund(gw, chan, USD(1000)));
|
||||||
|
|
||||||
// gw can claim
|
// gw can claim
|
||||||
auto const preAlice = env.balance(alice, USD.issue());
|
auto const preAlice = env.balance(alice, USD.issue());
|
||||||
auto chanBal = channelBalance(*env.current(), chan);
|
auto chanBal = channelBalance(*env.current(), chan);
|
||||||
@@ -4765,7 +4765,7 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
auto const bob = Account("bob");
|
auto const bob = Account("bob");
|
||||||
auto const carol = Account("carol");
|
auto const carol = Account("carol");
|
||||||
auto const gw = Account{"gateway"};
|
auto const gw = Account{"gateway"};
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
|
|
||||||
auto const aliceUSD = alice["USD"];
|
auto const aliceUSD = alice["USD"];
|
||||||
auto const bobUSD = bob["USD"];
|
auto const bobUSD = bob["USD"];
|
||||||
@@ -4805,7 +4805,8 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
// bob can claim, increasing the limit amount
|
// bob can claim, increasing the limit amount
|
||||||
auto const preBobLimit = limitAmount(env, bob, gw, USD);
|
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(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
|
||||||
env.close();
|
env.close();
|
||||||
auto const postBobLimit = limitAmount(env, bob, gw, USD);
|
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(claim(alice, chan, reqBal, authAmt));
|
||||||
env.close();
|
env.close();
|
||||||
// bob can claim
|
// bob can claim
|
||||||
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
|
// auto const sig = signClaimICAuth(alice.pk(), alice.sk(), chan,
|
||||||
// env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
|
// authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig),
|
||||||
// env.close();
|
// alice.pk())); env.close();
|
||||||
}
|
}
|
||||||
// test TransferRate
|
// test TransferRate
|
||||||
{
|
{
|
||||||
@@ -4896,20 +4897,21 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
// bob can claim, increasing the limit amount
|
// bob can claim, increasing the limit amount
|
||||||
// auto const preBobLimit = limitAmount(env, bob, gw, USD);
|
// 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,
|
||||||
// env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
|
// authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig),
|
||||||
// env.close();
|
// alice.pk())); env.close();
|
||||||
|
|
||||||
auto const postLocked = lockedAmount(env, alice, gw, USD);
|
auto const postLocked = lockedAmount(env, alice, gw, USD);
|
||||||
auto const aliceLimit = limitAmount(env, alice, gw, USD);
|
auto const aliceLimit = limitAmount(env, alice, gw, USD);
|
||||||
auto const bobLimit = limitAmount(env, bob, gw, USD);
|
auto const bobLimit = limitAmount(env, bob, gw, USD);
|
||||||
// std::cout << "ALICE AMOUNT: " << env.balance(alice, USD.issue()) << "\n";
|
// std::cout << "ALICE AMOUNT: " << env.balance(alice, USD.issue())
|
||||||
// std::cout << "BOB AMOUNT: " << env.balance(bob, USD.issue()) << "\n";
|
// << "\n"; std::cout << "BOB AMOUNT: " << env.balance(bob,
|
||||||
// std::cout << "ALICE LIMIT: " << aliceLimit << "\n";
|
// USD.issue()) << "\n"; std::cout << "ALICE LIMIT: " << aliceLimit
|
||||||
// std::cout << "BOB LIMIT: " << bobLimit << "\n";
|
// << "\n"; std::cout << "BOB LIMIT: " << bobLimit << "\n";
|
||||||
// std::cout << "POST LOCKED: " << postLocked << "\n";
|
// std::cout << "POST LOCKED: " << postLocked << "\n";
|
||||||
// std::cout << "CHAN BAL: " << channelBalance(*env.current(), chan) << "\n";
|
// std::cout << "CHAN BAL: " << channelBalance(*env.current(), chan)
|
||||||
// std::cout << "CHAN AUTH: " << channelAmount(*env.current(), chan) << "\n";
|
// << "\n"; std::cout << "CHAN AUTH: " <<
|
||||||
|
// channelAmount(*env.current(), chan) << "\n";
|
||||||
}
|
}
|
||||||
// test Global Freeze
|
// test Global Freeze
|
||||||
{
|
{
|
||||||
@@ -4952,7 +4954,8 @@ struct PayChan_test : public beast::unit_test::suite
|
|||||||
env(claim(alice, chan, reqBal, authAmt), ter(tecFROZEN));
|
env(claim(alice, chan, reqBal, authAmt), ter(tecFROZEN));
|
||||||
// bob cannot claim - tl global freeze
|
// bob cannot claim - tl global freeze
|
||||||
auto sig = signClaimICAuth(alice.pk(), alice.sk(), chan, authAmt);
|
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.close();
|
||||||
|
|
||||||
env(fclear(gw, asfGlobalFreeze));
|
env(fclear(gw, asfGlobalFreeze));
|
||||||
|
|||||||
Reference in New Issue
Block a user