Skip to content

Commit

Permalink
chore: fix fmt and make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed Aug 4, 2023
1 parent 873acdd commit 3a7e93b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions engine-modexp/src/mpnat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl MPNat {
let end = a.iter().position(|&x| x != 0).unwrap_or(len);

if end == len {
return (&[], true);
(&[], true)
} else {
return (&a[end..], false);
(&a[end..], false)
}
}

Expand Down Expand Up @@ -165,9 +165,9 @@ impl MPNat {
//
// The case of modulus being 0 should have already been
// handled in modexp().
debug_assert!( !(modulus.digits.len() == 1 && modulus.digits[0] == 0) );
debug_assert!(!(modulus.digits.len() == 1 && modulus.digits[0] == 0));
if exp_is_zero {
if modulus.digits.len() == 1 && modulus.digits[0] == 1 {
if modulus.digits.len() == 1 && modulus.digits[0] == 1 {
return Self { digits: vec![0] };
} else {
return Self { digits: vec![1] };
Expand Down Expand Up @@ -636,20 +636,14 @@ fn test_modpow_even() {
let exponent = hex::decode("").unwrap();
let modulus = hex::decode("02").unwrap();
let result = crate::modexp(&base, &exponent, &modulus);
assert_eq!(
hex::encode(result),
"01"
);
assert_eq!(hex::encode(result), "01");

// Test zero exp
let base = hex::decode("00").unwrap();
let exponent = hex::decode("00").unwrap();
let modulus = hex::decode("02").unwrap();
let result = crate::modexp(&base, &exponent, &modulus);
assert_eq!(
hex::encode(result),
"01"
);
assert_eq!(hex::encode(result), "01");

fn check_modpow_even(base: u128, exp: u128, modulus: u128, expected: u128) {
let mut x = MPNat::from_big_endian(&base.to_be_bytes());
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn repro_Emufid2() {
block_timestamp: 1_662_118_048_636_713_538,
input_path: "src/tests/res/input_Emufid2.hex",
evm_gas_used: 1_156_364,
near_gas_used: 296,
near_gas_used: 282,
});
}

Expand Down

0 comments on commit 3a7e93b

Please sign in to comment.