@@ -98,8 +98,11 @@ contract RebasingBatchShares is DevTestSetup {
9898
9999 // === 4: Free Loans === //
100100 uint256 debtB4 = borrowerOperations.getEntireSystemDebt ();
101- // We can now open a new Trove
102- uint256 anotherATroveId = openTroveAndJoinBatchManager (A, 100 ether, MIN_DEBT, B, MIN_ANNUAL_INTEREST_RATE);
101+ // We shouldn’t be able to open a new Trove now
102+ uint256 anotherATroveId = openTroveExpectRevert (A, 100 ether, MIN_DEBT, B);
103+ assertEq (anotherATroveId, 0 );
104+
105+ /*
103106 LatestTroveData memory anotherATrove = troveManager.getLatestTroveData(anotherATroveId);
104107 uint256 aDebt = anotherATrove.entireDebt;
105108
@@ -115,6 +118,7 @@ contract RebasingBatchShares is DevTestSetup {
115118
116119 assertGt(debtAfter, debtB4, "Debt should have increased");
117120 assertLt(balB4, balAfter, "Something should have benn paid");
121+ */
118122 }
119123
120124 uint128 subTractor = 1 ;
@@ -140,6 +144,7 @@ contract RebasingBatchShares is DevTestSetup {
140144 // Log ratio
141145 uint256 batchSharesRatio = batchShares * DECIMAL_PRECISION / batchDebt;
142146 console2.log ("shares / batch ratio: " , batchSharesRatio);
147+ console2.log ("Ratio too low? " , batchSharesRatio < MIN_BATCH_SHARES_RATIO);
143148
144149 // Trove
145150 /*
@@ -149,6 +154,7 @@ contract RebasingBatchShares is DevTestSetup {
149154 console2.log("Trove Shares: ", troveBatchShares);
150155 uint256 troveSharesRatio = troveBatchShares * DECIMAL_PRECISION / troveData.entireDebt;
151156 console2.log("Trove ratio: ", troveSharesRatio);
157+ console2.log("Ratio too low? ", troveSharesRatio < MIN_BATCH_SHARES_RATIO);
152158 */
153159 }
154160
@@ -198,4 +204,30 @@ contract RebasingBatchShares is DevTestSetup {
198204
199205 return allBatchDebtShares;
200206 }
207+
208+ function openTroveExpectRevert (address _troveOwner , uint256 _coll , uint256 _debt , address _batchAddress )
209+ internal
210+ returns (uint256 )
211+ {
212+ IBorrowerOperations.OpenTroveAndJoinInterestBatchManagerParams memory params = IBorrowerOperations
213+ .OpenTroveAndJoinInterestBatchManagerParams ({
214+ owner: _troveOwner,
215+ ownerIndex: 0 ,
216+ collAmount: _coll,
217+ boldAmount: _debt,
218+ upperHint: 0 ,
219+ lowerHint: 0 ,
220+ interestBatchManager: _batchAddress,
221+ maxUpfrontFee: 1e24 ,
222+ addManager: address (0 ),
223+ removeManager: address (0 ),
224+ receiver: address (0 )
225+ });
226+ vm.startPrank (_troveOwner);
227+ vm.expectRevert (TroveManager.BatchSharesRatioTooLow.selector );
228+ uint256 troveId = borrowerOperations.openTroveAndJoinInterestBatchManager (params);
229+ vm.stopPrank ();
230+
231+ return troveId;
232+ }
201233}
0 commit comments