mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +00:00
Compare commits
2 Commits
a1q123456/
...
vvysokikh1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f85c09e5ff | ||
|
|
b4a45f1f0f |
@@ -32,6 +32,7 @@
|
||||
// If you add an amendment here, then do not forget to increment `numFeatures`
|
||||
// in include/xrpl/protocol/Feature.h.
|
||||
|
||||
XRPL_FIX (TrustLineOwnerCount, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (IncludeKeyletFields, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicMPT, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (TokenEscrowV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
|
||||
@@ -1790,6 +1790,26 @@ rippleCreditIOU(
|
||||
// Receiver reserve is clear.
|
||||
}
|
||||
|
||||
// Check if receiver's balance went from zero/negative to positive
|
||||
// In this case, the receiver should now be charged for the trust line
|
||||
// Note: balance is in sender's terms, so receiver going from 0 to
|
||||
// positive means sender going from 0 to negative
|
||||
if (view.rules().enabled(fixTrustLineOwnerCount) &&
|
||||
saBefore >= beast::zero
|
||||
// Sender balance was non-negative (receiver was non-positive).
|
||||
&& saBalance < beast::zero
|
||||
// Sender is now negative (receiver is now positive).
|
||||
&& !(uFlags & (bSenderHigh ? lsfLowReserve : lsfHighReserve)))
|
||||
// Receiver reserve is not set.
|
||||
{
|
||||
adjustOwnerCount(
|
||||
view, view.peek(keylet::account(uReceiverID)), 1, j);
|
||||
|
||||
sleRippleState->setFieldU32(
|
||||
sfFlags,
|
||||
uFlags | (bSenderHigh ? lsfLowReserve : lsfHighReserve));
|
||||
}
|
||||
|
||||
if (bSenderHigh)
|
||||
saBalance.negate();
|
||||
|
||||
|
||||
@@ -2409,11 +2409,11 @@ public:
|
||||
{"abe", reserve(env, 0) + 0 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0},
|
||||
{"bud", reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0},
|
||||
{"che", reserve(env, 0) + 2 * f, 0, gwPreTrust, 1000, tecINSUF_RESERVE_OFFER, f, USD( 0), 0, 0},
|
||||
{"dan", drops(10) + reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, drops(10) + f, USD(0.00001), 0, 0},
|
||||
{"eli", XRP( 20) + reserve(env, 0) + 1 * f, 1000, gwPreTrust, 1000, tesSUCCESS, XRP(20) + 1 * f, USD( 20), 0, 0},
|
||||
{"dan", drops(10) + reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, drops(10) + f, USD(0.00001), 0, features[fixTrustLineOwnerCount] ? 1 : 0},
|
||||
{"eli", XRP( 20) + reserve(env, features[fixTrustLineOwnerCount] ? 1 : 0) + 1 * f, 1000, gwPreTrust, 1000, tesSUCCESS, XRP(20) + f, USD( 20), 0, features[fixTrustLineOwnerCount] ? 1 : 0},
|
||||
{"fyn", reserve(env, 1) + 0 * f, 0, gwPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1},
|
||||
{"gar", reserve(env, 1) + 0 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 1},
|
||||
{"hal", reserve(env, 1) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 1},
|
||||
{"gar", reserve(env, features[fixTrustLineOwnerCount] ? 2 : 1) + 0 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, features[fixTrustLineOwnerCount] ? 2 : 1},
|
||||
{"hal", reserve(env, features[fixTrustLineOwnerCount] ? 2 : 1) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, features[fixTrustLineOwnerCount] ? 2 : 1},
|
||||
|
||||
{"ned", reserve(env, 1) + 0 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"ole", reserve(env, 1) + 1 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
@@ -2468,6 +2468,7 @@ public:
|
||||
BEAST_EXPECT(env.balance(acct, USD.issue()) == t.balanceUsd);
|
||||
BEAST_EXPECT(
|
||||
env.balance(acct, xrpIssue()) == t.fundXrp - t.spentXrp);
|
||||
|
||||
env.require(offers(acct, t.offers));
|
||||
env.require(owners(acct, t.owners));
|
||||
|
||||
@@ -5463,6 +5464,7 @@ class Offer_manual_test : public OfferBaseUtil_test
|
||||
testAll(all);
|
||||
|
||||
testAll(all - takerDryOffer - permDEX);
|
||||
testAll(all - fixTrustLineOwnerCount);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -458,6 +458,79 @@ class TrustAndBalance_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(wsc->invoke("unsubscribe", jv)[jss::status] == "success");
|
||||
}
|
||||
|
||||
void
|
||||
testOwnerCountOnBalanceChange(FeatureBitset features)
|
||||
{
|
||||
testcase("Owner Count on Balance Change");
|
||||
using namespace test::jtx;
|
||||
|
||||
Env env{*this, features};
|
||||
Account gw{"gateway"};
|
||||
Account alice{"alice"};
|
||||
Account market{"market"};
|
||||
bool const aliceHigh = alice.id() > gw.id();
|
||||
|
||||
auto const USD = gw["USD"];
|
||||
|
||||
// Helper lambda to check alice's owner count and reserve flag
|
||||
auto checkAlice = [&](std::uint32_t expectedOwnerCount,
|
||||
bool expectedReserveSet) {
|
||||
BEAST_EXPECT(
|
||||
env.le(alice)->getFieldU32(sfOwnerCount) == expectedOwnerCount);
|
||||
auto const line =
|
||||
env.le(keylet::line(alice, gw, to_currency("USD")));
|
||||
BEAST_EXPECT(
|
||||
line->isFlag(aliceHigh ? lsfHighReserve : lsfLowReserve) ==
|
||||
expectedReserveSet);
|
||||
};
|
||||
|
||||
env.fund(XRP(10000), gw, alice, market);
|
||||
env.close();
|
||||
|
||||
// create trust lines
|
||||
env(trust(alice, USD(1000)));
|
||||
env(trust(market, USD(1000)));
|
||||
env.close();
|
||||
checkAlice(1, true);
|
||||
|
||||
// gw issues USD to alice and market
|
||||
env(pay(gw, alice, USD(100)));
|
||||
env(pay(gw, market, USD(1000)));
|
||||
env.close();
|
||||
checkAlice(1, true);
|
||||
|
||||
// gw clears asfDefaultRipple
|
||||
env(fclear(gw, asfDefaultRipple));
|
||||
env.close();
|
||||
|
||||
// alice clears trustline limit. This should trigger the check for
|
||||
// default ripple state and charge gw for non-default state
|
||||
env(trust(alice, USD(0)));
|
||||
env.close();
|
||||
checkAlice(1, true);
|
||||
|
||||
// alice clears the balance causing decrement in owners count
|
||||
env(pay(alice, gw, USD(100)));
|
||||
env.close();
|
||||
checkAlice(0, false);
|
||||
|
||||
// market offers USD for XRP
|
||||
env(offer(market, XRP(100), USD(100)));
|
||||
env.close();
|
||||
// Now alice acquires balance again by placing an offer (direct payment
|
||||
// would fail because alice set limit to 0). This offer will cross
|
||||
// market's. Balance goes from 0 to positive - this triggers the new
|
||||
// increment logic
|
||||
env(offer(alice, USD(50), XRP(50)));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(env.balance(alice, USD) == USD(50));
|
||||
if (features[fixTrustLineOwnerCount])
|
||||
checkAlice(1, true);
|
||||
else
|
||||
checkAlice(0, false);
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
run() override
|
||||
@@ -477,11 +550,13 @@ public:
|
||||
testIndirectMultiPath(true, features);
|
||||
testIndirectMultiPath(false, features);
|
||||
testInvoiceID(features);
|
||||
testOwnerCountOnBalanceChange(features);
|
||||
};
|
||||
|
||||
using namespace test::jtx;
|
||||
auto const sa = testable_amendments();
|
||||
testWithFeatures(sa - featurePermissionedDEX);
|
||||
testWithFeatures(sa - fixTrustLineOwnerCount);
|
||||
testWithFeatures(sa);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user