@@ -327,6 +327,13 @@ describe("Marketplace", function () {
327327 } )
328328 } )
329329
330+ it ( "updates the slot's current collateral" , async function ( ) {
331+ await marketplace . reserveSlot ( slot . request , slot . index )
332+ await marketplace . fillSlot ( slot . request , slot . index , proof )
333+ const collateral = await marketplace . currentCollateral ( slotId ( slot ) )
334+ expect ( collateral ) . to . equal ( collateralPerSlot ( request ) )
335+ } )
336+
330337 it ( "fails to retrieve a request of an empty slot" , async function ( ) {
331338 expect ( marketplace . getActiveSlot ( slotId ( slot ) ) ) . to . be . revertedWith (
332339 "Marketplace_SlotIsFree"
@@ -583,6 +590,12 @@ describe("Marketplace", function () {
583590 await token . approve ( marketplace . address , collateral )
584591 await marketplace . fillSlot ( slot . request , slot . index , proof )
585592 } )
593+
594+ it ( "updates the slot's current collateral" , async function ( ) {
595+ await waitUntilStarted ( marketplace , request , proof , token )
596+ await marketplace . freeSlot ( id )
597+ expect ( await marketplace . currentCollateral ( id ) ) . to . equal ( 0 )
598+ } )
586599 } )
587600
588601 describe ( "paying out a slot" , function ( ) {
@@ -637,6 +650,21 @@ describe("Marketplace", function () {
637650 expect ( endBalance - startBalance ) . to . be . equal ( expectedPartialPayout )
638651 } )
639652
653+ it ( "updates the collateral when freeing a finished slot" , async function ( ) {
654+ await waitUntilStarted ( marketplace , request , proof , token )
655+ await waitUntilFinished ( marketplace , requestId ( request ) )
656+ await marketplace . freeSlot ( slotId ( slot ) )
657+ expect ( await marketplace . currentCollateral ( slotId ( slot ) ) ) . to . equal ( 0 )
658+ } )
659+
660+ it ( "updates the collateral when freeing a cancelled slot" , async function ( ) {
661+ await marketplace . reserveSlot ( slot . request , slot . index )
662+ await marketplace . fillSlot ( slot . request , slot . index , proof )
663+ await waitUntilCancelled ( marketplace , request )
664+ await marketplace . freeSlot ( slotId ( slot ) )
665+ expect ( await marketplace . currentCollateral ( slotId ( slot ) ) ) . to . equal ( 0 )
666+ } )
667+
640668 it ( "does not pay when the contract hasn't ended" , async function ( ) {
641669 await marketplace . reserveSlot ( slot . request , slot . index )
642670 await marketplace . fillSlot ( slot . request , slot . index , proof )
@@ -1191,7 +1219,13 @@ describe("Marketplace", function () {
11911219 await marketplace . markProofAsMissing ( id , missedPeriod )
11921220 const endBalance = await marketplace . getSlotBalance ( id )
11931221 expect ( endBalance ) . to . equal ( startBalance - slashAmount )
1222+ } )
11941223
1224+ it ( "updates the slot's current collateral" , async function ( ) {
1225+ await setNextBlockTimestamp ( await currentTime ( ) )
1226+ await marketplace . markProofAsMissing ( id , missedPeriod )
1227+ const currentCollateral = await marketplace . currentCollateral ( id )
1228+ expect ( currentCollateral ) . to . equal ( collateral - slashAmount )
11951229 } )
11961230
11971231 it ( "rewards validator when marking proof as missing" , async function ( ) {
@@ -1234,6 +1268,11 @@ describe("Marketplace", function () {
12341268 expect ( await marketplace . getSlotBalance ( slotId ( slot ) ) ) . to . equal ( 0 )
12351269 } )
12361270
1271+ it ( "updates the slot's current collateral" , async function ( ) {
1272+ const collateral = await marketplace . currentCollateral ( slotId ( slot ) )
1273+ expect ( collateral ) . to . equal ( 0 )
1274+ } )
1275+
12371276 it ( "resets missed proof counter" , async function ( ) {
12381277 expect ( await marketplace . missingProofs ( slotId ( slot ) ) ) . to . equal ( 0 )
12391278 } )
0 commit comments