2222use super :: * ;
2323
2424use frame_benchmarking:: { account, benchmarks, impl_benchmark_test_suite, whitelisted_caller} ;
25- use frame_support:: traits:: OnInitialize ;
2625use frame_system:: RawOrigin ;
2726use sp_runtime:: traits:: Bounded ;
2827
29- use crate :: Module as Bounties ;
28+ use crate :: Pallet as Bounties ;
3029use pallet_treasury:: Pallet as Treasury ;
3130
3231const SEED : u32 = 0 ;
@@ -36,10 +35,10 @@ fn create_approved_bounties<T: Config>(n: u32) -> Result<(), &'static str> {
3635 for i in 0 ..n {
3736 let ( caller, _curator, _fee, value, reason) = setup_bounty :: < T > ( i, MAX_BYTES ) ;
3837 Bounties :: < T > :: propose_bounty ( RawOrigin :: Signed ( caller) . into ( ) , value, reason) ?;
39- let bounty_id = BountyCount :: get ( ) - 1 ;
38+ let bounty_id = BountyCount :: < T > :: get ( ) - 1 ;
4039 Bounties :: < T > :: approve_bounty ( RawOrigin :: Root . into ( ) , bounty_id) ?;
4140 }
42- ensure ! ( BountyApprovals :: get( ) . len( ) == n as usize , "Not all bounty approved" ) ;
41+ ensure ! ( BountyApprovals :: < T > :: get( ) . len( ) == n as usize , "Not all bounty approved" ) ;
4342 Ok ( ( ) )
4443}
4544
@@ -64,7 +63,7 @@ fn create_bounty<T: Config>(
6463 let ( caller, curator, fee, value, reason) = setup_bounty :: < T > ( 0 , MAX_BYTES ) ;
6564 let curator_lookup = T :: Lookup :: unlookup ( curator. clone ( ) ) ;
6665 Bounties :: < T > :: propose_bounty ( RawOrigin :: Signed ( caller) . into ( ) , value, reason) ?;
67- let bounty_id = BountyCount :: get ( ) - 1 ;
66+ let bounty_id = BountyCount :: < T > :: get ( ) - 1 ;
6867 Bounties :: < T > :: approve_bounty ( RawOrigin :: Root . into ( ) , bounty_id) ?;
6968 Treasury :: < T > :: on_initialize ( T :: BlockNumber :: zero ( ) ) ;
7069 Bounties :: < T > :: propose_curator ( RawOrigin :: Root . into ( ) , bounty_id, curator_lookup. clone ( ) , fee) ?;
@@ -94,15 +93,15 @@ benchmarks! {
9493 approve_bounty {
9594 let ( caller, curator, fee, value, reason) = setup_bounty:: <T >( 0 , MAX_BYTES ) ;
9695 Bounties :: <T >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
97- let bounty_id = BountyCount :: get( ) - 1 ;
96+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
9897 } : _( RawOrigin :: Root , bounty_id)
9998
10099 propose_curator {
101100 setup_pot_account:: <T >( ) ;
102101 let ( caller, curator, fee, value, reason) = setup_bounty:: <T >( 0 , MAX_BYTES ) ;
103102 let curator_lookup = T :: Lookup :: unlookup( curator. clone( ) ) ;
104103 Bounties :: <T >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
105- let bounty_id = BountyCount :: get( ) - 1 ;
104+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
106105 Bounties :: <T >:: approve_bounty( RawOrigin :: Root . into( ) , bounty_id) ?;
107106 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
108107 } : _( RawOrigin :: Root , bounty_id, curator_lookup, fee)
@@ -112,7 +111,7 @@ benchmarks! {
112111 setup_pot_account:: <T >( ) ;
113112 let ( curator_lookup, bounty_id) = create_bounty:: <T >( ) ?;
114113 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
115- let bounty_id = BountyCount :: get( ) - 1 ;
114+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
116115 frame_system:: Pallet :: <T >:: set_block_number( T :: BountyUpdatePeriod :: get( ) + 1u32 . into( ) ) ;
117116 let caller = whitelisted_caller( ) ;
118117 } : _( RawOrigin :: Signed ( caller) , bounty_id)
@@ -122,7 +121,7 @@ benchmarks! {
122121 let ( caller, curator, fee, value, reason) = setup_bounty:: <T >( 0 , MAX_BYTES ) ;
123122 let curator_lookup = T :: Lookup :: unlookup( curator. clone( ) ) ;
124123 Bounties :: <T >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
125- let bounty_id = BountyCount :: get( ) - 1 ;
124+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
126125 Bounties :: <T >:: approve_bounty( RawOrigin :: Root . into( ) , bounty_id) ?;
127126 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
128127 Bounties :: <T >:: propose_curator( RawOrigin :: Root . into( ) , bounty_id, curator_lookup, fee) ?;
@@ -133,7 +132,7 @@ benchmarks! {
133132 let ( curator_lookup, bounty_id) = create_bounty:: <T >( ) ?;
134133 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
135134
136- let bounty_id = BountyCount :: get( ) - 1 ;
135+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
137136 let curator = T :: Lookup :: lookup( curator_lookup) . map_err( <& str >:: from) ?;
138137
139138 let beneficiary = T :: Lookup :: unlookup( account( "beneficiary" , 0 , SEED ) ) ;
@@ -144,10 +143,9 @@ benchmarks! {
144143 let ( curator_lookup, bounty_id) = create_bounty:: <T >( ) ?;
145144 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
146145
147- let bounty_id = BountyCount :: get( ) - 1 ;
146+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
148147 let curator = T :: Lookup :: lookup( curator_lookup) . map_err( <& str >:: from) ?;
149148
150-
151149 let beneficiary_account: T :: AccountId = account( "beneficiary" , 0 , SEED ) ;
152150 let beneficiary = T :: Lookup :: unlookup( beneficiary_account. clone( ) ) ;
153151 Bounties :: <T >:: award_bounty( RawOrigin :: Signed ( curator. clone( ) ) . into( ) , bounty_id, beneficiary) ?;
@@ -164,29 +162,29 @@ benchmarks! {
164162 setup_pot_account:: <T >( ) ;
165163 let ( caller, curator, fee, value, reason) = setup_bounty:: <T >( 0 , 0 ) ;
166164 Bounties :: <T >:: propose_bounty( RawOrigin :: Signed ( caller) . into( ) , value, reason) ?;
167- let bounty_id = BountyCount :: get( ) - 1 ;
165+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
168166 } : close_bounty( RawOrigin :: Root , bounty_id)
169167
170168 close_bounty_active {
171169 setup_pot_account:: <T >( ) ;
172170 let ( curator_lookup, bounty_id) = create_bounty:: <T >( ) ?;
173171 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
174- let bounty_id = BountyCount :: get( ) - 1 ;
172+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
175173 } : close_bounty( RawOrigin :: Root , bounty_id)
176174 verify {
177- assert_last_event:: <T >( RawEvent :: BountyCanceled ( bounty_id) . into( ) )
175+ assert_last_event:: <T >( Event :: BountyCanceled ( bounty_id) . into( ) )
178176 }
179177
180178 extend_bounty_expiry {
181179 setup_pot_account:: <T >( ) ;
182180 let ( curator_lookup, bounty_id) = create_bounty:: <T >( ) ?;
183181 Bounties :: <T >:: on_initialize( T :: BlockNumber :: zero( ) ) ;
184182
185- let bounty_id = BountyCount :: get( ) - 1 ;
183+ let bounty_id = BountyCount :: < T > :: get( ) - 1 ;
186184 let curator = T :: Lookup :: lookup( curator_lookup) . map_err( <& str >:: from) ?;
187185 } : _( RawOrigin :: Signed ( curator) , bounty_id, Vec :: new( ) )
188186 verify {
189- assert_last_event:: <T >( RawEvent :: BountyExtended ( bounty_id) . into( ) )
187+ assert_last_event:: <T >( Event :: BountyExtended ( bounty_id) . into( ) )
190188 }
191189
192190 spend_funds {
@@ -209,7 +207,7 @@ benchmarks! {
209207 verify {
210208 ensure!( budget_remaining < BalanceOf :: <T >:: max_value( ) , "Budget not used" ) ;
211209 ensure!( missed_any == false , "Missed some" ) ;
212- assert_last_event:: <T >( RawEvent :: BountyBecameActive ( b - 1 ) . into( ) )
210+ assert_last_event:: <T >( Event :: BountyBecameActive ( b - 1 ) . into( ) )
213211 }
214212}
215213
0 commit comments