Review feedback from @dangell7

- Cleaned up some of the `LEDGER_ENTRY` macros by eliding unnecessary
  parameters.
- Define the transaction privileges in one place (InvariantCheck.cpp).
- Give `EscrowFinish` the `mayAuthorizeMPT` privilege.
- Rename the test helper `expectLine` to `expectHolding` since
  it handles both trust lines and MPTs.
- Restructure the ""pseudo-account has 2 pseudo-account fields set"
  invariant test to loop over all defined pseudo-account fields.
- Fix `operator<<` for `PrettyAmount` to handle `MPTIssue`s.
- Add enforcement of the `AccountRootsDeletedClean` invariant if SAV is
  enabled, and clarify the comment for the pseudo-account field check.
- Delete the 100% redundant `ttMPTOKEN_ISSUANCE_SET` check in
  `ValidMPTIssuance`.
This commit is contained in:
Ed Hennis
2025-08-19 19:52:30 -04:00
parent a648249b90
commit 9920037d13
12 changed files with 262 additions and 288 deletions

View File

@@ -56,7 +56,7 @@ enum LedgerEntryType : std::uint16_t
#pragma push_macro("LEDGER_ENTRY")
#undef LEDGER_ENTRY
#define LEDGER_ENTRY(tag, value, name, rpcName, fields) tag = value,
#define LEDGER_ENTRY(tag, value, ...) tag = value,
#include <xrpl/protocol/detail/ledger_entries.macro>

View File

@@ -36,24 +36,7 @@
*
* The `privileges` parameter of the TRANSACTION macro is a bitfield
* defining which operations the transaction can perform.
*
* The values are only used in InvariantCheck.cpp
* Valid values are
noPriv - The transaction can not do any of the enumerated operations
createAcct - The transaction can create a new ACCOUNT_ROOT object.
createPseudoAcct - The transaction can create a pseudo account,
which implies createAcct
mustDeleteAcct - The transaction must delete an ACCOUNT_ROOT object
mayDeleteAcct - The transaction may delete an ACCOUNT_ROOT object,
but does not have to
overrideFreeze - The transaction can override some freeze rules
changeNFTCounts - The transaction can mint or burn an NFT
createMPTIssuance - The transaction can create a new MPT issuance
destroyMPTIssuance - The transaction can destroy an MPT issuance
mustAuthorizeMPT - The transaction MUST create or delete an MPT
object (except by issuer)
mayAuthorizeMPT - The transaction MAY create or delete an MPT
object (except by issuer)
* The values are defined and used in InvariantCheck.cpp
*/
/** This transaction type executes a payment. */
@@ -92,7 +75,7 @@ TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate,
/** This transaction type completes an existing escrow. */
TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish,
Delegation::delegatable,
noPriv, ({
mayAuthorizeMPT, ({
{sfOwner, soeREQUIRED},
{sfOfferSequence, soeREQUIRED},
{sfFulfillment, soeOPTIONAL},

View File

@@ -718,11 +718,11 @@ JSS(write_load); // out: GetCounts
#pragma push_macro("LEDGER_ENTRY_DUPLICATE")
#undef LEDGER_ENTRY_DUPLICATE
#define LEDGER_ENTRY(tag, value, name, rpcName, fields) \
JSS(name); \
#define LEDGER_ENTRY(tag, value, name, rpcName, ...) \
JSS(name); \
JSS(rpcName);
#define LEDGER_ENTRY_DUPLICATE(tag, value, name, rpcName, fields) JSS(rpcName);
#define LEDGER_ENTRY_DUPLICATE(tag, value, name, rpcName, ...) JSS(rpcName);
#include <xrpl/protocol/detail/ledger_entries.macro>

View File

@@ -181,9 +181,9 @@ private:
BEAST_EXPECT(expectLedgerEntryRoot(
env, alice, XRP(20'000) - XRP(50) - txfee(env, 1)));
BEAST_EXPECT(expectLine(env, bob, USD1(100)));
BEAST_EXPECT(expectLine(env, bob, USD2(0)));
BEAST_EXPECT(expectLine(env, carol, USD2(50)));
BEAST_EXPECT(expectHolding(env, bob, USD1(100)));
BEAST_EXPECT(expectHolding(env, bob, USD2(0)));
BEAST_EXPECT(expectHolding(env, carol, USD2(50)));
}
}
@@ -220,7 +220,7 @@ private:
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRP(30'000) - (txfee(env, 1))));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
// Order that can be filled
env(offer(carol, XRP(100), USD(100)),
@@ -230,7 +230,7 @@ private:
XRP(10'000), USD(10'100), ammAlice.tokens()));
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRP(30'000) + XRP(100) - txfee(env, 2)));
BEAST_EXPECT(expectLine(env, carol, USD(29'900)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'900)));
BEAST_EXPECT(expectOffers(env, carol, 0));
},
{{XRP(10'100), USD(10'000)}},
@@ -254,7 +254,7 @@ private:
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRP(30'000) + XRP(100) - txfee(env, 1)));
// AMM
BEAST_EXPECT(expectLine(env, carol, USD(29'900)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'900)));
BEAST_EXPECT(expectOffers(env, carol, 0));
},
{{XRP(10'100), USD(10'000)}},
@@ -327,7 +327,7 @@ private:
USD(49),
IOUAmount{273'861'278752583, -8}));
BEAST_EXPECT(expectLine(env, bob, STAmount{USD, 101}));
BEAST_EXPECT(expectHolding(env, bob, STAmount{USD, 101}));
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(300'000) - xrpTransferred - txfee(env, 1)));
BEAST_EXPECT(expectOffers(env, bob, 0));
@@ -390,7 +390,7 @@ private:
BEAST_EXPECT(
ammBob.expectBalances(USD(300), XRP(1'000), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, alice, USD(0)));
BEAST_EXPECT(expectHolding(env, alice, USD(0)));
auto jrr = ledgerEntryRoot(env, alice);
BEAST_EXPECT(
@@ -423,7 +423,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRPAmount{9'900'990'100}, USD(10'100), ammAlice.tokens()));
// initial 30,000 - 10,000AMM - 100pay
BEAST_EXPECT(expectLine(env, alice, USD(19'900)));
BEAST_EXPECT(expectHolding(env, alice, USD(19'900)));
// initial 30,000 - 10,0000AMM + 99.009900pay - fee*3
BEAST_EXPECT(expectLedgerEntryRoot(
env,
@@ -453,7 +453,7 @@ private:
env(pay(alice, bob, USD(100)), sendmax(XRP(100)));
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, bob, USD(100)));
BEAST_EXPECT(expectHolding(env, bob, USD(100)));
},
{{XRP(10'000), USD(10'100)}},
0,
@@ -533,7 +533,7 @@ private:
STAmount{USD1, UINT64_C(5'030'181086519115), -12},
ammCarol.tokens()));
BEAST_EXPECT(expectOffers(env, dan, 1, {{Amounts{XRP(200), EUR(20)}}}));
BEAST_EXPECT(expectLine(env, bob, STAmount{EUR1, 30}));
BEAST_EXPECT(expectHolding(env, bob, STAmount{EUR1, 30}));
}
void
@@ -642,7 +642,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'000), USD(9'999), ammAlice.tokens()));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectLine(env, carol, USD(30'101)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'101)));
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRP(30'000) - XRP(100) - txfee(env, 1)));
},
@@ -682,7 +682,7 @@ private:
env(offer(alice, USD(100), XRP(200)), json(jss::Flags, tfSell));
BEAST_EXPECT(
ammBob.expectBalances(XRP(1'100), USD(2'000), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, alice, USD(200)));
BEAST_EXPECT(expectHolding(env, alice, USD(200)));
BEAST_EXPECT(expectLedgerEntryRoot(env, alice, XRP(250)));
BEAST_EXPECT(expectOffers(env, alice, 0));
}
@@ -733,7 +733,7 @@ private:
STAmount(XTS, UINT64_C(101'010101010101), -12),
XXX(99),
ammAlice.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, bob, STAmount{XTS, UINT64_C(98'989898989899), -12}));
}
else
@@ -742,10 +742,10 @@ private:
STAmount(XTS, UINT64_C(101'0101010101011), -13),
XXX(99),
ammAlice.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, bob, STAmount{XTS, UINT64_C(98'9898989898989), -13}));
}
BEAST_EXPECT(expectLine(env, bob, XXX(101)));
BEAST_EXPECT(expectHolding(env, bob, XXX(101)));
}
void
@@ -783,8 +783,8 @@ private:
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(ammBob.expectBalances(
XRP(10'000), EUR(10'100), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(15'100)));
BEAST_EXPECT(expectLine(env, carol, EUR(14'900)));
BEAST_EXPECT(expectHolding(env, carol, USD(15'100)));
BEAST_EXPECT(expectHolding(env, carol, EUR(14'900)));
BEAST_EXPECT(expectOffers(env, carol, 0));
}
@@ -816,8 +816,8 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(15'100)));
BEAST_EXPECT(expectLine(env, carol, EUR(14'900)));
BEAST_EXPECT(expectHolding(env, carol, USD(15'100)));
BEAST_EXPECT(expectHolding(env, carol, EUR(14'900)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectOffers(env, bob, 0));
}
@@ -850,8 +850,8 @@ private:
BEAST_EXPECT(ammBob.expectBalances(
XRP(10'000), EUR(10'100), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(15'100)));
BEAST_EXPECT(expectLine(env, carol, EUR(14'900)));
BEAST_EXPECT(expectHolding(env, carol, USD(15'100)));
BEAST_EXPECT(expectHolding(env, carol, EUR(14'900)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectOffers(env, alice, 0));
}
@@ -894,7 +894,7 @@ private:
XRP(20'220),
STAmount{USD, UINT64_C(197'8239366963403), -13},
ammBob.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, alice, STAmount{USD, UINT64_C(1'002'17606330366), -11}));
BEAST_EXPECT(expectOffers(env, alice, 0));
}
@@ -912,7 +912,7 @@ private:
XRP(21'500),
STAmount{USD, UINT64_C(186'046511627907), -12},
ammBob.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, alice, STAmount{USD, UINT64_C(1'013'953488372093), -12}));
BEAST_EXPECT(expectOffers(env, alice, 0));
}
@@ -953,7 +953,7 @@ private:
// AMM doesn't pay the transfer fee
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
BEAST_EXPECT(expectOffers(env, carol, 0));
},
{{XRP(10'000), USD(10'100)}},
@@ -974,7 +974,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'000), USD(10'100), ammAlice.tokens()));
// Carol pays 25% transfer fee
BEAST_EXPECT(expectLine(env, carol, USD(29'875)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'875)));
BEAST_EXPECT(expectOffers(env, carol, 0));
},
{{XRP(10'100), USD(10'000)}},
@@ -1011,9 +1011,9 @@ private:
// AMM doesn't pay the transfer fee
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(15'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(15'100)));
// Carol pays 25% transfer fee.
BEAST_EXPECT(expectLine(env, carol, EUR(14'875)));
BEAST_EXPECT(expectHolding(env, carol, EUR(14'875)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectOffers(env, bob, 0));
}
@@ -1051,9 +1051,9 @@ private:
// AMM doesn't pay the transfer fee
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'050), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(15'050)));
BEAST_EXPECT(expectHolding(env, carol, USD(15'050)));
// Carol pays 25% transfer fee.
BEAST_EXPECT(expectLine(env, carol, EUR(14'937.5)));
BEAST_EXPECT(expectHolding(env, carol, EUR(14'937.5)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(
expectOffers(env, bob, 1, {{Amounts{EUR(50), XRP(50)}}}));
@@ -1077,7 +1077,7 @@ private:
env(pay(gw, carol, EUR(1'000)), sendmax(EUR(10'000)));
env.close();
// 1000 / 0.8
BEAST_EXPECT(expectLine(env, carol, EUR(1'250)));
BEAST_EXPECT(expectHolding(env, carol, EUR(1'250)));
// The scenario:
// o USD/XRP AMM is created.
// o EUR/XRP Offer is created.
@@ -1096,9 +1096,9 @@ private:
// AMM doesn't pay the transfer fee
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(100)));
BEAST_EXPECT(expectHolding(env, carol, USD(100)));
// Carol pays 25% transfer fee: 1250 - 100(offer) - 25(transfer fee)
BEAST_EXPECT(expectLine(env, carol, EUR(1'125)));
BEAST_EXPECT(expectHolding(env, carol, EUR(1'125)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectOffers(env, bob, 0));
}
@@ -1120,7 +1120,7 @@ private:
env(pay(gw, alice, USD(11'000)));
env(pay(gw, carol, EUR(1'000)), sendmax(EUR(10'000)));
env.close();
BEAST_EXPECT(expectLine(env, carol, EUR(1'000)));
BEAST_EXPECT(expectHolding(env, carol, EUR(1'000)));
// The scenario:
// o USD/XRP AMM is created.
// o EUR/XRP Offer is created.
@@ -1139,9 +1139,9 @@ private:
// AMM pay doesn't transfer fee
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(100)));
BEAST_EXPECT(expectHolding(env, carol, USD(100)));
// Carol pays 25% transfer fee: 1000 - 100(offer) - 25(transfer fee)
BEAST_EXPECT(expectLine(env, carol, EUR(875)));
BEAST_EXPECT(expectHolding(env, carol, EUR(875)));
BEAST_EXPECT(expectOffers(env, carol, 0));
BEAST_EXPECT(expectOffers(env, bob, 0));
}
@@ -1170,7 +1170,7 @@ private:
BEAST_EXPECT(ammBob.expectBalances(
XRP(10'100), USD_bob(10'000), ammBob.tokens()));
BEAST_EXPECT(expectOffers(env, alice, 0));
BEAST_EXPECT(expectLine(env, alice, USD_bob(100)));
BEAST_EXPECT(expectHolding(env, alice, USD_bob(100)));
}
void
@@ -1206,19 +1206,19 @@ private:
env.close();
env(pay(dan, bob, D_BUX(100)));
env.close();
BEAST_EXPECT(expectLine(env, bob, D_BUX(100)));
BEAST_EXPECT(expectHolding(env, bob, D_BUX(100)));
env(pay(ann, cam, D_BUX(60)), path(bob, dan), sendmax(A_BUX(200)));
env.close();
BEAST_EXPECT(expectLine(env, ann, A_BUX(none)));
BEAST_EXPECT(expectLine(env, ann, D_BUX(none)));
BEAST_EXPECT(expectLine(env, bob, A_BUX(72)));
BEAST_EXPECT(expectLine(env, bob, D_BUX(40)));
BEAST_EXPECT(expectLine(env, cam, A_BUX(none)));
BEAST_EXPECT(expectLine(env, cam, D_BUX(60)));
BEAST_EXPECT(expectLine(env, dan, A_BUX(none)));
BEAST_EXPECT(expectLine(env, dan, D_BUX(none)));
BEAST_EXPECT(expectHolding(env, ann, A_BUX(none)));
BEAST_EXPECT(expectHolding(env, ann, D_BUX(none)));
BEAST_EXPECT(expectHolding(env, bob, A_BUX(72)));
BEAST_EXPECT(expectHolding(env, bob, D_BUX(40)));
BEAST_EXPECT(expectHolding(env, cam, A_BUX(none)));
BEAST_EXPECT(expectHolding(env, cam, D_BUX(60)));
BEAST_EXPECT(expectHolding(env, dan, A_BUX(none)));
BEAST_EXPECT(expectHolding(env, dan, D_BUX(none)));
AMM ammBob(env, bob, A_BUX(30), D_BUX(30));
@@ -1234,12 +1234,12 @@ private:
BEAST_EXPECT(
ammBob.expectBalances(A_BUX(30), D_BUX(30), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, ann, A_BUX(none)));
BEAST_EXPECT(expectLine(env, ann, D_BUX(0)));
BEAST_EXPECT(expectLine(env, cam, A_BUX(none)));
BEAST_EXPECT(expectLine(env, cam, D_BUX(60)));
BEAST_EXPECT(expectLine(env, dan, A_BUX(0)));
BEAST_EXPECT(expectLine(env, dan, D_BUX(none)));
BEAST_EXPECT(expectHolding(env, ann, A_BUX(none)));
BEAST_EXPECT(expectHolding(env, ann, D_BUX(0)));
BEAST_EXPECT(expectHolding(env, cam, A_BUX(none)));
BEAST_EXPECT(expectHolding(env, cam, D_BUX(60)));
BEAST_EXPECT(expectHolding(env, dan, A_BUX(0)));
BEAST_EXPECT(expectHolding(env, dan, D_BUX(none)));
}
}
@@ -1363,7 +1363,7 @@ private:
env(pay(gw, bob, USD(50)));
env.close();
BEAST_EXPECT(expectLine(env, bob, USD(50)));
BEAST_EXPECT(expectHolding(env, bob, USD(50)));
// Bob's offer should cross Alice's AMM
env(offer(bob, XRP(50), USD(50)));
@@ -1372,7 +1372,7 @@ private:
BEAST_EXPECT(
ammAlice.expectBalances(USD(1'050), XRP(1'000), ammAlice.tokens()));
BEAST_EXPECT(expectOffers(env, bob, 0));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
}
void
@@ -1403,7 +1403,7 @@ private:
env(pay(gw, bob, USD(50)));
env.close();
BEAST_EXPECT(expectLine(env, bob, USD(50)));
BEAST_EXPECT(expectHolding(env, bob, USD(50)));
// Alice should not be able to create AMM without authorization.
{
@@ -1440,7 +1440,7 @@ private:
BEAST_EXPECT(
ammAlice.expectBalances(USD(1'050), XRP(1'000), ammAlice.tokens()));
BEAST_EXPECT(expectOffers(env, bob, 0));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
}
void
@@ -1535,7 +1535,7 @@ private:
// AMM offer is 51.282052XRP/11AUD, 11AUD/1.1 = 10AUD to bob
BEAST_EXPECT(
ammCarol.expectBalances(XRP(51), AUD(40), ammCarol.tokens()));
BEAST_EXPECT(expectLine(env, bob, AUD(10)));
BEAST_EXPECT(expectHolding(env, bob, AUD(10)));
auto const result =
find_paths(env, alice, bob, Account(bob)["USD"](25));
@@ -1950,10 +1950,10 @@ private:
env(pay(alice, carol, USD(50)), path(~USD), sendmax(BTC(50)));
BEAST_EXPECT(expectLine(env, alice, BTC(50)));
BEAST_EXPECT(expectLine(env, bob, BTC(0)));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectLine(env, carol, USD(200)));
BEAST_EXPECT(expectHolding(env, alice, BTC(50)));
BEAST_EXPECT(expectHolding(env, bob, BTC(0)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, carol, USD(200)));
BEAST_EXPECT(
ammBob.expectBalances(BTC(150), USD(100), ammBob.tokens()));
}
@@ -1974,10 +1974,10 @@ private:
env(pay(alice, carol, USD(50)), path(~XRP, ~USD), sendmax(BTC(50)));
BEAST_EXPECT(expectLine(env, alice, BTC(50)));
BEAST_EXPECT(expectLine(env, bob, BTC(0)));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectLine(env, carol, USD(200)));
BEAST_EXPECT(expectHolding(env, alice, BTC(50)));
BEAST_EXPECT(expectHolding(env, bob, BTC(0)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, carol, USD(200)));
BEAST_EXPECT(ammBobBTC_XRP.expectBalances(
BTC(150), XRP(100), ammBobBTC_XRP.tokens()));
BEAST_EXPECT(ammBobXRP_USD.expectBalances(
@@ -2003,8 +2003,8 @@ private:
env, alice, xrpMinusFee(env, 10'000 - 50)));
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(10'000) - XRP(100) - ammCrtFee(env)));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectLine(env, carol, USD(200)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, carol, USD(200)));
BEAST_EXPECT(
ammBob.expectBalances(XRP(150), USD(100), ammBob.tokens()));
}
@@ -2024,10 +2024,10 @@ private:
env(pay(alice, carol, XRP(50)), path(~XRP), sendmax(USD(50)));
BEAST_EXPECT(expectLine(env, alice, USD(50)));
BEAST_EXPECT(expectHolding(env, alice, USD(50)));
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(10'000) - XRP(150) - ammCrtFee(env)));
BEAST_EXPECT(expectLine(env, bob, USD(0)));
BEAST_EXPECT(expectHolding(env, bob, USD(0)));
BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRP(10'000 + 50)));
BEAST_EXPECT(
ammBob.expectBalances(USD(150), XRP(100), ammBob.tokens()));
@@ -2209,7 +2209,7 @@ private:
sendmax(USD(0.4)),
txflags(tfNoRippleDirect | tfPartialPayment));
BEAST_EXPECT(expectLine(env, carol, EUR(1)));
BEAST_EXPECT(expectHolding(env, carol, EUR(1)));
BEAST_EXPECT(ammBob.expectBalances(
USD(8.4), XRPAmount{20}, ammBob.tokens()));
}
@@ -2244,7 +2244,7 @@ private:
// alice buys 107.1428USD with 120GBP and pays 25% tr fee on 120GBP
// 1,000 - 120*1.25 = 850GBP
BEAST_EXPECT(expectLine(env, alice, GBP(850)));
BEAST_EXPECT(expectHolding(env, alice, GBP(850)));
if (!features[fixAMMv1_1])
{
// 120GBP is swapped in for 107.1428USD
@@ -2262,7 +2262,7 @@ private:
}
// 25% of 85.7142USD is paid in tr fee
// 85.7142*1.25 = 107.1428USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'085'714285714286), -12)));
}
@@ -2294,10 +2294,10 @@ private:
// alice buys 120EUR with 120GBP via the offer
// and pays 25% tr fee on 120GBP
// 1,000 - 120*1.25 = 850GBP
BEAST_EXPECT(expectLine(env, alice, GBP(850)));
BEAST_EXPECT(expectHolding(env, alice, GBP(850)));
// consumed offer is 120GBP/120EUR
// ed doesn't pay tr fee
BEAST_EXPECT(expectLine(env, ed, EUR(880), GBP(1'120)));
BEAST_EXPECT(expectHolding(env, ed, EUR(880), GBP(1'120)));
BEAST_EXPECT(
expectOffers(env, ed, 1, {Amounts{GBP(880), EUR(880)}}));
// 25% on 96EUR is paid in tr fee 96*1.25 = 120EUR
@@ -2307,7 +2307,7 @@ private:
STAmount{USD, UINT64_C(912'4087591240876), -13},
amm.tokens()));
// 25% on 70.0729USD is paid in tr fee 70.0729*1.25 = 87.5912USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'070'07299270073), -11)));
}
{
@@ -2333,7 +2333,7 @@ private:
txflags(tfNoRippleDirect | tfPartialPayment));
env.close();
BEAST_EXPECT(expectLine(env, alice, GBP(850)));
BEAST_EXPECT(expectHolding(env, alice, GBP(850)));
if (!features[fixAMMv1_1])
{
// alice buys 107.1428EUR with 120GBP and pays 25% tr fee on
@@ -2367,7 +2367,7 @@ private:
amm2.tokens()));
}
// 25% on 63.1578USD is paid in tr fee 63.1578*1.25 = 78.9473USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'063'157894736842), -12)));
}
{
@@ -2386,7 +2386,7 @@ private:
BEAST_EXPECT(
amm.expectBalances(USD(1'100), EUR(1'000), amm.tokens()));
// alice pays 25% tr fee on 100USD 1100-100*1.25 = 975USD
BEAST_EXPECT(expectLine(env, alice, USD(975), EUR(1'200)));
BEAST_EXPECT(expectHolding(env, alice, USD(975), EUR(1'200)));
BEAST_EXPECT(expectOffers(env, alice, 0));
}
@@ -2416,7 +2416,7 @@ private:
// alice buys 125USD with 142.8571GBP and pays 25% tr fee
// on 142.8571GBP
// 1,000 - 142.8571*1.25 = 821.4285GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, alice, STAmount(GBP, UINT64_C(821'4285714285712), -13)));
// 142.8571GBP is swapped in for 125USD
BEAST_EXPECT(amm.expectBalances(
@@ -2425,7 +2425,7 @@ private:
amm.tokens()));
// 25% on 100USD is paid in tr fee
// 100*1.25 = 125USD
BEAST_EXPECT(expectLine(env, carol, USD(1'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(1'100)));
}
{
// Payment via AMM with limit quality, deliver less
@@ -2456,7 +2456,7 @@ private:
// alice buys 28.125USD with 24GBP and pays 25% tr fee
// on 24GBP
// 1,200 - 24*1.25 = 1,170GBP
BEAST_EXPECT(expectLine(env, alice, GBP(1'170)));
BEAST_EXPECT(expectHolding(env, alice, GBP(1'170)));
// 24GBP is swapped in for 28.125USD
BEAST_EXPECT(amm.expectBalances(
GBP(1'024), USD(1'171.875), amm.tokens()));
@@ -2466,7 +2466,7 @@ private:
// alice buys 28.125USD with 24GBP and pays 25% tr fee
// on 24GBP
// 1,200 - 24*1.25 =~ 1,170GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'169'999999999999), -12}));
@@ -2478,7 +2478,7 @@ private:
}
// 25% on 22.5USD is paid in tr fee
// 22.5*1.25 = 28.125USD
BEAST_EXPECT(expectLine(env, carol, USD(1'222.5)));
BEAST_EXPECT(expectHolding(env, carol, USD(1'222.5)));
}
{
// Payment via offer and AMM with limit quality, deliver less
@@ -2513,13 +2513,13 @@ private:
// alice buys 70.4210EUR with 70.4210GBP via the offer
// and pays 25% tr fee on 70.4210GBP
// 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'311'973684210527), -12}));
// ed doesn't pay tr fee, the balances reflect consumed offer
// 70.4210GBP/70.4210EUR
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
ed,
STAmount{EUR, UINT64_C(1'329'578947368421), -12},
@@ -2543,13 +2543,13 @@ private:
// alice buys 70.4210EUR with 70.4210GBP via the offer
// and pays 25% tr fee on 70.4210GBP
// 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'311'973684210525), -12}));
// ed doesn't pay tr fee, the balances reflect consumed offer
// 70.4210GBP/70.4210EUR
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
ed,
STAmount{EUR, UINT64_C(1'329'57894736842), -11},
@@ -2569,7 +2569,7 @@ private:
amm.tokens()));
}
// 25% on 59.7321USD is paid in tr fee 59.7321*1.25 = 74.6651USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'459'732142857143), -12)));
}
{
@@ -2605,7 +2605,7 @@ private:
// alice buys 53.3322EUR with 56.3368GBP via the amm
// and pays 25% tr fee on 56.3368GBP
// 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'329'578947368421), -12}));
@@ -2622,7 +2622,7 @@ private:
// alice buys 53.3322EUR with 56.3368GBP via the amm
// and pays 25% tr fee on 56.3368GBP
// 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'329'57894736842), -11}));
@@ -2636,7 +2636,7 @@ private:
}
// 25% on 42.6658EUR is paid in tr fee 42.6658*1.25 = 53.3322EUR
// 42.6658EUR/59.7321USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
ed,
STAmount{USD, UINT64_C(1'340'267857142857), -12},
@@ -2649,7 +2649,7 @@ private:
STAmount{EUR, UINT64_C(957'3341836734693), -13},
STAmount{USD, UINT64_C(1'340'267857142857), -12}}}));
// 25% on 47.7857USD is paid in tr fee 47.7857*1.25 = 59.7321USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'447'785714285714), -12)));
}
{
@@ -2683,7 +2683,7 @@ private:
// alice buys 53.3322EUR with 107.5308GBP
// 25% on 86.0246GBP is paid in tr fee
// 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'292'469135802469), -12}));
@@ -2704,7 +2704,7 @@ private:
// alice buys 53.3322EUR with 107.5308GBP
// 25% on 86.0246GBP is paid in tr fee
// 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{GBP, UINT64_C(1'292'469135802466), -12}));
@@ -2721,7 +2721,7 @@ private:
amm2.tokens()));
}
// 25% on 66.7432USD is paid in tr fee 66.7432*1.25 = 83.4291USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount(USD, UINT64_C(1'466'743295019157), -12)));
}
{
@@ -2778,7 +2778,7 @@ private:
amm2.tokens()));
}
// 25% on 81.1111USD is paid in tr fee 81.1111*1.25 = 101.3888USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, carol, STAmount{USD, UINT64_C(1'481'111111111111), -12}));
}
}
@@ -2808,7 +2808,7 @@ private:
BEAST_EXPECT(
ammBob.expectBalances(XRP(1'050), USD(1'000), ammBob.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(2'050)));
BEAST_EXPECT(expectHolding(env, carol, USD(2'050)));
BEAST_EXPECT(expectOffers(env, bob, 1, {{{XRP(100), USD(50)}}}));
}
}

View File

@@ -97,8 +97,8 @@ private:
AMM ammAlice(env, alice, USD(20'000), BTC(0.5));
BEAST_EXPECT(ammAlice.expectBalances(
USD(20'000), BTC(0.5), IOUAmount{100, 0}));
BEAST_EXPECT(expectLine(env, alice, USD(0)));
BEAST_EXPECT(expectLine(env, alice, BTC(0)));
BEAST_EXPECT(expectHolding(env, alice, USD(0)));
BEAST_EXPECT(expectHolding(env, alice, BTC(0)));
}
// Require authorization is set, account is authorized
@@ -1394,7 +1394,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0}));
// 30,000 less deposited 1,000
BEAST_EXPECT(expectLine(env, carol, USD(29'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'000)));
// 30,000 less deposited 1,000 and 10 drops tx fee
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRPAmount{29'000'000'000 - baseFee}));
@@ -1449,7 +1449,8 @@ private:
IOUAmount{1, 7} + newLPTokens));
// 30,000 less deposited depositUSD
BEAST_EXPECT(expectLine(env, carol, USD(30'000) - depositUSD));
BEAST_EXPECT(
expectHolding(env, carol, USD(30'000) - depositUSD));
// 30,000 less deposited depositXRP and 10 drops tx fee
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRP(30'000) - depositXRP - txfee(env, 1)));
@@ -1553,15 +1554,15 @@ private:
AMM ammAlice(env, alice, USD(20'000), BTC(0.5));
BEAST_EXPECT(ammAlice.expectBalances(
USD(20'000), BTC(0.5), IOUAmount{100, 0}));
BEAST_EXPECT(expectLine(env, alice, USD(0)));
BEAST_EXPECT(expectLine(env, alice, BTC(0)));
BEAST_EXPECT(expectHolding(env, alice, USD(0)));
BEAST_EXPECT(expectHolding(env, alice, BTC(0)));
fund(env, gw, {carol}, {USD(2'000), BTC(0.05)}, Fund::Acct);
// no transfer fee on deposit
ammAlice.deposit(carol, 10);
BEAST_EXPECT(ammAlice.expectBalances(
USD(22'000), BTC(0.55), IOUAmount{110, 0}));
BEAST_EXPECT(expectLine(env, carol, USD(0)));
BEAST_EXPECT(expectLine(env, carol, BTC(0)));
BEAST_EXPECT(expectHolding(env, carol, USD(0)));
BEAST_EXPECT(expectHolding(env, carol, BTC(0)));
}
// Tiny deposits
@@ -2281,7 +2282,7 @@ private:
BEAST_EXPECT(
ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0}));
// 30,000 less deposited 1,000
BEAST_EXPECT(expectLine(env, carol, USD(29'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'000)));
// 30,000 less deposited 1,000 and 10 drops tx fee
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRPAmount{29'000'000'000 - baseFee}));
@@ -2290,7 +2291,7 @@ private:
ammAlice.withdraw(carol, 1'000'000);
BEAST_EXPECT(
ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero())));
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
BEAST_EXPECT(expectLedgerEntryRoot(
env, carol, XRPAmount{30'000'000'000 - 2 * baseFee}));
});
@@ -2525,22 +2526,22 @@ private:
AMM ammAlice(env, alice, USD(20'000), BTC(0.5));
BEAST_EXPECT(ammAlice.expectBalances(
USD(20'000), BTC(0.5), IOUAmount{100, 0}));
BEAST_EXPECT(expectLine(env, alice, USD(0)));
BEAST_EXPECT(expectLine(env, alice, BTC(0)));
BEAST_EXPECT(expectHolding(env, alice, USD(0)));
BEAST_EXPECT(expectHolding(env, alice, BTC(0)));
fund(env, gw, {carol}, {USD(2'000), BTC(0.05)}, Fund::Acct);
// no transfer fee on deposit
ammAlice.deposit(carol, 10);
BEAST_EXPECT(ammAlice.expectBalances(
USD(22'000), BTC(0.55), IOUAmount{110, 0}));
BEAST_EXPECT(expectLine(env, carol, USD(0)));
BEAST_EXPECT(expectLine(env, carol, BTC(0)));
BEAST_EXPECT(expectHolding(env, carol, USD(0)));
BEAST_EXPECT(expectHolding(env, carol, BTC(0)));
// no transfer fee on withdraw
ammAlice.withdraw(carol, 10);
BEAST_EXPECT(ammAlice.expectBalances(
USD(20'000), BTC(0.5), IOUAmount{100, 0}));
BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0, 0}));
BEAST_EXPECT(expectLine(env, carol, USD(2'000)));
BEAST_EXPECT(expectLine(env, carol, BTC(0.05)));
BEAST_EXPECT(expectHolding(env, carol, USD(2'000)));
BEAST_EXPECT(expectHolding(env, carol, BTC(0.05)));
}
// Tiny withdraw
@@ -3527,7 +3528,7 @@ private:
// Alice doesn't have anymore lp tokens
env(amm.bid({.account = alice, .bidMin = 500}));
BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{500}));
BEAST_EXPECT(expectLine(env, alice, STAmount{lpIssue, 0}));
BEAST_EXPECT(expectHolding(env, alice, STAmount{lpIssue, 0}));
// But trades with the discounted fee since she still owns the slot.
// Alice pays 10011 drops in fees
env(pay(alice, bob, USD(10)), path(~USD), sendmax(XRP(11)));
@@ -3790,7 +3791,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
// Initial balance 30,000 + 100
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
// Initial balance 30,000 - 100(sendmax) - 10(tx fee)
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(30'000) - XRP(100) - txfee(env, 1)));
@@ -3810,7 +3811,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
// Initial balance 30,000 + 100
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
// Initial balance 30,000 - 100(sendmax) - 10(tx fee)
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(30'000) - XRP(100) - txfee(env, 1)));
@@ -3831,7 +3832,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
// Initial balance 30,000 + 100
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
// Initial balance 30,000 - 100(sendmax) - 10(tx fee)
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(30'000) - XRP(100) - txfee(env, 1)));
@@ -3857,7 +3858,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'010), USD(10'000), ammAlice.tokens()));
// Initial balance 30,000 + 10(limited by limitQuality)
BEAST_EXPECT(expectLine(env, carol, USD(30'010)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'010)));
// Initial balance 30,000 - 10(limited by limitQuality) - 10(tx
// fee)
BEAST_EXPECT(expectLedgerEntryRoot(
@@ -3897,7 +3898,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'010), USD(10'000), ammAlice.tokens()));
// 10USD - 10% transfer fee
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'009'09090909091), -11}));
@@ -3984,7 +3985,7 @@ private:
BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}}));
}
// Initial 30,000 + 100
BEAST_EXPECT(expectLine(env, carol, STAmount{USD, 30'100}));
BEAST_EXPECT(expectHolding(env, carol, STAmount{USD, 30'100}));
// Initial 1,000 - 30082730(AMM pool) - 70798251(offer) - 10(tx fee)
BEAST_EXPECT(expectLedgerEntryRoot(
env,
@@ -4027,7 +4028,7 @@ private:
STAmount(EUR, UINT64_C(49'98750312422), -11),
STAmount(USD, UINT64_C(49'98750312422), -11)}}}));
// Initial 30,000 + 99.99999999999
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'099'99999999999), -11}));
@@ -4061,7 +4062,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
// Initial 30,000 + 200
BEAST_EXPECT(expectLine(env, carol, USD(30'200)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'200)));
}
else
{
@@ -4069,7 +4070,7 @@ private:
XRP(10'100),
STAmount(USD, UINT64_C(10'000'00000000001), -11),
ammAlice.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount(USD, UINT64_C(30'199'99999999999), -11)));
@@ -4104,7 +4105,7 @@ private:
env.close();
BEAST_EXPECT(ammAlice.expectBalances(
XRP(1'050), USD(1'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(2'200)));
BEAST_EXPECT(expectHolding(env, carol, USD(2'200)));
BEAST_EXPECT(expectOffers(env, bob, 0));
}
@@ -4118,7 +4119,7 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), USD(10'000), ammAlice.tokens()));
// Initial 1,000 + 100
BEAST_EXPECT(expectLine(env, bob, USD(1'100)));
BEAST_EXPECT(expectHolding(env, bob, USD(1'100)));
// Initial 30,000 - 100(offer) - 10(tx fee)
BEAST_EXPECT(expectLedgerEntryRoot(
env, bob, XRP(30'000) - XRP(100) - txfee(env, 1)));
@@ -4145,9 +4146,9 @@ private:
BEAST_EXPECT(ammAlice.expectBalances(
GBP(1'100), EUR(1'000), ammAlice.tokens()));
// Initial 30,000 - 100(offer) - 25% transfer fee
BEAST_EXPECT(expectLine(env, carol, GBP(29'875)));
BEAST_EXPECT(expectHolding(env, carol, GBP(29'875)));
// Initial 30,000 + 100(offer)
BEAST_EXPECT(expectLine(env, carol, EUR(30'100)));
BEAST_EXPECT(expectHolding(env, carol, EUR(30'100)));
BEAST_EXPECT(expectOffers(env, bob, 0));
},
{{GBP(1'000), EUR(1'100)}},
@@ -4285,12 +4286,12 @@ private:
// = 58.825 = ~29941.17
// carol bought ~72.93EUR at the cost of ~70.68GBP
// the offer is partially consumed
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{GBP, UINT64_C(29'941'16770347333), -11}));
// Initial 30,000 + ~49.3(offers = 39.3(AMM) + 10(LOB))
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{EUR, UINT64_C(30'049'31517120716), -11}));
@@ -4324,20 +4325,20 @@ private:
// = 88.35 = ~29911.64
// carol bought ~72.93EUR at the cost of ~70.68GBP
// the offer is partially consumed
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{GBP, UINT64_C(29'911'64396400896), -11}));
// Initial 30,000 + ~72.93(offers = 62.93(AMM) + 10(LOB))
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{EUR, UINT64_C(30'072'93416277865), -11}));
}
// Initial 2000 + 10 = 2010
BEAST_EXPECT(expectLine(env, bob, GBP(2'010)));
BEAST_EXPECT(expectHolding(env, bob, GBP(2'010)));
// Initial 2000 - 10 * 1.25 = 1987.5
BEAST_EXPECT(expectLine(env, ed, EUR(1'987.5)));
BEAST_EXPECT(expectHolding(env, ed, EUR(1'987.5)));
},
{{GBP(1'000), EUR(1'100)}},
0,
@@ -4363,8 +4364,8 @@ private:
env.close();
BEAST_EXPECT(ammAlice.expectBalances(
GBP(1'100), EUR(1'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, bob, GBP(75)));
BEAST_EXPECT(expectLine(env, carol, EUR(30'080)));
BEAST_EXPECT(expectHolding(env, bob, GBP(75)));
BEAST_EXPECT(expectHolding(env, carol, EUR(30'080)));
},
{{GBP(1'000), EUR(1'100)}},
0,
@@ -4401,12 +4402,12 @@ private:
sendmax(CAN(195.3125)),
txflags(tfPartialPayment));
env.close();
BEAST_EXPECT(expectLine(env, bob, CAN(0)));
BEAST_EXPECT(expectLine(env, dan, CAN(356.25), GBP(43.75)));
BEAST_EXPECT(expectHolding(env, bob, CAN(0)));
BEAST_EXPECT(expectHolding(env, dan, CAN(356.25), GBP(43.75)));
BEAST_EXPECT(ammAlice.expectBalances(
GBP(10'125), EUR(10'000), ammAlice.tokens()));
BEAST_EXPECT(expectLine(env, ed, EUR(300), USD(100)));
BEAST_EXPECT(expectLine(env, carol, USD(80)));
BEAST_EXPECT(expectHolding(env, ed, EUR(300), USD(100)));
BEAST_EXPECT(expectHolding(env, carol, USD(80)));
},
{{GBP(10'000), EUR(10'125)}},
0,
@@ -4523,7 +4524,7 @@ private:
BEAST_EXPECT(btc_usd.expectBalances(
BTC(10'100), USD(10'000), btc_usd.tokens()));
BEAST_EXPECT(expectLine(env, carol, USD(300)));
BEAST_EXPECT(expectHolding(env, carol, USD(300)));
}
// Dependent AMM
@@ -4594,7 +4595,7 @@ private:
STAmount{EUR, UINT64_C(10'917'2945958102), -10},
eth_eur.tokens()));
}
BEAST_EXPECT(expectLine(env, carol, USD(300)));
BEAST_EXPECT(expectHolding(env, carol, USD(300)));
}
// AMM offers limit
@@ -4620,7 +4621,7 @@ private:
XRP(10'030),
STAmount{USD, UINT64_C(9'970'089730807577), -12},
ammAlice.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'029'91026919241), -11}));
@@ -4631,7 +4632,7 @@ private:
XRP(10'030),
STAmount{USD, UINT64_C(9'970'089730807827), -12},
ammAlice.tokens()));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'029'91026919217), -11}));
@@ -4663,14 +4664,14 @@ private:
if (!features[fixAMMv1_1])
{
// Carol gets ~100USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'099'99999999999), -11}));
}
else
{
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
}
BEAST_EXPECT(expectOffers(
env,
@@ -4717,7 +4718,7 @@ private:
1,
{{{XRPAmount{50'074'628},
STAmount{USD, UINT64_C(50'07512950697), -11}}}}));
BEAST_EXPECT(expectLine(env, carol, USD(30'100)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'100)));
}
}
@@ -4809,11 +4810,11 @@ private:
env(offer(carol, STAmount{token2, 100}, STAmount{token1, 100}));
env.close();
BEAST_EXPECT(
expectLine(env, alice, STAmount{token1, 10'000'100}) &&
expectLine(env, alice, STAmount{token2, 9'999'900}));
expectHolding(env, alice, STAmount{token1, 10'000'100}) &&
expectHolding(env, alice, STAmount{token2, 9'999'900}));
BEAST_EXPECT(
expectLine(env, carol, STAmount{token2, 1'000'100}) &&
expectLine(env, carol, STAmount{token1, 999'900}));
expectHolding(env, carol, STAmount{token2, 1'000'100}) &&
expectHolding(env, carol, STAmount{token1, 999'900}));
BEAST_EXPECT(
expectOffers(env, alice, 0) && expectOffers(env, carol, 0));
});
@@ -5034,7 +5035,7 @@ private:
BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000}));
ammAlice.withdrawAll(carol, USD(3'000));
BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0}));
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
// Set fee to 1%
ammAlice.vote(alice, 1'000);
BEAST_EXPECT(ammAlice.expectTradingFee(1'000));
@@ -5043,12 +5044,12 @@ private:
ammAlice.deposit(carol, USD(3'000));
BEAST_EXPECT(ammAlice.expectLPTokens(
carol, IOUAmount{994'981155689671, -12}));
BEAST_EXPECT(expectLine(env, carol, USD(27'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(27'000)));
// Set fee to 0
ammAlice.vote(alice, 0);
ammAlice.withdrawAll(carol, USD(0));
// Carol gets back less than the original deposit
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(29'994'96220068281), -11}));
@@ -5109,13 +5110,13 @@ private:
ammAlice.deposit(carol, USD(3'000));
BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000}));
BEAST_EXPECT(expectLine(env, carol, USD(27'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(27'000)));
// Set fee to 1%
ammAlice.vote(alice, 1'000);
BEAST_EXPECT(ammAlice.expectTradingFee(1'000));
// Single withdrawal. Carol gets ~5USD less than deposited.
ammAlice.withdrawAll(carol, USD(0));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(29'994'97487437186), -11}));
@@ -5189,9 +5190,9 @@ private:
{USD(1'000), EUR(1'000)},
Fund::Acct);
// Alice contributed 1010EUR and 1000USD to the pool
BEAST_EXPECT(expectLine(env, alice, EUR(28'990)));
BEAST_EXPECT(expectLine(env, alice, USD(29'000)));
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, alice, EUR(28'990)));
BEAST_EXPECT(expectHolding(env, alice, USD(29'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
// Carol pays to Alice with no fee
env(pay(carol, alice, EUR(10)),
path(~EUR),
@@ -5199,9 +5200,9 @@ private:
txflags(tfNoRippleDirect));
env.close();
// Alice has 10EUR more and Carol has 10USD less
BEAST_EXPECT(expectLine(env, alice, EUR(29'000)));
BEAST_EXPECT(expectLine(env, alice, USD(29'000)));
BEAST_EXPECT(expectLine(env, carol, USD(29'990)));
BEAST_EXPECT(expectHolding(env, alice, EUR(29'000)));
BEAST_EXPECT(expectHolding(env, alice, USD(29'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'990)));
// Set fee to 1%
ammAlice.vote(alice, 1'000);
@@ -5213,10 +5214,10 @@ private:
txflags(tfNoRippleDirect));
env.close();
// Bob sends 10.1~EUR to pay 10USD
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, bob, STAmount{EUR, UINT64_C(989'8989898989899), -13}));
// Carol got 10USD
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
BEAST_EXPECT(ammAlice.expectBalances(
USD(1'000),
STAmount{EUR, UINT64_C(1'010'10101010101), -11},
@@ -5233,8 +5234,8 @@ private:
// No fee
env(offer(carol, EUR(10), USD(10)));
env.close();
BEAST_EXPECT(expectLine(env, carol, USD(29'990)));
BEAST_EXPECT(expectLine(env, carol, EUR(30'010)));
BEAST_EXPECT(expectHolding(env, carol, USD(29'990)));
BEAST_EXPECT(expectHolding(env, carol, EUR(30'010)));
// Change pool composition back
env(offer(carol, USD(10), EUR(10)));
env.close();
@@ -5245,11 +5246,11 @@ private:
env.close();
// Alice gets fewer ~4.97EUR for ~5.02USD, the difference goes
// to the pool
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(29'995'02512562814), -11}));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{EUR, UINT64_C(30'004'97487437186), -11}));
@@ -5299,16 +5300,16 @@ private:
path(~USD),
sendmax(EUR(15)),
txflags(tfNoRippleDirect));
BEAST_EXPECT(expectLine(env, ed, USD(2'010)));
BEAST_EXPECT(expectHolding(env, ed, USD(2'010)));
if (!features[fixAMMv1_1])
{
BEAST_EXPECT(expectLine(env, bob, EUR(1'990)));
BEAST_EXPECT(expectHolding(env, bob, EUR(1'990)));
BEAST_EXPECT(ammAlice.expectBalances(
USD(1'000), EUR(1'005), ammAlice.tokens()));
}
else
{
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env, bob, STAmount(EUR, UINT64_C(1989'999999999999), -12)));
BEAST_EXPECT(ammAlice.expectBalances(
USD(1'000),
@@ -5336,10 +5337,10 @@ private:
path(~USD),
sendmax(EUR(15)),
txflags(tfNoRippleDirect));
BEAST_EXPECT(expectLine(env, ed, USD(2'010)));
BEAST_EXPECT(expectHolding(env, ed, USD(2'010)));
if (!features[fixAMMv1_1])
{
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
bob,
STAmount{EUR, UINT64_C(1'989'987453007618), -12}));
@@ -5350,7 +5351,7 @@ private:
}
else
{
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
bob,
STAmount{EUR, UINT64_C(1'989'987453007628), -12}));
@@ -5381,8 +5382,8 @@ private:
path(~USD),
sendmax(EUR(15)),
txflags(tfNoRippleDirect));
BEAST_EXPECT(expectLine(env, ed, USD(2'010)));
BEAST_EXPECT(expectLine(env, bob, EUR(1'990)));
BEAST_EXPECT(expectHolding(env, ed, USD(2'010)));
BEAST_EXPECT(expectHolding(env, bob, EUR(1'990)));
BEAST_EXPECT(ammAlice.expectBalances(
USD(1'005), EUR(1'000), ammAlice.tokens()));
BEAST_EXPECT(expectOffers(env, carol, 0));
@@ -5408,8 +5409,8 @@ private:
path(~USD),
sendmax(EUR(15)),
txflags(tfNoRippleDirect));
BEAST_EXPECT(expectLine(env, ed, USD(2'010)));
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(env, ed, USD(2'010)));
BEAST_EXPECT(expectHolding(
env, bob, STAmount{EUR, UINT64_C(1'989'993923296712), -12}));
BEAST_EXPECT(ammAlice.expectBalances(
USD(1'004),
@@ -5480,47 +5481,47 @@ private:
else
BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'000), USD(10'000), IOUAmount{10'000'000}));
BEAST_EXPECT(expectLine(env, ben, USD(1'500'000)));
BEAST_EXPECT(expectLine(env, simon, USD(1'500'000)));
BEAST_EXPECT(expectLine(env, chris, USD(1'500'000)));
BEAST_EXPECT(expectLine(env, dan, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, ben, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, simon, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, chris, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, dan, USD(1'500'000)));
if (!features[fixAMMv1_1] && !features[fixAMMv1_3])
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
carol,
STAmount{USD, UINT64_C(30'000'00000000001), -11}));
else if (features[fixAMMv1_1] && !features[fixAMMv1_3])
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
else
BEAST_EXPECT(expectLine(env, carol, USD(30'000)));
BEAST_EXPECT(expectLine(env, ed, USD(1'500'000)));
BEAST_EXPECT(expectLine(env, paul, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, carol, USD(30'000)));
BEAST_EXPECT(expectHolding(env, ed, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, paul, USD(1'500'000)));
if (!features[fixAMMv1_1] && !features[fixAMMv1_3])
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
nataly,
STAmount{USD, UINT64_C(1'500'000'000000002), -9}));
else if (features[fixAMMv1_1] && !features[fixAMMv1_3])
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
nataly,
STAmount{USD, UINT64_C(1'500'000'000000005), -9}));
else
BEAST_EXPECT(expectLine(env, nataly, USD(1'500'000)));
BEAST_EXPECT(expectHolding(env, nataly, USD(1'500'000)));
ammAlice.withdrawAll(alice);
BEAST_EXPECT(!ammAlice.ammExists());
if (!features[fixAMMv1_1])
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{USD, UINT64_C(30'000'0000000013), -10}));
else if (features[fixAMMv1_3])
BEAST_EXPECT(expectLine(
BEAST_EXPECT(expectHolding(
env,
alice,
STAmount{USD, UINT64_C(30'000'0000000003), -10}));
else
BEAST_EXPECT(expectLine(env, alice, USD(30'000)));
BEAST_EXPECT(expectHolding(env, alice, USD(30'000)));
// alice XRP balance is 30,000initial - 50 ammcreate fee -
// 10drops fee
BEAST_EXPECT(
@@ -5883,7 +5884,7 @@ private:
BEAST_EXPECT(amm->expectBalances(
USD(1'000), ETH(1'000), amm->tokens()));
}
BEAST_EXPECT(expectLine(env, bob, USD(2'100)));
BEAST_EXPECT(expectHolding(env, bob, USD(2'100)));
q[i] = Quality(Amounts{
ETH(2'000) - env.balance(carol, ETH),
env.balance(bob, USD) - USD(2'000)});
@@ -6056,7 +6057,7 @@ private:
-13}}}}));
}
}
BEAST_EXPECT(expectLine(env, bob, USD(2'100)));
BEAST_EXPECT(expectHolding(env, bob, USD(2'100)));
q[i] = Quality(Amounts{
ETH(2'000) - env.balance(carol, ETH),
env.balance(bob, USD) - USD(2'000)});
@@ -6203,7 +6204,7 @@ private:
sendmax(ETH(600)));
env.close();
BEAST_EXPECT(expectLine(env, bob, USD(2'100)));
BEAST_EXPECT(expectHolding(env, bob, USD(2'100)));
if (i == 2 && !features[fixAMMv1_1])
{

View File

@@ -1482,23 +1482,6 @@ class Invariants_test : public beast::unit_test::suite
sle->at(~sfVaultID) = std::nullopt;
},
},
{
"pseudo-account has 2 pseudo-account fields set",
[this](SLE::pointer& sle) {
BEAST_EXPECT(sle->at(~sfVaultID) && !sle->at(~sfAMMID));
sle->at(~sfAMMID) = ~sle->at(~sfVaultID);
},
},
/*
{
"pseudo-account has 2 pseudo-account fields set",
[this](SLE::pointer& sle) {
BEAST_EXPECT(
sle->at(~sfVaultID) && !sle->at(~sfLoanBrokerID));
sle->at(~sfLoanBrokerID) = ~sle->at(~sfVaultID);
},
},
*/
{
"pseudo-account sequence changed",
[](SLE::pointer& sle) { sle->at(sfSequence) = 12345; },
@@ -1532,6 +1515,31 @@ class Invariants_test : public beast::unit_test::suite
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
createPseudo);
}
for (auto const pField : getPseudoAccountFields())
{
// createPseudo creates a vault, so sfVaultID will be set, and
// setting it again will not cause an error
if (pField == &sfVaultID)
continue;
doInvariantCheck(
{{"pseudo-account has 2 pseudo-account fields set"}},
[&](Account const& A1, Account const&, ApplyContext& ac) {
auto sle = ac.view().peek(keylet::account(pseudoAccountID));
if (!sle)
return false;
auto const vaultID = ~sle->at(~sfVaultID);
BEAST_EXPECT(vaultID && !sle->isFieldPresent(*pField));
sle->setFieldH256(*pField, *vaultID);
ac.view().update(sle);
return true;
},
XRPAmount{},
STTx{ttACCOUNT_SET, [](STObject& tx) {}},
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
createPseudo);
}
// Take one of the regular accounts and set the sequence to 0, which
// will make it look like a pseudo-account

View File

@@ -287,11 +287,11 @@ class LPTokenTransfer_test : public jtx::AMMTest
// with fixFrozenLPTokenTransfer enabled, alice's offer can no
// longer cross with carol's offer
BEAST_EXPECT(
expectLine(env, alice, STAmount{token1, 10'000'000}) &&
expectLine(env, alice, STAmount{token2, 10'000'000}));
expectHolding(env, alice, STAmount{token1, 10'000'000}) &&
expectHolding(env, alice, STAmount{token2, 10'000'000}));
BEAST_EXPECT(
expectLine(env, carol, STAmount{token2, 10'000'000}) &&
expectLine(env, carol, STAmount{token1, 10'000'000}));
expectHolding(env, carol, STAmount{token2, 10'000'000}) &&
expectHolding(env, carol, STAmount{token1, 10'000'000}));
BEAST_EXPECT(
expectOffers(env, alice, 1) && expectOffers(env, carol, 0));
}
@@ -300,11 +300,11 @@ class LPTokenTransfer_test : public jtx::AMMTest
// alice's offer still crosses with carol's offer despite carol's
// token1 is frozen
BEAST_EXPECT(
expectLine(env, alice, STAmount{token1, 10'000'100}) &&
expectLine(env, alice, STAmount{token2, 9'999'900}));
expectHolding(env, alice, STAmount{token1, 10'000'100}) &&
expectHolding(env, alice, STAmount{token2, 9'999'900}));
BEAST_EXPECT(
expectLine(env, carol, STAmount{token2, 10'000'100}) &&
expectLine(env, carol, STAmount{token1, 9'999'900}));
expectHolding(env, carol, STAmount{token2, 10'000'100}) &&
expectHolding(env, carol, STAmount{token1, 9'999'900}));
BEAST_EXPECT(
expectOffers(env, alice, 0) && expectOffers(env, carol, 0));
}

View File

@@ -453,7 +453,7 @@ PrettyAmount
xrpMinusFee(Env const& env, std::int64_t xrpAmount);
bool
expectLine(
expectHolding(
Env& env,
AccountID const& account,
STAmount const& value,
@@ -461,18 +461,18 @@ expectLine(
template <typename... Amts>
bool
expectLine(
expectHolding(
Env& env,
AccountID const& account,
STAmount const& value,
Amts const&... amts)
{
return expectLine(env, account, value, false) &&
expectLine(env, account, amts...);
return expectHolding(env, account, value, false) &&
expectHolding(env, account, amts...);
}
bool
expectLine(Env& env, AccountID const& account, None const& value);
expectHolding(Env& env, AccountID const& account, None const& value);
bool
expectOffers(

View File

@@ -103,7 +103,7 @@ xrpMinusFee(Env const& env, std::int64_t xrpAmount)
};
[[nodiscard]] bool
expectLine(
expectHolding(
Env& env,
AccountID const& account,
STAmount const& value,
@@ -137,13 +137,17 @@ expectLine(
}
[[nodiscard]] bool
expectLine(Env& env, AccountID const& account, None const&, Issue const& issue)
expectHolding(
Env& env,
AccountID const& account,
None const&,
Issue const& issue)
{
return !env.le(keylet::line(account, issue));
}
[[nodiscard]] bool
expectLine(
expectHolding(
Env& env,
AccountID const& account,
None const&,
@@ -153,11 +157,11 @@ expectLine(
}
[[nodiscard]] bool
expectLine(Env& env, AccountID const& account, None const& value)
expectHolding(Env& env, AccountID const& account, None const& value)
{
return std::visit(
[&](auto const& issue) {
return expectLine(env, account, value, issue);
return expectHolding(env, account, value, issue);
},
value.asset.value());
}

View File

@@ -91,12 +91,18 @@ operator<<(std::ostream& os, PrettyAmount const& amount)
os << to_places(d, 6) << " XRP";
}
else
else if (amount.value().holds<Issue>())
{
os << amount.value().getText() << "/"
<< to_string(amount.value().issue().currency) << "(" << amount.name()
<< ")";
}
else
{
auto const& mptIssue = amount.value().asset().get<MPTIssue>();
os << amount.value().getText() << "/" << to_string(mptIssue) << "("
<< amount.name() << ")";
}
return os;
}

View File

@@ -485,7 +485,8 @@ AccountRootsDeletedClean::finalize(
// feature is enabled. Enabled, or not, though, a fatal-level message will
// be logged
[[maybe_unused]] bool const enforce =
view.rules().enabled(featureInvariantsV1_1);
view.rules().enabled(featureInvariantsV1_1) ||
view.rules().enabled(featureSingleAssetVault);
auto const objectExists = [&view, enforce, &j](auto const& keylet) {
(void)enforce;
@@ -538,7 +539,8 @@ AccountRootsDeletedClean::finalize(
return false;
}
// Keys directly stored in the AccountRoot object
// If the account is a pseudo account, then the linked object must
// also be deleted. e.g. AMM, Vault, etc.
for (auto const& field : getPseudoAccountFields())
{
if (accountSLE->isFieldPresent(*field))
@@ -569,7 +571,7 @@ LedgerEntryTypesMatch::visitEntry(
#pragma push_macro("LEDGER_ENTRY")
#undef LEDGER_ENTRY
#define LEDGER_ENTRY(tag, value, name, rpcName, fields) case tag:
#define LEDGER_ENTRY(tag, ...) case tag:
switch (after->getType())
{
@@ -1507,36 +1509,6 @@ ValidMPTIssuance::finalize(
return true;
}
if (tx.getTxnType() == ttMPTOKEN_ISSUANCE_SET)
{
if (mptIssuancesDeleted_ > 0)
{
JLOG(j.fatal()) << "Invariant failed: MPT issuance set "
"succeeded while removing MPT issuances";
}
else if (mptIssuancesCreated_ > 0)
{
JLOG(j.fatal()) << "Invariant failed: MPT issuance set "
"succeeded while creating MPT issuances";
}
else if (mptokensDeleted_ > 0)
{
JLOG(j.fatal()) << "Invariant failed: MPT issuance set "
"succeeded while removing MPTokens";
}
else if (mptokensCreated_ > 0)
{
JLOG(j.fatal()) << "Invariant failed: MPT issuance set "
"succeeded while creating MPTokens";
}
return mptIssuancesCreated_ == 0 && mptIssuancesDeleted_ == 0 &&
mptokensCreated_ == 0 && mptokensDeleted_ == 0;
}
if (tx.getTxnType() == ttESCROW_FINISH)
return true;
}
if (mptIssuancesCreated_ != 0)

View File

@@ -938,7 +938,7 @@ chooseLedgerEntryType(Json::Value const& params)
#pragma push_macro("LEDGER_ENTRY")
#undef LEDGER_ENTRY
#define LEDGER_ENTRY(tag, value, name, rpcName, fields) \
#define LEDGER_ENTRY(tag, value, name, rpcName, ...) \
{jss::name, jss::rpcName, tag},
#include <xrpl/protocol/detail/ledger_entries.macro>