2121
2222use super :: * ;
2323
24- use frame_benchmarking:: { account, benchmarks_instance_pallet, whitelisted_caller} ;
24+ use frame_benchmarking:: { account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError } ;
2525use frame_system:: RawOrigin ;
2626use sp_runtime:: traits:: Bounded ;
2727
@@ -31,13 +31,14 @@ use pallet_treasury::Pallet as Treasury;
3131const SEED : u32 = 0 ;
3232
3333// Create bounties that are approved for use in `on_initialize`.
34- fn create_approved_bounties < T : Config < I > , I : ' static > ( n : u32 ) -> Result < ( ) , & ' static str > {
34+ fn create_approved_bounties < T : Config < I > , I : ' static > ( n : u32 ) -> Result < ( ) , BenchmarkError > {
3535 for i in 0 ..n {
3636 let ( caller, _curator, _fee, value, reason) =
3737 setup_bounty :: < T , I > ( i, T :: MaximumReasonLength :: get ( ) ) ;
3838 Bounties :: < T , I > :: propose_bounty ( RawOrigin :: Signed ( caller) . into ( ) , value, reason) ?;
3939 let bounty_id = BountyCount :: < T , I > :: get ( ) - 1 ;
40- let approve_origin = T :: ApproveOrigin :: successful_origin ( ) ;
40+ let approve_origin =
41+ T :: SpendOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ?;
4142 Bounties :: < T , I > :: approve_bounty ( approve_origin, bounty_id) ?;
4243 }
4344 ensure ! ( BountyApprovals :: <T , I >:: get( ) . len( ) == n as usize , "Not all bounty approved" ) ;
@@ -62,13 +63,14 @@ fn setup_bounty<T: Config<I>, I: 'static>(
6263}
6364
6465fn create_bounty < T : Config < I > , I : ' static > (
65- ) -> Result < ( AccountIdLookupOf < T > , BountyIndex ) , & ' static str > {
66+ ) -> Result < ( AccountIdLookupOf < T > , BountyIndex ) , BenchmarkError > {
6667 let ( caller, curator, fee, value, reason) =
6768 setup_bounty :: < T , I > ( 0 , T :: MaximumReasonLength :: get ( ) ) ;
6869 let curator_lookup = T :: Lookup :: unlookup ( curator. clone ( ) ) ;
6970 Bounties :: < T , I > :: propose_bounty ( RawOrigin :: Signed ( caller) . into ( ) , value, reason) ?;
7071 let bounty_id = BountyCount :: < T , I > :: get ( ) - 1 ;
71- let approve_origin = T :: ApproveOrigin :: successful_origin ( ) ;
72+ let approve_origin =
73+ T :: SpendOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ?;
7274 Bounties :: < T , I > :: approve_bounty ( approve_origin. clone ( ) , bounty_id) ?;
7375 Treasury :: < T , I > :: on_initialize ( T :: BlockNumber :: zero ( ) ) ;
7476 Bounties :: < T , I > :: propose_curator ( approve_origin, bounty_id, curator_lookup. clone ( ) , fee) ?;
@@ -97,7 +99,7 @@ benchmarks_instance_pallet! {
9799 let ( caller, curator, fee, value, reason) = setup_bounty:: <T , I >( 0 , T :: MaximumReasonLength :: get( ) ) ;
98100 Bounties :: <T , I >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
99101 let bounty_id = BountyCount :: <T , I >:: get( ) - 1 ;
100- let approve_origin = T :: SpendOrigin :: successful_origin ( ) ;
102+ let approve_origin = T :: SpendOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ? ;
101103 } : _<T :: RuntimeOrigin >( approve_origin, bounty_id)
102104
103105 propose_curator {
@@ -106,10 +108,9 @@ benchmarks_instance_pallet! {
106108 let curator_lookup = T :: Lookup :: unlookup( curator) ;
107109 Bounties :: <T , I >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
108110 let bounty_id = BountyCount :: <T , I >:: get( ) - 1 ;
109- let approve_origin = T :: SpendOrigin :: successful_origin ( ) ;
110- Bounties :: <T , I >:: approve_bounty( approve_origin, bounty_id) ?;
111+ let approve_origin = T :: SpendOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ? ;
112+ Bounties :: <T , I >:: approve_bounty( approve_origin. clone ( ) , bounty_id) ?;
111113 Treasury :: <T , I >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
112- let approve_origin = T :: SpendOrigin :: successful_origin( ) ;
113114 } : _<T :: RuntimeOrigin >( approve_origin, bounty_id, curator_lookup, fee)
114115
115116 // Worst case when curator is inactive and any sender unassigns the curator.
@@ -128,7 +129,7 @@ benchmarks_instance_pallet! {
128129 let curator_lookup = T :: Lookup :: unlookup( curator. clone( ) ) ;
129130 Bounties :: <T , I >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
130131 let bounty_id = BountyCount :: <T , I >:: get( ) - 1 ;
131- let approve_origin = T :: SpendOrigin :: successful_origin ( ) ;
132+ let approve_origin = T :: SpendOrigin :: try_successful_origin ( ) . map_err ( |_| BenchmarkError :: Weightless ) ? ;
132133 Bounties :: <T , I >:: approve_bounty( approve_origin. clone( ) , bounty_id) ?;
133134 Treasury :: <T , I >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
134135 Bounties :: <T , I >:: propose_curator( approve_origin, bounty_id, curator_lookup, fee) ?;
0 commit comments