@@ -268,9 +268,9 @@ class Freeze_test : public beast::unit_test::suite
268
268
}
269
269
270
270
void
271
- testSetAndClean (FeatureBitset features)
271
+ testSetAndClear (FeatureBitset features)
272
272
{
273
- testcase (" Deep Freeze" );
273
+ testcase (" Freeze Set and Clear " );
274
274
275
275
using namespace test ::jtx;
276
276
Env env (*this , features);
@@ -689,6 +689,121 @@ class Freeze_test : public beast::unit_test::suite
689
689
return ;
690
690
}
691
691
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
+
692
807
uint32_t
693
808
modifiedTrustlineFlags (test::jtx::Env& env)
694
809
{
@@ -709,10 +824,11 @@ class Freeze_test : public beast::unit_test::suite
709
824
auto testAll = [this ](FeatureBitset features) {
710
825
testRippleState (features);
711
826
testDeepFreeze (features);
712
- testSetAndClean (features);
827
+ testSetAndClear (features);
713
828
testGlobalFreeze (features);
714
829
testNoFreeze (features);
715
830
testOffersWhenFrozen (features);
831
+ testPaymentsWhenDeepFrozen (features);
716
832
};
717
833
using namespace test ::jtx;
718
834
auto const sa = supported_amendments ();
0 commit comments