mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
add tests for DeepFreeze
This commit is contained in:
@@ -4021,7 +4021,87 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
fee(1500));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// test Deep Freeze
|
||||
{
|
||||
// Env Setup
|
||||
Env env{*this, features};
|
||||
auto const baseFee = env.current()->fees().base;
|
||||
env.fund(XRP(10'000), alice, bob, gw);
|
||||
// env(fset(gw, asfAllowTrustLineLocking));
|
||||
env.close();
|
||||
env(trust(alice, USD(100'000)));
|
||||
env(trust(bob, USD(100'000)));
|
||||
env.close();
|
||||
env(pay(gw, alice, USD(10'000)));
|
||||
env(pay(gw, bob, USD(10'000)));
|
||||
env.close();
|
||||
|
||||
// set freeze on alice trustline
|
||||
env(trust(gw, USD(10'000), alice, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// setup transaction
|
||||
auto seq1 = env.seq(alice);
|
||||
auto const delta = USD(125);
|
||||
|
||||
// create escrow fails - frozen trustline
|
||||
env(escrow(alice, bob, delta),
|
||||
condition(cb1),
|
||||
finish_time(env.now() + 1s),
|
||||
fee(baseFee * 150),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// clear freeze on alice trustline
|
||||
env(trust(
|
||||
gw, USD(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// create escrow success
|
||||
seq1 = env.seq(alice);
|
||||
env(escrow(alice, bob, delta),
|
||||
condition(cb1),
|
||||
finish_time(env.now() + 1s),
|
||||
fee(baseFee * 150));
|
||||
env.close();
|
||||
|
||||
// set freeze on bob trustline
|
||||
env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// bob finish escrow fails because of deep frozen assets
|
||||
env(finish(bob, alice, seq1),
|
||||
condition(cb1),
|
||||
fulfillment(fb1),
|
||||
fee(baseFee * 150),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// reset freeze on alice and bob trustline
|
||||
env(trust(
|
||||
gw, USD(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
|
||||
env(trust(gw, USD(10'000), bob, tfClearFreeze | tfClearDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// create escrow success
|
||||
seq1 = env.seq(alice);
|
||||
env(escrow(alice, bob, delta),
|
||||
condition(cb1),
|
||||
cancel_time(env.now() + 1s),
|
||||
fee(baseFee * 150));
|
||||
env.close();
|
||||
|
||||
// set freeze on bob trustline
|
||||
env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// bob cancel escrow fails because of deep frozen assets
|
||||
env(cancel(bob, alice, seq1), fee(baseFee), ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testIOUTLINSF(FeatureBitset features)
|
||||
{
|
||||
|
||||
@@ -5512,6 +5512,87 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
reqBal = chanBal + delta;
|
||||
authAmt = reqBal + USD(100);
|
||||
|
||||
// bob claim paychan success
|
||||
sig = signClaimIOUAuth(alice.pk(), alice.sk(), chan, authAmt);
|
||||
env(paychan::claim(
|
||||
bob, chan, reqBal, authAmt, Slice(sig), alice.pk()));
|
||||
env.close();
|
||||
}
|
||||
// test Deep Freeze
|
||||
{
|
||||
// Env Setup
|
||||
Env env{*this, features};
|
||||
env.fund(XRP(10000), alice, bob, gw);
|
||||
env.close();
|
||||
env(trust(alice, USD(100000)));
|
||||
env(trust(bob, USD(100000)));
|
||||
env.close();
|
||||
env(pay(gw, alice, USD(10000)));
|
||||
env(pay(gw, bob, USD(10000)));
|
||||
env.close();
|
||||
|
||||
// set freeze on alice trustline
|
||||
env(trust(gw, USD(100000), alice, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// setup transaction
|
||||
auto const pk = alice.pk();
|
||||
auto const settleDelay = 100s;
|
||||
auto chan = channel(alice, bob, env.seq(alice));
|
||||
|
||||
// create paychan fails - frozen trustline
|
||||
env(paychan::create(alice, bob, USD(1000), settleDelay, pk),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// clear freeze on alice trustline
|
||||
env(trust(
|
||||
gw, USD(100000), alice, tfClearFreeze | tfClearDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// create paychan success
|
||||
chan = channel(alice, bob, env.seq(alice));
|
||||
env(paychan::create(alice, bob, USD(1000), settleDelay, pk));
|
||||
env.close();
|
||||
|
||||
// set freeze on alice trustline
|
||||
env(trust(gw, USD(100000), alice, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// paychan fields
|
||||
auto chanBal = channelBalance(*env.current(), chan);
|
||||
auto chanAmt = channelAmount(*env.current(), chan);
|
||||
auto const delta = USD(10);
|
||||
auto reqBal = chanBal + delta;
|
||||
auto authAmt = reqBal + USD(100);
|
||||
|
||||
// alice claim paychan fails - frozen trustline
|
||||
env(paychan::claim(alice, chan, reqBal, authAmt), ter(tecFROZEN));
|
||||
|
||||
// bob claim paychan fails - frozen trustline
|
||||
auto sig = signClaimIOUAuth(alice.pk(), alice.sk(), chan, authAmt);
|
||||
env(paychan::claim(
|
||||
bob, chan, reqBal, authAmt, Slice(sig), alice.pk()),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// clear freeze on bob trustline
|
||||
env(trust(gw, USD(100000), bob, tfClearFreeze | tfClearDeepFreeze));
|
||||
// clear freeze on alice trustline
|
||||
env(trust(
|
||||
gw, USD(100000), alice, tfClearFreeze | tfClearDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// alice claim paychan success
|
||||
env(paychan::claim(alice, chan, reqBal, authAmt));
|
||||
env.close();
|
||||
|
||||
// paychan fields
|
||||
chanBal = channelBalance(*env.current(), chan);
|
||||
chanAmt = channelAmount(*env.current(), chan);
|
||||
reqBal = chanBal + delta;
|
||||
authAmt = reqBal + USD(100);
|
||||
|
||||
// bob claim paychan success
|
||||
sig = signClaimIOUAuth(alice.pk(), alice.sk(), chan, authAmt);
|
||||
env(paychan::claim(
|
||||
|
||||
@@ -2389,12 +2389,18 @@ struct Remit_test : public beast::unit_test::suite
|
||||
env(trust(gw, USD(100000), alice, tfSetFreeze));
|
||||
env.close();
|
||||
|
||||
// remit fails - frozen trustline
|
||||
// outgoing remit fails - frozen trustline
|
||||
env(remit::remit(alice, bob),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// incoming remit success - frozen trustline
|
||||
// env(remit::remit(bob, alice),
|
||||
// remit::amts({XRP(1), USD(1)}),
|
||||
// ter(tesSUCCESS));
|
||||
// env.close();
|
||||
|
||||
// clear freeze on alice trustline
|
||||
env(trust(gw, USD(100000), alice, tfClearFreeze));
|
||||
env.close();
|
||||
@@ -2404,6 +2410,76 @@ struct Remit_test : public beast::unit_test::suite
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
// incoming remit success
|
||||
env(remit::remit(bob, alice),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testTLDeepFreeze(FeatureBitset features)
|
||||
{
|
||||
testcase("trustline deep freeze");
|
||||
using namespace test::jtx;
|
||||
using namespace std::literals;
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
auto const carol = Account("carol");
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const USD = gw["USD"];
|
||||
|
||||
auto const aliceUSD = alice["USD"];
|
||||
auto const bobUSD = bob["USD"];
|
||||
|
||||
// test Deep Freeze
|
||||
{
|
||||
// Env Setup
|
||||
Env env{*this, features};
|
||||
env.fund(XRP(10000), alice, bob, gw);
|
||||
env.close();
|
||||
env(trust(alice, USD(100000)));
|
||||
env(trust(bob, USD(100000)));
|
||||
env.close();
|
||||
env(pay(gw, alice, USD(10000)));
|
||||
env(pay(gw, bob, USD(10000)));
|
||||
env.close();
|
||||
|
||||
// set deep freeze on alice trustline
|
||||
env(trust(gw, USD(100000), alice, tfSetFreeze | tfSetDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// outgoing remit fails - deep frozen trustline
|
||||
env(remit::remit(alice, bob),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// incoming remit fails - deep frozen trustline
|
||||
env(remit::remit(bob, alice),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tecFROZEN));
|
||||
env.close();
|
||||
|
||||
// clear freeze on alice trustline
|
||||
env(trust(
|
||||
gw, USD(100000), alice, tfClearFreeze | tfClearDeepFreeze));
|
||||
env.close();
|
||||
|
||||
// outgoing remit success
|
||||
env(remit::remit(alice, bob),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
// incoming remit success
|
||||
env(remit::remit(bob, alice),
|
||||
remit::amts({XRP(1), USD(1)}),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2816,6 +2892,7 @@ struct Remit_test : public beast::unit_test::suite
|
||||
testRequireAuth(features);
|
||||
testDepositAuth(features);
|
||||
testTLFreeze(features);
|
||||
testTLDeepFreeze(features);
|
||||
testRippling(features);
|
||||
testURIToken(features);
|
||||
testOptionals(features);
|
||||
|
||||
Reference in New Issue
Block a user