mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix tx re-ordering bug in test:
`env.fund` requires two transactions: `pay` and `set account`. If there is a `trust` transaction in the same set of txs, the txs may be reordered so `pay` -> `trust` -> `set account` so the wrong `no ripple` flag would be used on the trust line. Adding a `close` between `env.fund` and `env.trust` resolves this problem.
This commit is contained in:
@@ -31,6 +31,20 @@
|
|||||||
namespace ripple {
|
namespace ripple {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
bool getNoRippleFlag (jtx::Env const& env,
|
||||||
|
jtx::Account const& src,
|
||||||
|
jtx::Account const& dst,
|
||||||
|
Currency const& cur)
|
||||||
|
{
|
||||||
|
if (auto sle = env.le (keylet::line (src, dst, cur)))
|
||||||
|
{
|
||||||
|
auto const flag = (src.id() > dst.id()) ? lsfHighNoRipple : lsfLowNoRipple;
|
||||||
|
return sle->isFlag (flag);
|
||||||
|
}
|
||||||
|
Throw<std::runtime_error> ("No line in getTrustFlag");
|
||||||
|
return false; // silence warning
|
||||||
|
}
|
||||||
|
|
||||||
jtx::PrettyAmount
|
jtx::PrettyAmount
|
||||||
xrpMinusFee (jtx::Env const& env, std::int64_t xrpAmount)
|
xrpMinusFee (jtx::Env const& env, std::int64_t xrpAmount)
|
||||||
{
|
{
|
||||||
@@ -1046,9 +1060,16 @@ struct Flow_test : public beast::unit_test::suite
|
|||||||
auto const bob = Account("bob");
|
auto const bob = Account("bob");
|
||||||
auto const gw = Account("gw");
|
auto const gw = Account("gw");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
|
auto const usdC = USD.currency;
|
||||||
|
|
||||||
env.fund(XRP(10000), alice, bob, gw);
|
env.fund(XRP(10000), alice, bob, gw);
|
||||||
|
// Need to be past this time to see the bug
|
||||||
|
env.close(amendmentRIPD1274SoTime() +
|
||||||
|
100 * env.closed()->info().closeTimeResolution);
|
||||||
env(trust(alice, USD(100)));
|
env(trust(alice, USD(100)));
|
||||||
|
env.close();
|
||||||
|
|
||||||
|
BEAST_EXPECT(!getNoRippleFlag(env, gw, alice, usdC));
|
||||||
|
|
||||||
env(pay(
|
env(pay(
|
||||||
gw, alice,
|
gw, alice,
|
||||||
@@ -1079,10 +1100,6 @@ struct Flow_test : public beast::unit_test::suite
|
|||||||
USD.issue(), std::uint64_t(1700000000000000ull), -14, false},
|
USD.issue(), std::uint64_t(1700000000000000ull), -14, false},
|
||||||
XRP(.001)));
|
XRP(.001)));
|
||||||
|
|
||||||
// Need to be past this time to see the bug
|
|
||||||
env.close(amendmentRIPD1274SoTime() +
|
|
||||||
100 * env.closed()->info().closeTimeResolution);
|
|
||||||
|
|
||||||
env(pay(alice, bob, XRP(10000)), path(~XRP), sendmax(USD(100)),
|
env(pay(alice, bob, XRP(10000)), path(~XRP), sendmax(USD(100)),
|
||||||
txflags(tfPartialPayment | tfNoRippleDirect));
|
txflags(tfPartialPayment | tfNoRippleDirect));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,11 @@ struct XRPEndpointStepInfo
|
|||||||
AccountID acc;
|
AccountID acc;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TrustFlag { freeze, auth };
|
enum class TrustFlag {freeze, auth, noripple};
|
||||||
|
|
||||||
std::uint32_t
|
/*constexpr*/ std::uint32_t trustFlag (TrustFlag f, bool useHigh)
|
||||||
trustFlag(TrustFlag f, bool useHigh)
|
|
||||||
{
|
{
|
||||||
switch (f)
|
switch(f)
|
||||||
{
|
{
|
||||||
case TrustFlag::freeze:
|
case TrustFlag::freeze:
|
||||||
if (useHigh)
|
if (useHigh)
|
||||||
@@ -59,8 +58,12 @@ trustFlag(TrustFlag f, bool useHigh)
|
|||||||
if (useHigh)
|
if (useHigh)
|
||||||
return lsfHighAuth;
|
return lsfHighAuth;
|
||||||
return lsfLowAuth;
|
return lsfLowAuth;
|
||||||
|
case TrustFlag::noripple:
|
||||||
|
if (useHigh)
|
||||||
|
return lsfHighNoRipple;
|
||||||
|
return lsfLowNoRipple;
|
||||||
}
|
}
|
||||||
return 0; // Silence warning about end of non-void function
|
return 0; // Silence warning about end of non-void function
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user