@@ -6,8 +6,11 @@ import {
6
6
POX_CONTRACT ,
7
7
StackerInfo ,
8
8
allowContractCaller ,
9
+ delegateStackStx ,
10
+ delegateStx ,
9
11
getStackingMinimum ,
10
12
setSignerKeyAuthorization ,
13
+ stackAggregationCommitIndexed ,
11
14
stackStx ,
12
15
stackers ,
13
16
} from "./helpers" ;
@@ -1602,3 +1605,121 @@ describe("test `set-signer-key-authorization`", () => {
1602
1605
expect ( response . result ) . toBeErr ( Cl . int ( ERRORS . ERR_INVALID_REWARD_CYCLE ) ) ;
1603
1606
} ) ;
1604
1607
} ) ;
1608
+
1609
+ describe ( "test `get-num-reward-set-pox-addresses`" , ( ) => {
1610
+ it ( "returns 0 when there are no stackers" , ( ) => {
1611
+ const response = simnet . callReadOnlyFn (
1612
+ POX_CONTRACT ,
1613
+ "get-num-reward-set-pox-addresses" ,
1614
+ [ Cl . uint ( 1 ) ] ,
1615
+ address1
1616
+ ) ;
1617
+ expect ( response . result ) . toBeUint ( 0 ) ;
1618
+ } ) ;
1619
+
1620
+ it ( "returns the number of stackers" , ( ) => {
1621
+ const amount = getStackingMinimum ( ) * 2n ;
1622
+ stackers . forEach ( ( stacker ) => {
1623
+ stackStx (
1624
+ stacker ,
1625
+ amount ,
1626
+ 1000 ,
1627
+ 6 ,
1628
+ amount ,
1629
+ stacker . authId ,
1630
+ stacker . stxAddress
1631
+ ) ;
1632
+ } ) ;
1633
+
1634
+ const response = simnet . callReadOnlyFn (
1635
+ POX_CONTRACT ,
1636
+ "get-num-reward-set-pox-addresses" ,
1637
+ [ Cl . uint ( 1 ) ] ,
1638
+ address1
1639
+ ) ;
1640
+ expect ( response . result ) . toBeUint ( stackers . length ) ;
1641
+ } ) ;
1642
+
1643
+ it ( "returns the number of stackers for a specific reward cycle" , ( ) => {
1644
+ const amount = getStackingMinimum ( ) * 2n ;
1645
+ stackers . forEach ( ( stacker ) => {
1646
+ stackStx (
1647
+ stacker ,
1648
+ amount ,
1649
+ 1000 ,
1650
+ 6 ,
1651
+ amount ,
1652
+ stacker . authId ,
1653
+ stacker . stxAddress
1654
+ ) ;
1655
+ } ) ;
1656
+
1657
+ const response = simnet . callReadOnlyFn (
1658
+ POX_CONTRACT ,
1659
+ "get-num-reward-set-pox-addresses" ,
1660
+ [ Cl . uint ( 2 ) ] ,
1661
+ address1
1662
+ ) ;
1663
+ expect ( response . result ) . toBeUint ( stackers . length ) ;
1664
+ } ) ;
1665
+
1666
+ it ( "returns 0 when there are expired stackers" , ( ) => {
1667
+ const amount = getStackingMinimum ( ) * 2n ;
1668
+ stackers . forEach ( ( stacker ) => {
1669
+ stackStx (
1670
+ stacker ,
1671
+ amount ,
1672
+ 1000 ,
1673
+ 6 ,
1674
+ amount ,
1675
+ stacker . authId ,
1676
+ stacker . stxAddress
1677
+ ) ;
1678
+ } ) ;
1679
+
1680
+ const response = simnet . callReadOnlyFn (
1681
+ POX_CONTRACT ,
1682
+ "get-num-reward-set-pox-addresses" ,
1683
+ [ Cl . uint ( 8 ) ] ,
1684
+ address1
1685
+ ) ;
1686
+ expect ( response . result ) . toBeUint ( 0 ) ;
1687
+ } ) ;
1688
+
1689
+ it ( "handles delegated stacking" , ( ) => {
1690
+ const account = stackers [ 0 ] ;
1691
+ const minAmount = getStackingMinimum ( ) ;
1692
+ const amount = minAmount * 2n ;
1693
+ const maxAmount = minAmount * 4n ;
1694
+ const startBurnHeight = 1000 ;
1695
+ const lockPeriod = 6 ;
1696
+ const rewardCycle = 1 ;
1697
+ const authId = 1 ;
1698
+
1699
+ delegateStx ( maxAmount , address3 , null , account . btcAddr , account . stxAddress ) ;
1700
+ delegateStackStx (
1701
+ account . stxAddress ,
1702
+ amount ,
1703
+ account . btcAddr ,
1704
+ startBurnHeight ,
1705
+ lockPeriod ,
1706
+ address3
1707
+ ) ;
1708
+
1709
+ stackAggregationCommitIndexed (
1710
+ account ,
1711
+ rewardCycle ,
1712
+ maxAmount ,
1713
+ authId ,
1714
+ address3
1715
+ ) ;
1716
+
1717
+ const response = simnet . callReadOnlyFn (
1718
+ POX_CONTRACT ,
1719
+ "get-num-reward-set-pox-addresses" ,
1720
+ [ Cl . uint ( 1 ) ] ,
1721
+ address1
1722
+ ) ;
1723
+ expect ( response . result ) . toBeUint ( 1 ) ;
1724
+ } ) ;
1725
+ } ) ;
0 commit comments