@@ -267,7 +267,8 @@ mod benchmarks {
267
267
Ok ( ( ) )
268
268
}
269
269
270
- // Worst case when curator is inactive and any sender un-assigns the curator.
270
+ // Worst case when curator is inactive and any sender un-assigns the curator,
271
+ // or if `BountyUpdatePeriod` is large enough and `RejectOrigin` executes the call.
271
272
#[ benchmark]
272
273
fn unassign_curator ( ) -> Result < ( ) , BenchmarkError > {
273
274
setup_pot_account :: < T > ( ) ;
@@ -276,24 +277,21 @@ mod benchmarks {
276
277
let bounty_update_period = T :: BountyUpdatePeriod :: get ( ) ;
277
278
let inactivity_timeout = T :: SpendPeriod :: get ( ) . saturating_add ( bounty_update_period) ;
278
279
set_block_number :: < T > ( inactivity_timeout. saturating_add ( 1u32 . into ( ) ) ) ;
279
- let caller: T :: AccountId = whitelisted_caller ( ) ;
280
-
281
- #[ block]
282
- {
283
- let res = Pallet :: < T > :: unassign_curator (
284
- RawOrigin :: Signed ( caller) . into ( ) ,
285
- bounty_setup. bounty_id ,
286
- bounty_setup. child_bounty_id ,
287
- ) ;
288
-
289
- // If `BountyUpdatePeriod` overflowed the inactivity timeout, the call will fail (which
290
- // is fine) but we need to handle it.
291
- if Pallet :: < T > :: treasury_block_number ( ) <= inactivity_timeout {
292
- assert ! ( res. is_err( ) ) ;
293
- } else {
294
- assert_ok ! ( res) ;
295
- }
296
- }
280
+
281
+ // If `BountyUpdatePeriod` overflows the inactivity timeout the benchmark still executes the slash
282
+ let origin = if Pallet :: < T > :: treasury_block_number ( ) <= inactivity_timeout {
283
+ T :: RejectOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ?
284
+ } else {
285
+ let caller: T :: AccountId = whitelisted_caller ( ) ;
286
+ RawOrigin :: Signed ( caller. clone ( ) ) . into ( )
287
+ } ;
288
+
289
+ #[ extrinsic_call]
290
+ _ (
291
+ origin as T :: RuntimeOrigin ,
292
+ bounty_setup. bounty_id ,
293
+ bounty_setup. child_bounty_id ,
294
+ ) ;
297
295
298
296
Ok ( ( ) )
299
297
}
0 commit comments