mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Enable rm funded offer fix after a switch over date
This commit is contained in:
@@ -24,6 +24,15 @@
|
|||||||
namespace ripple {
|
namespace ripple {
|
||||||
namespace path {
|
namespace path {
|
||||||
|
|
||||||
|
static
|
||||||
|
bool enableDirRestartFix (
|
||||||
|
std::uint32_t parentCloseTime)
|
||||||
|
{
|
||||||
|
// Mon Aug 3 11:00:00am PDT
|
||||||
|
static std::uint32_t const enableAfter = 491940000;
|
||||||
|
return parentCloseTime > enableAfter;
|
||||||
|
}
|
||||||
|
|
||||||
// At the right most node of a list of consecutive offer nodes, given the amount
|
// At the right most node of a list of consecutive offer nodes, given the amount
|
||||||
// requested to be delivered, push towards the left nodes the amount requested
|
// requested to be delivered, push towards the left nodes the amount requested
|
||||||
// for the right nodes so we can compute how much to deliver from the source.
|
// for the right nodes so we can compute how much to deliver from the source.
|
||||||
@@ -44,6 +53,12 @@ TER PathCursor::deliverNodeReverseImpl (
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
TER resultCode = tesSUCCESS;
|
TER resultCode = tesSUCCESS;
|
||||||
|
|
||||||
|
if (!enableDirRestartFix (rippleCalc_.view.info ().parentCloseTime))
|
||||||
|
{
|
||||||
|
node().directory.restart(multiQuality_);
|
||||||
|
}
|
||||||
|
|
||||||
// Accumulation of what the previous node must deliver.
|
// Accumulation of what the previous node must deliver.
|
||||||
// Possible optimization: Note this gets zeroed on each increment, ideally
|
// Possible optimization: Note this gets zeroed on each increment, ideally
|
||||||
// only on first increment, then it could be a limit on the forward pass.
|
// only on first increment, then it could be a limit on the forward pass.
|
||||||
@@ -351,8 +366,11 @@ TER PathCursor::deliverNodeReverse (
|
|||||||
// increment
|
// increment
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
for (int i = nodeIndex_; i >= 0 && !node (i).isAccount(); --i)
|
if (enableDirRestartFix (rippleCalc_.view.info ().parentCloseTime))
|
||||||
node (i).directory.restart (multiQuality_);
|
{
|
||||||
|
for (int i = nodeIndex_; i >= 0 && !node (i).isAccount(); --i)
|
||||||
|
node (i).directory.restart (multiQuality_);
|
||||||
|
}
|
||||||
|
|
||||||
return deliverNodeReverseImpl(uOutAccountID, saOutReq, saOutAct);
|
return deliverNodeReverseImpl(uOutAccountID, saOutReq, saOutAct);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,50 +41,73 @@ public:
|
|||||||
// would remove the first "taker gets" xrp offer, even though the offer is
|
// would remove the first "taker gets" xrp offer, even though the offer is
|
||||||
// still funded and not used for the payment.
|
// still funded and not used for the payment.
|
||||||
|
|
||||||
using namespace jtx;
|
// Mon Aug 3 11:00:00am PDT
|
||||||
Env env (*this);
|
static NetClock::time_point const switchoverTime (
|
||||||
auto const gw = Account ("gateway");
|
std::chrono::seconds (491940000));
|
||||||
auto const USD = gw["USD"];
|
|
||||||
auto const BTC = gw["BTC"];
|
|
||||||
Account const alice ("alice");
|
|
||||||
Account const bob ("bob");
|
|
||||||
Account const carol ("carol");
|
|
||||||
|
|
||||||
env.fund (XRP (10000), alice, bob, carol, gw);
|
for(int i=0; i<2; ++i)
|
||||||
env.trust (USD (1000), alice, bob, carol);
|
{
|
||||||
env.trust (BTC (1000), alice, bob, carol);
|
using namespace jtx;
|
||||||
|
Env env (*this);
|
||||||
|
|
||||||
env (pay (gw, alice, BTC (1000)));
|
auto const tp = switchoverTime + std::chrono::seconds (i);
|
||||||
|
bool const enableFix = tp > switchoverTime;
|
||||||
|
expect (enableFix == bool(i));
|
||||||
|
|
||||||
env (pay (gw, carol, USD (1000)));
|
// ledger close times have a dynamic resolution depending on network
|
||||||
env (pay (gw, carol, BTC (1000)));
|
// conditions it appears the resolution in test is 10 seconds
|
||||||
|
env.close (tp);
|
||||||
|
|
||||||
// Must be two offers at the same quality
|
NetClock::time_point const pct (
|
||||||
// "taker gets" must be XRP
|
std::chrono::seconds (env.open ()->info ().parentCloseTime));
|
||||||
// (Different amounts so I can distinguish the offers)
|
if (enableFix)
|
||||||
env (offer (carol, BTC (49), XRP (49)));
|
expect (pct > switchoverTime);
|
||||||
env (offer (carol, BTC (51), XRP (51)));
|
else
|
||||||
|
expect (pct <= switchoverTime);
|
||||||
|
|
||||||
// Offers for the poor quality path
|
auto const gw = Account ("gateway");
|
||||||
// Must be two offers at the same quality
|
auto const USD = gw["USD"];
|
||||||
env (offer (carol, XRP (50), USD (50)));
|
auto const BTC = gw["BTC"];
|
||||||
env (offer (carol, XRP (50), USD (50)));
|
Account const alice ("alice");
|
||||||
|
Account const bob ("bob");
|
||||||
|
Account const carol ("carol");
|
||||||
|
|
||||||
// Offers for the good quality path
|
env.fund (XRP (10000), alice, bob, carol, gw);
|
||||||
env (offer (carol, BTC (1), USD (100)));
|
env.trust (USD (1000), alice, bob, carol);
|
||||||
|
env.trust (BTC (1000), alice, bob, carol);
|
||||||
|
|
||||||
PathSet paths (
|
env (pay (gw, alice, BTC (1000)));
|
||||||
Path (XRP, USD),
|
|
||||||
Path (USD));
|
|
||||||
|
|
||||||
env (pay ("alice", "bob", USD (100)),
|
env (pay (gw, carol, USD (1000)));
|
||||||
json (paths.json ()),
|
env (pay (gw, carol, BTC (1000)));
|
||||||
sendmax (BTC (1000)),
|
|
||||||
txflags (tfPartialPayment));
|
|
||||||
|
|
||||||
require (balance ("bob", USD (100)));
|
// Must be two offers at the same quality
|
||||||
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
|
// "taker gets" must be XRP
|
||||||
isOffer (env, "carol", BTC (49), XRP (49)));
|
// (Different amounts so I can distinguish the offers)
|
||||||
|
env (offer (carol, BTC (49), XRP (49)));
|
||||||
|
env (offer (carol, BTC (51), XRP (51)));
|
||||||
|
|
||||||
|
// Offers for the poor quality path
|
||||||
|
// Must be two offers at the same quality
|
||||||
|
env (offer (carol, XRP (50), USD (50)));
|
||||||
|
env (offer (carol, XRP (50), USD (50)));
|
||||||
|
|
||||||
|
// Offers for the good quality path
|
||||||
|
env (offer (carol, BTC (1), USD (100)));
|
||||||
|
|
||||||
|
PathSet paths (Path (XRP, USD), Path (USD));
|
||||||
|
|
||||||
|
env (pay ("alice", "bob", USD (100)), json (paths.json ()),
|
||||||
|
sendmax (BTC (1000)), txflags (tfPartialPayment));
|
||||||
|
|
||||||
|
require (balance ("bob", USD (100)));
|
||||||
|
if (enableFix)
|
||||||
|
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
|
||||||
|
isOffer (env, "carol", BTC (49), XRP (49)));
|
||||||
|
else
|
||||||
|
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
|
||||||
|
!isOffer (env, "carol", BTC (49), XRP (49)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void testCanceledOffer ()
|
void testCanceledOffer ()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user