Skip to content

Commit 805102a

Browse files
committed
Added payment tests for freeze and deep freeze
1 parent c7c26ac commit 805102a

File tree

1 file changed

+119
-3
lines changed

1 file changed

+119
-3
lines changed

src/test/app/Freeze_test.cpp

+119-3
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ class Freeze_test : public beast::unit_test::suite
268268
}
269269

270270
void
271-
testSetAndClean(FeatureBitset features)
271+
testSetAndClear(FeatureBitset features)
272272
{
273-
testcase("Deep Freeze");
273+
testcase("Freeze Set and Clear");
274274

275275
using namespace test::jtx;
276276
Env env(*this, features);
@@ -689,6 +689,121 @@ class Freeze_test : public beast::unit_test::suite
689689
return;
690690
}
691691

692+
void
693+
testPaymentsWhenDeepFrozen(FeatureBitset features)
694+
{
695+
testcase("Direct payments on frozen trust lines");
696+
697+
using namespace test::jtx;
698+
Env env(*this, features);
699+
700+
Account G1{"G1"};
701+
Account A1{"A1"};
702+
Account A2{"A2"};
703+
704+
env.fund(XRP(10000), G1);
705+
env.fund(XRP(10000), A1);
706+
env.fund(XRP(10000), A2);
707+
env.close();
708+
709+
env.trust(G1["USD"](1000), A1);
710+
env.trust(G1["USD"](1000), A2);
711+
env.close();
712+
713+
env(pay(G1, A1, G1["USD"](1000)));
714+
env(pay(G1, A2, G1["USD"](1000)));
715+
env.close();
716+
717+
// Checking payments before freeze
718+
// To issuer:
719+
env(pay(A1, G1, G1["USD"](1)));
720+
env(pay(A2, G1, G1["USD"](1)));
721+
env.close();
722+
723+
// To each other:
724+
env(pay(A1, A2, G1["USD"](1)));
725+
env(pay(A2, A1, G1["USD"](1)));
726+
env.close();
727+
728+
// Freeze A1
729+
env(trust(G1, A1["USD"](0), tfSetFreeze));
730+
env.close();
731+
732+
// Issuer and A1 can send payments to each other
733+
env(pay(A1, G1, G1["USD"](1)));
734+
env(pay(G1, A1, G1["USD"](1)));
735+
env.close();
736+
737+
// A1 cannot send tokens to A2
738+
env(pay(A1, A2, G1["USD"](1)), ter(tecPATH_DRY));
739+
740+
// A2 can still send to A1
741+
env(pay(A2, A1, G1["USD"](1)));
742+
env.close();
743+
744+
if (features[featureDeepFreeze])
745+
{
746+
// Deep freeze A1
747+
env(trust(G1, A1["USD"](0), tfSetDeepFreeze));
748+
env.close();
749+
750+
// Issuer and A1 can send payments to each other
751+
env(pay(A1, G1, G1["USD"](1)));
752+
env(pay(G1, A1, G1["USD"](1)));
753+
env.close();
754+
755+
// A1 cannot send tokens to A2
756+
env(pay(A1, A2, G1["USD"](1)), ter(tecPATH_DRY));
757+
758+
// A2 cannot send tokens to A1
759+
env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY));
760+
761+
// Clear deep freeze on A1
762+
env(trust(G1, A1["USD"](0), tfClearDeepFreeze));
763+
env.close();
764+
}
765+
766+
// Clear freeze on A1
767+
env(trust(G1, A1["USD"](0), tfClearFreeze));
768+
env.close();
769+
770+
// A1 freezes trust line
771+
env(trust(A1, G1["USD"](0), tfSetFreeze));
772+
env.close();
773+
774+
// Issuer and A1 can send payments to each other
775+
env(pay(A1, G1, G1["USD"](1)));
776+
// env(pay(G1, A1, G1["USD"](1))); // BUG: seems like
777+
env.close();
778+
779+
// Issuer and A2 must not be affected
780+
env(pay(A2, G1, G1["USD"](1)));
781+
env(pay(G1, A2, G1["USD"](1)));
782+
env.close();
783+
784+
// A1 can send tokens to A2
785+
env(pay(A1, A2, G1["USD"](1)));
786+
env.close();
787+
788+
// A2 cannot send tokens to A1
789+
env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY));
790+
791+
if (features[featureDeepFreeze])
792+
{
793+
// A1 deep freezes trust line
794+
env(trust(A1, G1["USD"](0), tfSetDeepFreeze));
795+
// Issuer and A1 can send payments to each other
796+
env(pay(A1, G1, G1["USD"](1)));
797+
// env(pay(G1, A1, G1["USD"](1))); // BUG: seems like
798+
env.close();
799+
800+
// A1 cannot send tokens to A2
801+
env(pay(A1, A2, G1["USD"](1)), ter(tecPATH_DRY));
802+
// A2 cannot send tokens to A1
803+
env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY));
804+
}
805+
}
806+
692807
uint32_t
693808
modifiedTrustlineFlags(test::jtx::Env& env)
694809
{
@@ -709,10 +824,11 @@ class Freeze_test : public beast::unit_test::suite
709824
auto testAll = [this](FeatureBitset features) {
710825
testRippleState(features);
711826
testDeepFreeze(features);
712-
testSetAndClean(features);
827+
testSetAndClear(features);
713828
testGlobalFreeze(features);
714829
testNoFreeze(features);
715830
testOffersWhenFrozen(features);
831+
testPaymentsWhenDeepFrozen(features);
716832
};
717833
using namespace test::jtx;
718834
auto const sa = supported_amendments();

0 commit comments

Comments
 (0)