1515// See the License for the specific language governing permissions and
1616// limitations under the License.
1717
18- //! bounties pallet benchmarking.
19-
20- #![ cfg( feature = "runtime-benchmarks" ) ]
18+ //! Bounties pallet benchmarking.
2119
2220use super :: * ;
2321
@@ -37,6 +35,16 @@ fn set_block_number<T: Config<I>, I: 'static>(n: BlockNumberFor<T>) {
3735 <T as pallet_treasury:: Config < I > >:: BlockNumberProvider :: set_block_number ( n) ;
3836}
3937
38+ fn minimum_balance < T : Config < I > , I : ' static > ( ) -> BalanceOf < T , I > {
39+ let minimum_balance = T :: Currency :: minimum_balance ( ) ;
40+
41+ if minimum_balance. is_zero ( ) {
42+ 1u32 . into ( )
43+ } else {
44+ minimum_balance
45+ }
46+ }
47+
4048// Create bounties that are approved for use in `on_initialize`.
4149fn create_approved_bounties < T : Config < I > , I : ' static > ( n : u32 ) -> Result < ( ) , BenchmarkError > {
4250 for i in 0 ..n {
@@ -62,12 +70,10 @@ fn setup_bounty<T: Config<I>, I: 'static>(
6270 let fee = value / 2u32 . into ( ) ;
6371 let deposit = T :: BountyDepositBase :: get ( ) +
6472 T :: DataDepositPerByte :: get ( ) * T :: MaximumReasonLength :: get ( ) . into ( ) ;
65- let _ = T :: Currency :: make_free_balance_be ( & caller, deposit + T :: Currency :: minimum_balance ( ) ) ;
73+ let _ = T :: Currency :: make_free_balance_be ( & caller, deposit + minimum_balance :: < T , I > ( ) ) ;
6674 let curator = account ( "curator" , u, SEED ) ;
67- let _ = T :: Currency :: make_free_balance_be (
68- & curator,
69- fee / 2u32 . into ( ) + T :: Currency :: minimum_balance ( ) ,
70- ) ;
75+ let _ =
76+ T :: Currency :: make_free_balance_be ( & curator, fee / 2u32 . into ( ) + minimum_balance :: < T , I > ( ) ) ;
7177 let reason = vec ! [ 0 ; d as usize ] ;
7278 ( caller, curator, fee, value, reason)
7379}
@@ -91,7 +97,7 @@ fn create_bounty<T: Config<I>, I: 'static>(
9197
9298fn setup_pot_account < T : Config < I > , I : ' static > ( ) {
9399 let pot_account = Bounties :: < T , I > :: account_id ( ) ;
94- let value = T :: Currency :: minimum_balance ( ) . saturating_mul ( 1_000_000_000u32 . into ( ) ) ;
100+ let value = minimum_balance :: < T , I > ( ) . saturating_mul ( 1_000_000_000u32 . into ( ) ) ;
95101 let _ = T :: Currency :: make_free_balance_be ( & pot_account, value) ;
96102}
97103
0 commit comments