mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-31 11:00:23 +00:00
fix: Unify freeze checks for pseudo-account deposit/withdraw (#7382)
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> Co-authored-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
This commit is contained in:
@@ -7461,21 +7461,42 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
|
||||
// MPTLock is set
|
||||
usd.set({.flags = tfMPTLock});
|
||||
// carol and issuer can't withdraw
|
||||
for (auto const& account : {carol, gw})
|
||||
{
|
||||
amm.withdraw(
|
||||
{.account = account,
|
||||
.asset1Out = usd(1),
|
||||
.asset2Out = eur(1),
|
||||
.err = Ter(tecLOCKED)});
|
||||
amm.withdraw({.account = account, .tokens = 1'000, .err = Ter(tecLOCKED)});
|
||||
// can single withdraw another asset
|
||||
amm.withdraw(
|
||||
{.account = account,
|
||||
.asset1Out = eur(1),
|
||||
.assets = std::make_pair(eur, usd)});
|
||||
}
|
||||
auto const fix330 = env.current()->rules().enabled(fixCleanup3_3_0);
|
||||
|
||||
// carol can't withdraw the locked token (any withdrawal type)
|
||||
amm.withdraw(
|
||||
{.account = carol,
|
||||
.asset1Out = usd(1),
|
||||
.asset2Out = eur(1),
|
||||
.err = Ter(tecLOCKED)});
|
||||
amm.withdraw({.account = carol, .tokens = 1'000, .err = Ter(tecLOCKED)});
|
||||
// can single withdraw the non-locked asset
|
||||
amm.withdraw(
|
||||
{.account = carol, .asset1Out = eur(1), .assets = std::make_pair(eur, usd)});
|
||||
|
||||
// post-fixCleanup3_3_0 the issuer can redeem even when locked.
|
||||
// Each successful withdrawal burns LP tokens, so replenish between
|
||||
// each type to keep gw's LP balance stable.
|
||||
auto const gwLockErr = fix330 ? Ter(tesSUCCESS) : Ter(tecLOCKED);
|
||||
auto const replenish = [&](IOUAmount tokens) {
|
||||
usd.set({.flags = tfMPTUnlock});
|
||||
amm.deposit({.account = gw, .tokens = tokens});
|
||||
usd.set({.flags = tfMPTLock});
|
||||
};
|
||||
|
||||
amm.withdraw(
|
||||
{.account = gw, .asset1Out = usd(1), .asset2Out = eur(1), .err = gwLockErr});
|
||||
if (fix330)
|
||||
replenish(IOUAmount{1});
|
||||
|
||||
amm.withdraw({.account = gw, .tokens = 1'000, .err = gwLockErr});
|
||||
if (fix330)
|
||||
replenish(IOUAmount{1'000});
|
||||
|
||||
// can single withdraw the non-locked asset
|
||||
amm.withdraw(
|
||||
{.account = gw, .asset1Out = eur(1), .assets = std::make_pair(eur, usd)});
|
||||
|
||||
usd.set({.flags = tfMPTUnlock});
|
||||
|
||||
// MPTRequireAuth is set
|
||||
|
||||
Reference in New Issue
Block a user