Compare commits

..

3 Commits

Author SHA1 Message Date
Niq Dudfield
8b0be2d2f5 docs(freeze): canceling escrows with deep frozen assets is allowed 2025-07-09 10:26:24 +07:00
tequ
60dec74baf Add DeepFreeze test for URIToken (#539) 2025-07-09 12:49:47 +10:00
Denis Angell
9abea13649 Feature Clawback (#534) 2025-07-09 12:48:46 +10:00
2 changed files with 127 additions and 22 deletions

View File

@@ -4147,7 +4147,8 @@ struct Escrow_test : public beast::unit_test::suite
env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
env.close();
// bob cancel escrow fails because of deep frozen assets
// bob cancel escrow succeeds despite deep frozen assets (unlocking
// return is allowed)
env(escrow::cancel(bob, alice, seq1),
fee(baseFee),
ter(tesSUCCESS));
@@ -4657,4 +4658,4 @@ public:
BEAST_DEFINE_TESTSUITE(Escrow, app, ripple);
} // namespace test
} // namespace ripple
} // namespace ripple

View File

@@ -1932,31 +1932,135 @@ struct URIToken_test : public beast::unit_test::suite
env(pay(gw, bob, USD(1000)));
env.close();
// set freeze on alice trustline
env(trust(gw, USD(10000), bob, tfSetFreeze));
{
// IOU bob(frozen) -> alice
// set freeze on bob trustline
env(trust(gw, USD(10000), bob, tfSetFreeze));
env.close();
// setup mint
std::string const uri(maxTokenURILength, '?');
auto const tid = uritoken::tokenid(alice, uri);
std::string const hexid{strHex(tid)};
env(uritoken::mint(alice, uri));
env(uritoken::sell(alice, hexid), uritoken::amt(USD(10)));
env.close();
// buy uritoken fails - frozen trustline
env(uritoken::buy(bob, hexid),
uritoken::amt(USD(10)),
ter(tecINSUFFICIENT_FUNDS));
env.close();
// clear freeze on bob trustline
env(trust(gw, USD(10000), bob, tfClearFreeze));
env.close();
// buy uri success
env(uritoken::buy(bob, hexid), uritoken::amt(USD(10)));
env.close();
}
{
// IOU alice -> bob(frozen)
// set freeze on bob trustline
env(trust(gw, USD(10000), bob, tfSetFreeze));
env.close();
// setup mint
std::string const uri(maxTokenURILength, '?');
auto const tid = uritoken::tokenid(bob, uri);
std::string const hexid{strHex(tid)};
env(uritoken::mint(bob, uri));
env(uritoken::sell(bob, hexid), uritoken::amt(USD(10)));
env.close();
// buy uritoken fails - frozen trustline
env(uritoken::buy(alice, hexid),
uritoken::amt(USD(10)),
ter(tecFROZEN));
env.close();
// clear freeze on bob trustline
env(trust(gw, USD(10000), bob, tfClearFreeze));
env.close();
// buy uri success
env(uritoken::buy(alice, hexid), uritoken::amt(USD(10)));
env.close();
}
}
// test DeepFreeze
{
// Env Setup
Env env{*this, features};
env.fund(XRP(1000), alice, bob, gw);
env.close();
env.trust(USD(100000), alice, bob);
env.close();
env(pay(gw, alice, USD(1000)));
env(pay(gw, bob, USD(1000)));
env.close();
// setup mint
std::string const uri(maxTokenURILength, '?');
auto const tid = uritoken::tokenid(alice, uri);
std::string const hexid{strHex(tid)};
env(uritoken::mint(alice, uri));
env(uritoken::sell(alice, hexid), uritoken::amt(USD(10)));
env.close();
{
// set freeze on bob trustline
env(trust(gw, USD(10000), bob, tfSetFreeze | tfSetDeepFreeze));
env.close();
// buy uritoken fails - frozen trustline
env(uritoken::buy(bob, hexid),
uritoken::amt(USD(10)),
ter(tecINSUFFICIENT_FUNDS));
env.close();
// IOU bob(frozen) -> alice
// setup mint
std::string const uri(maxTokenURILength, '?');
auto const tid = uritoken::tokenid(alice, uri);
std::string const hexid{strHex(tid)};
env(uritoken::mint(alice, uri));
env(uritoken::sell(alice, hexid), uritoken::amt(USD(10)));
env.close();
// clear freeze on alice trustline
env(trust(gw, USD(10000), bob, tfClearFreeze));
env.close();
// buy uritoken fails - frozen trustline
env(uritoken::buy(bob, hexid),
uritoken::amt(USD(10)),
ter(tecINSUFFICIENT_FUNDS));
env.close();
// buy uri success
env(uritoken::buy(bob, hexid), uritoken::amt(USD(10)));
env.close();
// clear freeze on bob trustline
env(trust(
gw, USD(10000), bob, tfClearFreeze | tfClearDeepFreeze));
env.close();
// buy uri success
env(uritoken::buy(bob, hexid), uritoken::amt(USD(10)));
env.close();
}
{
// set freeze on bob trustline
env(trust(gw, USD(10000), bob, tfSetFreeze | tfSetDeepFreeze));
env.close();
// IOU alice -> bob(frozen)
// setup mint
std::string const uri(maxTokenURILength, '?');
auto const tid = uritoken::tokenid(bob, uri);
std::string const hexid{strHex(tid)};
env(uritoken::mint(bob, uri));
env(uritoken::sell(bob, hexid), uritoken::amt(USD(10)));
env.close();
// buy uritoken fails - frozen trustline
env(uritoken::buy(alice, hexid),
uritoken::amt(USD(10)),
ter(tecFROZEN));
env.close();
// clear freeze on bob trustline
env(trust(
gw, USD(10000), bob, tfClearFreeze | tfClearDeepFreeze));
env.close();
// buy uri success
env(uritoken::buy(alice, hexid), uritoken::amt(USD(10)));
env.close();
}
}
}