mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 18:55:49 +00:00
Add DeepFreeze test for URIToken (#539)
This commit is contained in:
@@ -1932,31 +1932,135 @@ struct URIToken_test : public beast::unit_test::suite
|
|||||||
env(pay(gw, bob, USD(1000)));
|
env(pay(gw, bob, USD(1000)));
|
||||||
env.close();
|
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();
|
env.close();
|
||||||
|
|
||||||
// setup mint
|
{
|
||||||
std::string const uri(maxTokenURILength, '?');
|
// set freeze on bob trustline
|
||||||
auto const tid = uritoken::tokenid(alice, uri);
|
env(trust(gw, USD(10000), bob, tfSetFreeze | tfSetDeepFreeze));
|
||||||
std::string const hexid{strHex(tid)};
|
env.close();
|
||||||
env(uritoken::mint(alice, uri));
|
|
||||||
env(uritoken::sell(alice, hexid), uritoken::amt(USD(10)));
|
|
||||||
env.close();
|
|
||||||
|
|
||||||
// buy uritoken fails - frozen trustline
|
// IOU bob(frozen) -> alice
|
||||||
env(uritoken::buy(bob, hexid),
|
// setup mint
|
||||||
uritoken::amt(USD(10)),
|
std::string const uri(maxTokenURILength, '?');
|
||||||
ter(tecINSUFFICIENT_FUNDS));
|
auto const tid = uritoken::tokenid(alice, uri);
|
||||||
env.close();
|
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
|
// buy uritoken fails - frozen trustline
|
||||||
env(trust(gw, USD(10000), bob, tfClearFreeze));
|
env(uritoken::buy(bob, hexid),
|
||||||
env.close();
|
uritoken::amt(USD(10)),
|
||||||
|
ter(tecINSUFFICIENT_FUNDS));
|
||||||
|
env.close();
|
||||||
|
|
||||||
// buy uri success
|
// clear freeze on bob trustline
|
||||||
env(uritoken::buy(bob, hexid), uritoken::amt(USD(10)));
|
env(trust(
|
||||||
env.close();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user