mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-19 18:15:50 +00:00
Compare commits
4 Commits
parasig
...
fix-delive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaaab2309c | ||
|
|
dde03634f8 | ||
|
|
49b766181b | ||
|
|
75ab16e989 |
@@ -60,24 +60,9 @@ getDeliveredAmount(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serializedTx->isFieldPresent(sfAmount))
|
if (serializedTx->isFieldPresent(sfAmount))
|
||||||
{
|
|
||||||
using namespace std::chrono_literals;
|
|
||||||
|
|
||||||
// Ledger 4594095 is the first ledger in which the DeliveredAmount field
|
|
||||||
// was present when a partial payment was made and its absence indicates
|
|
||||||
// that the amount delivered is listed in the Amount field.
|
|
||||||
//
|
|
||||||
// If the ledger closed long after the DeliveredAmount code was deployed
|
|
||||||
// then its absence indicates that the amount delivered is listed in the
|
|
||||||
// Amount field. DeliveredAmount went live January 24, 2014.
|
|
||||||
// 446000000 is in Feb 2014, well after DeliveredAmount went live
|
|
||||||
if (getLedgerIndex() >= 4594095 ||
|
|
||||||
getCloseTime() > NetClock::time_point{446000000s} ||
|
|
||||||
(serializedTx && serializedTx->isFieldPresent(sfNetworkID)))
|
|
||||||
{
|
{
|
||||||
return serializedTx->getFieldAmount(sfAmount);
|
return serializedTx->getFieldAmount(sfAmount);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5466,6 +5466,7 @@ private:
|
|||||||
params[jss::transaction] = txIds[i];
|
params[jss::transaction] = txIds[i];
|
||||||
auto const jrr = env.rpc("json", "tx", to_string(params));
|
auto const jrr = env.rpc("json", "tx", to_string(params));
|
||||||
auto const meta = jrr[jss::result][jss::meta];
|
auto const meta = jrr[jss::result][jss::meta];
|
||||||
|
BEAST_EXPECT(meta[jss::delivered_amount] == "1000000");
|
||||||
for (auto const& node : meta[sfAffectedNodes.jsonName])
|
for (auto const& node : meta[sfAffectedNodes.jsonName])
|
||||||
{
|
{
|
||||||
auto const nodeType = node[sfLedgerEntryType.jsonName];
|
auto const nodeType = node[sfLedgerEntryType.jsonName];
|
||||||
|
|||||||
@@ -191,17 +191,12 @@ class DeliveredAmount_test : public beast::unit_test::suite
|
|||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
|
|
||||||
for (bool const afterSwitchTime : {true, false})
|
|
||||||
{
|
|
||||||
Env env{*this, features};
|
Env env{*this, features};
|
||||||
env.fund(XRP(10000), alice, bob, carol, gw);
|
env.fund(XRP(10000), alice, bob, carol, gw);
|
||||||
env.trust(USD(1000), alice, bob, carol);
|
env.trust(USD(1000), alice, bob, carol);
|
||||||
if (afterSwitchTime)
|
|
||||||
env.close(NetClock::time_point{446000000s});
|
|
||||||
else
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
CheckDeliveredAmount checkDeliveredAmount{afterSwitchTime};
|
CheckDeliveredAmount checkDeliveredAmount{true};
|
||||||
{
|
{
|
||||||
// add payments, but do no close until subscribed
|
// add payments, but do no close until subscribed
|
||||||
|
|
||||||
@@ -239,8 +234,7 @@ class DeliveredAmount_test : public beast::unit_test::suite
|
|||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
|
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
|
||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
jv.isMember(jss::ripplerpc) &&
|
jv.isMember(jss::ripplerpc) && jv[jss::ripplerpc] == "2.0");
|
||||||
jv[jss::ripplerpc] == "2.0");
|
|
||||||
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
|
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 3);
|
BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 3);
|
||||||
@@ -265,7 +259,6 @@ class DeliveredAmount_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
|
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void
|
void
|
||||||
testTxDeliveredAmountRPC(FeatureBitset features)
|
testTxDeliveredAmountRPC(FeatureBitset features)
|
||||||
{
|
{
|
||||||
@@ -280,17 +273,12 @@ class DeliveredAmount_test : public beast::unit_test::suite
|
|||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
|
|
||||||
for (bool const afterSwitchTime : {true, false})
|
|
||||||
{
|
|
||||||
Env env{*this, features};
|
Env env{*this, features};
|
||||||
env.fund(XRP(10000), alice, bob, carol, gw);
|
env.fund(XRP(10000), alice, bob, carol, gw);
|
||||||
env.trust(USD(1000), alice, bob, carol);
|
env.trust(USD(1000), alice, bob, carol);
|
||||||
if (afterSwitchTime)
|
|
||||||
env.close(NetClock::time_point{446000000s});
|
|
||||||
else
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
CheckDeliveredAmount checkDeliveredAmount{afterSwitchTime};
|
CheckDeliveredAmount checkDeliveredAmount{true};
|
||||||
// normal payments
|
// normal payments
|
||||||
env(pay(gw, alice, USD(50)));
|
env(pay(gw, alice, USD(50)));
|
||||||
checkDeliveredAmount.adjCountersSuccess();
|
checkDeliveredAmount.adjCountersSuccess();
|
||||||
@@ -316,14 +304,11 @@ class DeliveredAmount_test : public beast::unit_test::suite
|
|||||||
auto const jtxn = env.rpc(
|
auto const jtxn = env.rpc(
|
||||||
"json",
|
"json",
|
||||||
"ledger",
|
"ledger",
|
||||||
to_string(
|
to_string(jvParams))[jss::result][jss::ledger][jss::transactions];
|
||||||
jvParams))[jss::result][jss::ledger][jss::transactions];
|
|
||||||
for (auto const& t : jtxn)
|
for (auto const& t : jtxn)
|
||||||
BEAST_EXPECT(
|
BEAST_EXPECT(checkDeliveredAmount.checkTxn(t, t[jss::metaData]));
|
||||||
checkDeliveredAmount.checkTxn(t, t[jss::metaData]));
|
|
||||||
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
|
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public:
|
|||||||
{
|
{
|
||||||
Env env(*this);
|
Env env(*this);
|
||||||
auto const result = env.rpc("server_definitions");
|
auto const result = env.rpc("server_definitions");
|
||||||
std::cout << "RESULT: " << result << "\n";
|
|
||||||
BEAST_EXPECT(!result[jss::result].isMember(jss::error));
|
BEAST_EXPECT(!result[jss::result].isMember(jss::error));
|
||||||
BEAST_EXPECT(result[jss::result].isMember(jss::FIELDS));
|
BEAST_EXPECT(result[jss::result].isMember(jss::FIELDS));
|
||||||
BEAST_EXPECT(result[jss::result].isMember(jss::LEDGER_ENTRY_TYPES));
|
BEAST_EXPECT(result[jss::result].isMember(jss::LEDGER_ENTRY_TYPES));
|
||||||
|
|||||||
Reference in New Issue
Block a user