File tree 4 files changed +22
-3
lines changed
4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
[workspace ]
2
2
members = [
3
3
" programs/*" ,
4
- " modules/*"
4
+ " modules/*" ,
5
5
]
6
6
resolver = " 2"
7
7
Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " ntt-fuzz"
3
3
version = " 0.0.1"
4
+ edition = " 2021"
4
5
5
6
[[bin ]]
6
- name = " ntt- fuzz"
7
+ name = " fuzz-trimmed-amount "
7
8
path = " fuzz_trimmed_amount.rs"
9
+ [[bin ]]
10
+ name = " fuzz-rate-limit-state"
11
+ path = " fuzz_rate_limit.rs"
8
12
9
- edition = " 2021"
10
13
[dependencies ]
11
14
ntt-messages = { path = " ../../modules/ntt-messages" }
15
+ example-native-token-transfers = { path = " ../../programs/example-native-token-transfers" }
12
16
honggfuzz = " 0.5"
13
17
arbitrary = { version = " 1" , optional = true , features = [" derive" ] }
14
18
Original file line number Diff line number Diff line change
1
+ use honggfuzz:: fuzz;
2
+ use example_native_token_transfers:: queue:: rate_limit:: RateLimitState ;
3
+
4
+ fn main ( ) {
5
+ loop {
6
+ fuzz ! ( |input: ( u64 , u64 ) | {
7
+ let ( limit, new_limit) = input;
8
+
9
+ let mut rls = RateLimitState :: new( limit) ;
10
+ rls. set_limit( new_limit)
11
+ } ) ;
12
+ }
13
+ }
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ impl TrimmedAmount {
61
61
return Ok ( amount) ;
62
62
}
63
63
if from_decimals > to_decimals {
64
+ // [`u64::checked_pow`] expects a u32 argument
64
65
let power: u32 = ( from_decimals - to_decimals) . into ( ) ;
65
66
// Exponentiation will overflow u64 when `power` is greater than 18
66
67
let scaling_factor: u64 = 10u64
@@ -69,6 +70,7 @@ impl TrimmedAmount {
69
70
70
71
Ok ( amount / scaling_factor)
71
72
} else {
73
+ // [`u64::checked_pow`] expects a u32 argument
72
74
let power: u32 = ( to_decimals - from_decimals) . into ( ) ;
73
75
74
76
// Exponentiation will overflow u64 when `power` is greater than 18
You can’t perform that action at this time.
0 commit comments