@@ -2726,3 +2726,142 @@ describe("test `delegate-stack-extend`", () => {
2726
2726
expect ( tuple . data [ "lock-period" ] ) . toBeUint ( 1 ) ;
2727
2727
} ) ;
2728
2728
} ) ;
2729
+
2730
+ describe ( "test `get-partial-stacked-by-cycle`" , ( ) => {
2731
+ it ( "returns the correct amount" , ( ) => {
2732
+ const account = stackers [ 0 ] ;
2733
+ const amount = getStackingMinimum ( ) * 2n ;
2734
+ const maxAmount = amount * 2n ;
2735
+ const rewardCycle = 1 ;
2736
+
2737
+ delegateStx ( maxAmount , address2 , null , account . btcAddr , account . stxAddress ) ;
2738
+ delegateStackStx (
2739
+ account . stxAddress ,
2740
+ amount ,
2741
+ account . btcAddr ,
2742
+ 1000 ,
2743
+ 1 ,
2744
+ address2
2745
+ ) ;
2746
+
2747
+ const info = simnet . callReadOnlyFn (
2748
+ POX_CONTRACT ,
2749
+ "get-partial-stacked-by-cycle" ,
2750
+ [
2751
+ poxAddressToTuple ( account . btcAddr ) ,
2752
+ Cl . uint ( rewardCycle ) ,
2753
+ Cl . principal ( address2 ) ,
2754
+ ] ,
2755
+ address2
2756
+ ) ;
2757
+ expect ( info . result ) . toBeSome (
2758
+ Cl . tuple ( {
2759
+ "stacked-amount" : Cl . uint ( amount ) ,
2760
+ } )
2761
+ ) ;
2762
+ } ) ;
2763
+
2764
+ it ( "returns `none` when there are no partially stacked STX" , ( ) => {
2765
+ const account = stackers [ 0 ] ;
2766
+ const rewardCycle = 1 ;
2767
+
2768
+ const info = simnet . callReadOnlyFn (
2769
+ POX_CONTRACT ,
2770
+ "get-partial-stacked-by-cycle" ,
2771
+ [
2772
+ poxAddressToTuple ( account . btcAddr ) ,
2773
+ Cl . uint ( rewardCycle ) ,
2774
+ Cl . principal ( address2 ) ,
2775
+ ] ,
2776
+ address2
2777
+ ) ;
2778
+ expect ( info . result ) . toBeNone ( ) ;
2779
+ } ) ;
2780
+
2781
+ it ( "returns `none` after fully stacked" , ( ) => {
2782
+ const account = stackers [ 0 ] ;
2783
+ const amount = getStackingMinimum ( ) * 2n ;
2784
+ const maxAmount = amount * 2n ;
2785
+ const rewardCycle = 1 ;
2786
+ const authId = 1 ;
2787
+
2788
+ delegateStx ( maxAmount , address2 , null , account . btcAddr , account . stxAddress ) ;
2789
+ delegateStackStx (
2790
+ account . stxAddress ,
2791
+ amount ,
2792
+ account . btcAddr ,
2793
+ 1000 ,
2794
+ 1 ,
2795
+ address2
2796
+ ) ;
2797
+
2798
+ let info = simnet . callReadOnlyFn (
2799
+ POX_CONTRACT ,
2800
+ "get-partial-stacked-by-cycle" ,
2801
+ [
2802
+ poxAddressToTuple ( account . btcAddr ) ,
2803
+ Cl . uint ( rewardCycle ) ,
2804
+ Cl . principal ( address2 ) ,
2805
+ ] ,
2806
+ address2
2807
+ ) ;
2808
+ expect ( info . result ) . toBeSome (
2809
+ Cl . tuple ( {
2810
+ "stacked-amount" : Cl . uint ( amount ) ,
2811
+ } )
2812
+ ) ;
2813
+
2814
+ stackAggregationCommitIndexed (
2815
+ account ,
2816
+ rewardCycle ,
2817
+ maxAmount ,
2818
+ authId ,
2819
+ address2
2820
+ ) ;
2821
+
2822
+ info = simnet . callReadOnlyFn (
2823
+ POX_CONTRACT ,
2824
+ "get-partial-stacked-by-cycle" ,
2825
+ [
2826
+ poxAddressToTuple ( account . btcAddr ) ,
2827
+ Cl . uint ( rewardCycle ) ,
2828
+ Cl . principal ( address2 ) ,
2829
+ ] ,
2830
+ address2
2831
+ ) ;
2832
+ expect ( info . result ) . toBeNone ( ) ;
2833
+ } ) ;
2834
+
2835
+ it ( "returns the correct amount for multiple cycles" , ( ) => {
2836
+ const account = stackers [ 0 ] ;
2837
+ const amount = getStackingMinimum ( ) * 2n ;
2838
+ const maxAmount = amount * 2n ;
2839
+ const rewardCycle = 4 ;
2840
+
2841
+ delegateStx ( maxAmount , address2 , null , account . btcAddr , account . stxAddress ) ;
2842
+ delegateStackStx (
2843
+ account . stxAddress ,
2844
+ amount ,
2845
+ account . btcAddr ,
2846
+ 1000 ,
2847
+ 6 ,
2848
+ address2
2849
+ ) ;
2850
+
2851
+ const info = simnet . callReadOnlyFn (
2852
+ POX_CONTRACT ,
2853
+ "get-partial-stacked-by-cycle" ,
2854
+ [
2855
+ poxAddressToTuple ( account . btcAddr ) ,
2856
+ Cl . uint ( rewardCycle ) ,
2857
+ Cl . principal ( address2 ) ,
2858
+ ] ,
2859
+ address2
2860
+ ) ;
2861
+ expect ( info . result ) . toBeSome (
2862
+ Cl . tuple ( {
2863
+ "stacked-amount" : Cl . uint ( amount ) ,
2864
+ } )
2865
+ ) ;
2866
+ } ) ;
2867
+ } ) ;
0 commit comments