@@ -57,7 +57,18 @@ contract("BondingManager", accounts => {
57
57
await expectThrow ( bondingManager . transcoder ( blockRewardCut , feeShare , pricePerSegment ) , { from : tAddr } )
58
58
} )
59
59
60
- it ( "should fail with zero delegated amount" , async ( ) => {
60
+ it ( "should fail if transcoder is not bonded to self" , async ( ) => {
61
+ await fixture . token . setApproved ( true )
62
+ await bondingManager . bond ( 2000 , tAddr , { from : accounts [ 2 ] } )
63
+
64
+ // Fails because transcoder has non zero delegated stake but is not bonded to self
65
+ await expectThrow ( bondingManager . transcoder ( blockRewardCut , feeShare , pricePerSegment ) , { from : tAddr } )
66
+ } )
67
+
68
+ it ( "should fail if transcoder does not have a non-zero amount bonded to self" , async ( ) => {
69
+ await bondingManager . bond ( 0 , tAddr , { from : tAddr } )
70
+
71
+ // Fails because transcoder is delegated to self but has zero bonded stake
61
72
await expectThrow ( bondingManager . transcoder ( blockRewardCut , feeShare , pricePerSegment ) , { from : tAddr } )
62
73
} )
63
74
@@ -105,38 +116,6 @@ contract("BondingManager", accounts => {
105
116
} )
106
117
} )
107
118
108
- describe ( "resignAsTranscoder" , ( ) => {
109
- const tAddr = accounts [ 1 ]
110
-
111
- beforeEach ( async ( ) => {
112
- const blockRewardCut = 10 * PERC_MULTIPLIER
113
- const feeShare = 5 * PERC_MULTIPLIER
114
- const pricePerSegment = 100
115
-
116
- await bondingManager . setParameters ( UNBONDING_PERIOD , NUM_TRANSCODERS , NUM_ACTIVE_TRANSCODERS )
117
-
118
- await fixture . roundsManager . setCurrentRoundInitialized ( true )
119
- await fixture . token . setApproved ( true )
120
- await bondingManager . bond ( 2000 , tAddr , { from : tAddr } )
121
- await bondingManager . transcoder ( blockRewardCut , feeShare , pricePerSegment , { from : tAddr } )
122
- } )
123
-
124
- it ( "should throw if transcoder is not registered" , async ( ) => {
125
- await expectThrow ( bondingManager . resignAsTranscoder ( { from : accounts [ 2 ] } ) )
126
- } )
127
-
128
- it ( "should remove the transcoder from the transcoder pools" , async ( ) => {
129
- await bondingManager . resignAsTranscoder ( { from : tAddr } )
130
- assert . equal ( await bondingManager . transcoderStatus ( tAddr ) , 0 , "transcoder not removed from pool" )
131
- } )
132
-
133
- it ( "should set a transcoder as not registered" , async ( ) => {
134
- await bondingManager . resignAsTranscoder ( { from : tAddr } )
135
- const transcoderStatus = await bondingManager . transcoderStatus ( tAddr )
136
- assert . equal ( transcoderStatus , 0 , "transcoder is not not registered" )
137
- } )
138
- } )
139
-
140
119
describe ( "bond" , ( ) => {
141
120
const tAddr0 = accounts [ 1 ]
142
121
const tAddr1 = accounts [ 2 ]
@@ -599,10 +578,10 @@ contract("BondingManager", accounts => {
599
578
// Delegator bonds to transcoder
600
579
await bondingManager . bond ( 2000 , tAddr , { from : dAddr } )
601
580
602
- // Set active transcoders
603
- await fixture . roundsManager . initializeRound ( )
604
581
// Set current round so delegator is bonded
605
582
await fixture . roundsManager . setCurrentRound ( currentRound )
583
+ // Set active transcoders
584
+ await fixture . roundsManager . initializeRound ( )
606
585
} )
607
586
608
587
it ( "should set withdraw round to current block + unbonding period" , async ( ) => {
@@ -642,6 +621,20 @@ contract("BondingManager", accounts => {
642
621
643
622
assert . equal ( startDelegatedAmount . sub ( endDelegatedAmount ) , 2000 , "delegate's delegated amount did not decrease by bonded amount" )
644
623
} )
624
+
625
+ it ( "should resign transcoder if caller is a registered transcoder" , async ( ) => {
626
+ await bondingManager . unbond ( { from : tAddr } )
627
+
628
+ assert . equal ( await bondingManager . transcoderStatus ( tAddr ) , 0 , "transcoder not removed from pool" )
629
+ } )
630
+
631
+ it ( "should set transcoder as inactive for the current round if caller is a registered transcoder" , async ( ) => {
632
+ assert . isOk ( await bondingManager . isActiveTranscoder ( tAddr , currentRound ) , "transcoder should be active" )
633
+
634
+ await bondingManager . unbond ( { from : tAddr } )
635
+
636
+ assert . isNotOk ( await bondingManager . isActiveTranscoder ( tAddr , currentRound ) , "transcoder should be inactive" )
637
+ } )
645
638
} )
646
639
647
640
describe ( "withdrawStake" , ( ) => {
0 commit comments