@@ -326,6 +326,13 @@ describe("Marketplace", function () {
326326 } )
327327 } )
328328
329+ it ( "updates the slot's current collateral" , async function ( ) {
330+ await marketplace . reserveSlot ( slot . request , slot . index )
331+ await marketplace . fillSlot ( slot . request , slot . index , proof )
332+ const collateral = await marketplace . currentCollateral ( slotId ( slot ) )
333+ expect ( collateral ) . to . equal ( collateralPerSlot ( request ) )
334+ } )
335+
329336 it ( "fails to retrieve a request of an empty slot" , async function ( ) {
330337 expect ( marketplace . getActiveSlot ( slotId ( slot ) ) ) . to . be . revertedWith (
331338 "Marketplace_SlotIsFree"
@@ -549,6 +556,12 @@ describe("Marketplace", function () {
549556 . to . emit ( marketplace , "SlotFreed" )
550557 . withArgs ( slot . request , slot . index )
551558 } )
559+
560+ it ( "updates the slot's current collateral" , async function ( ) {
561+ await waitUntilStarted ( marketplace , request , proof , token )
562+ await marketplace . freeSlot ( id )
563+ expect ( await marketplace . currentCollateral ( id ) ) . to . equal ( 0 )
564+ } )
552565 } )
553566
554567 describe ( "paying out a slot" , function ( ) {
@@ -603,6 +616,21 @@ describe("Marketplace", function () {
603616 expect ( endBalance - startBalance ) . to . be . equal ( expectedPartialPayout )
604617 } )
605618
619+ it ( "updates the collateral when freeing a finished slot" , async function ( ) {
620+ await waitUntilStarted ( marketplace , request , proof , token )
621+ await waitUntilFinished ( marketplace , requestId ( request ) )
622+ await marketplace . freeSlot ( slotId ( slot ) )
623+ expect ( await marketplace . currentCollateral ( slotId ( slot ) ) ) . to . equal ( 0 )
624+ } )
625+
626+ it ( "updates the collateral when freeing a cancelled slot" , async function ( ) {
627+ await marketplace . reserveSlot ( slot . request , slot . index )
628+ await marketplace . fillSlot ( slot . request , slot . index , proof )
629+ await waitUntilCancelled ( marketplace , request )
630+ await marketplace . freeSlot ( slotId ( slot ) )
631+ expect ( await marketplace . currentCollateral ( slotId ( slot ) ) ) . to . equal ( 0 )
632+ } )
633+
606634 it ( "does not pay when the contract hasn't ended" , async function ( ) {
607635 await marketplace . reserveSlot ( slot . request , slot . index )
608636 await marketplace . fillSlot ( slot . request , slot . index , proof )
@@ -1157,7 +1185,13 @@ describe("Marketplace", function () {
11571185 await marketplace . markProofAsMissing ( id , missedPeriod )
11581186 const endBalance = await marketplace . getSlotBalance ( id )
11591187 expect ( endBalance ) . to . equal ( startBalance - slashAmount )
1188+ } )
11601189
1190+ it ( "updates the slot's current collateral" , async function ( ) {
1191+ await setNextBlockTimestamp ( await currentTime ( ) )
1192+ await marketplace . markProofAsMissing ( id , missedPeriod )
1193+ const currentCollateral = await marketplace . currentCollateral ( id )
1194+ expect ( currentCollateral ) . to . equal ( collateral - slashAmount )
11611195 } )
11621196
11631197 it ( "rewards validator when marking proof as missing" , async function ( ) {
@@ -1200,6 +1234,11 @@ describe("Marketplace", function () {
12001234 expect ( await marketplace . getSlotBalance ( slotId ( slot ) ) ) . to . equal ( 0 )
12011235 } )
12021236
1237+ it ( "updates the slot's current collateral" , async function ( ) {
1238+ const collateral = await marketplace . currentCollateral ( slotId ( slot ) )
1239+ expect ( collateral ) . to . equal ( 0 )
1240+ } )
1241+
12031242 it ( "resets missed proof counter" , async function ( ) {
12041243 expect ( await marketplace . missingProofs ( slotId ( slot ) ) ) . to . equal ( 0 )
12051244 } )
0 commit comments