@@ -685,6 +685,35 @@ contract("Colony Expenditure", (accounts) => {
685
685
expect ( potPayout ) . to . be . zero ;
686
686
} ) ;
687
687
688
+ it ( "should automatically reclaim funds if there is excess funding for a token" , async ( ) => {
689
+ await colony . setExpenditureRecipient ( expenditureId , SLOT0 , RECIPIENT , { from : ADMIN } ) ;
690
+ await colony . setExpenditurePayout ( expenditureId , SLOT0 , token . address , WAD , { from : ADMIN } ) ;
691
+
692
+ const expenditure = await colony . getExpenditure ( expenditureId ) ;
693
+ await colony . moveFundsBetweenPots (
694
+ 1 ,
695
+ UINT256_MAX ,
696
+ 1 ,
697
+ UINT256_MAX ,
698
+ UINT256_MAX ,
699
+ domain1 . fundingPotId ,
700
+ expenditure . fundingPotId ,
701
+ WAD . muln ( 2 ) ,
702
+ token . address
703
+ ) ;
704
+ await colony . finalizeExpenditure ( expenditureId , { from : ADMIN } ) ;
705
+
706
+ const balanceBefore = await colony . getFundingPotBalance ( domain1 . fundingPotId , token . address ) ;
707
+ await colony . claimExpenditurePayout ( expenditureId , SLOT0 , token . address ) ;
708
+ const balanceAfter = await colony . getFundingPotBalance ( domain1 . fundingPotId , token . address ) ;
709
+ expect ( balanceAfter . sub ( balanceBefore ) ) . to . eq . BN ( WAD ) ;
710
+
711
+ const potBalance = await colony . getFundingPotBalance ( expenditure . fundingPotId , token . address ) ;
712
+ const potPayout = await colony . getFundingPotPayout ( expenditure . fundingPotId , token . address ) ;
713
+ expect ( potBalance ) . to . be . zero ;
714
+ expect ( potPayout ) . to . be . zero ;
715
+ } ) ;
716
+
688
717
it ( "if skill is set, should emit two reputation updates" , async ( ) => {
689
718
await colony . setExpenditureRecipient ( expenditureId , SLOT0 , RECIPIENT , { from : ADMIN } ) ;
690
719
await colony . setExpenditurePayout ( expenditureId , SLOT0 , token . address , WAD , { from : ADMIN } ) ;
0 commit comments