mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Remove STAmountSO::soTime and soTime2:
STAmount::soTime and soTime2 were time based "amendment like" switches to control small changes in behavior for STAmount. soTime2, which was the most recent, was dated Feb 27, 2016. That's over 3 years ago. The main reason to retain these soTimes would be to replay old transactions. The likelihood of needing to replay a transaction from over three years ago is pretty low. So it makes sense to remove these soTime values. In Flow_test the testZeroOutputStep() test is removed. That test started to fail when the STAmount::soTimes were removed. I checked with the original author of the test. He said that the code being tested by that unit test has been removed, so it makes sense to remove the test. That test is removed.
This commit is contained in:
committed by
Manoj doshi
parent
f7fffee28d
commit
fc0a082700
@@ -492,11 +492,6 @@ struct Flow_test : public beast::unit_test::suite
|
||||
// pass. This test checks that the payment produces 1 EUR, as expected.
|
||||
|
||||
Env env (*this, features);
|
||||
|
||||
auto const closeTime = STAmountSO::soTime2 +
|
||||
100 * env.closed ()->info ().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
|
||||
env.fund (XRP (10000), alice, bob, carol, gw);
|
||||
env.trust (USD (1000), alice, bob, carol);
|
||||
env.trust (EUR (1000), alice, bob, carol);
|
||||
@@ -1249,40 +1244,6 @@ struct Flow_test : public beast::unit_test::suite
|
||||
ter(temBAD_PATH));
|
||||
}
|
||||
|
||||
void
|
||||
testZeroOutputStep()
|
||||
{
|
||||
testcase("Zero Output Step");
|
||||
|
||||
using namespace jtx;
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
auto const carol = Account("carol");
|
||||
auto const gw = Account("gw");
|
||||
auto const USD = gw["USD"];
|
||||
auto const EUR = gw["EUR"];
|
||||
|
||||
auto const features = supported_amendments();
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(10000), alice, bob, carol, gw);
|
||||
env.trust(USD(1000), alice, bob, carol);
|
||||
env.trust(EUR(1000), alice, bob, carol);
|
||||
env(pay(gw, alice, USD(100)));
|
||||
env(pay(gw, bob, USD(100)));
|
||||
env(pay(gw, bob, EUR(100)));
|
||||
env.close();
|
||||
|
||||
env(offer(bob, USD(100), EUR(100)));
|
||||
env(offer(bob, EUR(100), XRP(0.000001)));
|
||||
env.close();
|
||||
|
||||
env(pay(alice, carol, XRP(1)),
|
||||
path(~EUR, ~XRP),
|
||||
sendmax(USD(1)),
|
||||
txflags(tfPartialPayment),
|
||||
ter(tecPATH_DRY));
|
||||
}
|
||||
|
||||
void testWithFeats(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
@@ -1311,7 +1272,6 @@ struct Flow_test : public beast::unit_test::suite
|
||||
void run() override
|
||||
{
|
||||
testLimitQuality();
|
||||
testZeroOutputStep();
|
||||
testRIPD1443(true);
|
||||
testRIPD1443(false);
|
||||
testRIPD1449(true);
|
||||
|
||||
@@ -274,25 +274,7 @@ public:
|
||||
for (int i=0;i<101;++i)
|
||||
env (offer (carol, USD (1), EUR (2)));
|
||||
|
||||
auto hasFeature = [](Env& e, uint256 const& f)
|
||||
{
|
||||
return (e.app().config().features.find(f) !=
|
||||
e.app().config().features.end());
|
||||
};
|
||||
|
||||
for (auto d : {-1, 1})
|
||||
{
|
||||
auto const closeTime = STAmountSO::soTime +
|
||||
d * env.closed()->info().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
*stAmountCalcSwitchover = closeTime > STAmountSO::soTime ||
|
||||
!hasFeature(env, fix1513);
|
||||
// Will fail without the underflow fix
|
||||
TER const expectedResult = *stAmountCalcSwitchover ?
|
||||
TER {tesSUCCESS} : TER {tecPATH_PARTIAL};
|
||||
env (pay (alice, bob, EUR (epsilon)), path (~EUR),
|
||||
sendmax (USD (100)), ter (expectedResult));
|
||||
}
|
||||
env (pay (alice, bob, EUR (epsilon)), path (~EUR), sendmax (USD (100)));
|
||||
}
|
||||
|
||||
void testXRPTinyPayment (FeatureBitset features)
|
||||
@@ -324,74 +306,46 @@ public:
|
||||
auto const gw = Account {"gw"};
|
||||
|
||||
auto const USD = gw["USD"];
|
||||
Env env {*this, features};
|
||||
|
||||
for (auto withFix : {false, true})
|
||||
{
|
||||
if (!withFix)
|
||||
continue;
|
||||
env.fund (XRP (10000), alice, bob, carol, dan, erin, gw);
|
||||
env.trust (USD (1000), alice, bob, carol, dan, erin);
|
||||
env (pay (gw, carol, USD (0.99999)));
|
||||
env (pay (gw, dan, USD (1)));
|
||||
env (pay (gw, erin, USD (1)));
|
||||
|
||||
Env env {*this, features};
|
||||
// Carol doesn't quite have enough funds for this offer
|
||||
// The amount left after this offer is taken will cause
|
||||
// STAmount to incorrectly round to zero when the next offer
|
||||
// (at a good quality) is considered. (when the
|
||||
// stAmountCalcSwitchover2 patch is inactive)
|
||||
env (offer (carol, drops (1), USD (1)));
|
||||
// Offer at a quality poor enough so when the input xrp is
|
||||
// calculated in the reverse pass, the amount is not zero.
|
||||
env (offer (dan, XRP (100), USD (1)));
|
||||
|
||||
auto closeTime = [&]
|
||||
{
|
||||
auto const delta =
|
||||
100 * env.closed ()->info ().closeTimeResolution;
|
||||
if (withFix)
|
||||
return STAmountSO::soTime2 + delta;
|
||||
else
|
||||
return STAmountSO::soTime2 - delta;
|
||||
}();
|
||||
env.close ();
|
||||
// This is the funded offer that will be incorrectly removed.
|
||||
// It is considered after the offer from carol, which leaves a
|
||||
// tiny amount left to pay. When calculating the amount of xrp
|
||||
// needed for this offer, it will incorrectly compute zero in both
|
||||
// the forward and reverse passes (when the stAmountCalcSwitchover2
|
||||
// is inactive.)
|
||||
env (offer (erin, drops (1), USD (1)));
|
||||
|
||||
env.fund (XRP (10000), alice, bob, carol, dan, erin, gw);
|
||||
env.trust (USD (1000), alice, bob, carol, dan, erin);
|
||||
env (pay (gw, carol, USD (0.99999)));
|
||||
env (pay (gw, dan, USD (1)));
|
||||
env (pay (gw, erin, USD (1)));
|
||||
env (pay (alice, bob, USD (1)), path (~USD),
|
||||
sendmax (XRP (102)),
|
||||
txflags (tfNoRippleDirect | tfPartialPayment));
|
||||
|
||||
// Carol doesn't quite have enough funds for this offer
|
||||
// The amount left after this offer is taken will cause
|
||||
// STAmount to incorrectly round to zero when the next offer
|
||||
// (at a good quality) is considered. (when the
|
||||
// stAmountCalcSwitchover2 patch is inactive)
|
||||
env (offer (carol, drops (1), USD (1)));
|
||||
// Offer at a quality poor enough so when the input xrp is
|
||||
// calculated in the reverse pass, the amount is not zero.
|
||||
env (offer (dan, XRP (100), USD (1)));
|
||||
env.require (
|
||||
offers (carol, 0),
|
||||
offers (dan, 1));
|
||||
|
||||
env.close (closeTime);
|
||||
// This is the funded offer that will be incorrectly removed.
|
||||
// It is considered after the offer from carol, which leaves a
|
||||
// tiny amount left to pay. When calculating the amount of xrp
|
||||
// needed for this offer, it will incorrectly compute zero in both
|
||||
// the forward and reverse passes (when the stAmountCalcSwitchover2
|
||||
// is inactive.)
|
||||
env (offer (erin, drops (1), USD (1)));
|
||||
|
||||
{
|
||||
env (pay (alice, bob, USD (1)), path (~USD),
|
||||
sendmax (XRP (102)),
|
||||
txflags (tfNoRippleDirect | tfPartialPayment));
|
||||
|
||||
env.require (
|
||||
offers (carol, 0),
|
||||
offers (dan, 1));
|
||||
if (!withFix)
|
||||
{
|
||||
// funded offer was removed
|
||||
env.require (
|
||||
balance (erin, USD (1)),
|
||||
offers (erin, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
// offer was correctly consumed. There is still some
|
||||
// liquidity left on that offer.
|
||||
env.require (
|
||||
balance (erin, USD (0.99999)),
|
||||
offers (erin, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
// offer was correctly consumed. There is still some
|
||||
// liquidity left on that offer.
|
||||
env.require (
|
||||
balance (erin, USD (0.99999)),
|
||||
offers (erin, 1));
|
||||
}
|
||||
|
||||
void testEnforceNoRipple (FeatureBitset features)
|
||||
|
||||
Reference in New Issue
Block a user