@@ -19,12 +19,12 @@ pub mod currency {
19
19
use primitives:: Balance ;
20
20
21
21
pub const DOTS : Balance = 1_000_000_000_000 ;
22
- pub const DOLLARS : Balance = DOTS ;
22
+ pub const DOLLARS : Balance = DOTS / 6 ;
23
23
pub const CENTS : Balance = DOLLARS / 100 ;
24
24
pub const MILLICENTS : Balance = CENTS / 1_000 ;
25
25
26
26
pub const fn deposit ( items : u32 , bytes : u32 ) -> Balance {
27
- items as Balance * 15 * CENTS + ( bytes as Balance ) * 6 * CENTS
27
+ items as Balance * 20 * DOLLARS + ( bytes as Balance ) * 100 * MILLICENTS
28
28
}
29
29
}
30
30
@@ -97,21 +97,25 @@ mod tests {
97
97
use frame_support:: weights:: WeightToFeePolynomial ;
98
98
use runtime_common:: { MaximumBlockWeight , ExtrinsicBaseWeight } ;
99
99
use super :: fee:: WeightToFee ;
100
- use super :: currency:: { CENTS , DOLLARS } ;
100
+ use super :: currency:: { CENTS , DOLLARS , MILLICENTS } ;
101
101
102
102
#[ test]
103
103
// This function tests that the fee for `MaximumBlockWeight` of weight is correct
104
104
fn full_block_fee_is_correct ( ) {
105
105
// A full block should cost 16 DOLLARS
106
106
println ! ( "Base: {}" , ExtrinsicBaseWeight :: get( ) ) ;
107
- assert_eq ! ( WeightToFee :: calc( & MaximumBlockWeight :: get( ) ) , 16 * DOLLARS )
107
+ let x = WeightToFee :: calc ( & MaximumBlockWeight :: get ( ) ) ;
108
+ let y = 16 * DOLLARS ;
109
+ assert ! ( x. max( y) - x. min( y) < MILLICENTS ) ;
108
110
}
109
111
110
112
#[ test]
111
113
// This function tests that the fee for `ExtrinsicBaseWeight` of weight is correct
112
114
fn extrinsic_base_fee_is_correct ( ) {
113
115
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
114
116
println ! ( "Base: {}" , ExtrinsicBaseWeight :: get( ) ) ;
115
- assert_eq ! ( WeightToFee :: calc( & ExtrinsicBaseWeight :: get( ) ) , CENTS / 10 )
117
+ let x = WeightToFee :: calc ( & ExtrinsicBaseWeight :: get ( ) ) ;
118
+ let y = CENTS / 10 ;
119
+ assert ! ( x. max( y) - x. min( y) < MILLICENTS ) ;
116
120
}
117
121
}
0 commit comments