Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
more clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihChengLiang committed Feb 15, 2024
1 parent f3a97cc commit 150c75c
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 152 deletions.
6 changes: 5 additions & 1 deletion eth-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#![deny(missing_docs)]
//#![deny(unsafe_code)] Allowed now until we find a
// better way to handle downcasting from Operation into it's variants.
#![allow(clippy::upper_case_acronyms)] // Too pedantic

// Too pedantic
#![allow(clippy::upper_case_acronyms)]
// Clippy is buggy on this one. Remove after https://github.com/rust-lang/rust-clippy/issues/12101 is resolved.
#![allow(clippy::useless_vec)]

#[macro_use]
pub mod macros;
Expand Down
11 changes: 7 additions & 4 deletions testool/src/statetest/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ impl<'a> YamlStateTestBuilder<'a> {

#[cfg(test)]
mod test {
use std::fmt::Display;

use super::*;
use crate::{
config::TestSuite,
Expand Down Expand Up @@ -524,9 +526,9 @@ arith:
}
}
}
impl ToString for Template {
fn to_string(&self) -> String {
TEMPLATE
impl Display for Template {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = TEMPLATE
.replace("{{ gas_limit }}", &self.gas_limit)
.replace("{{ pre_code }}", &self.pre_code)
.replace("{{ res_storage }}", &self.res_storage)
Expand All @@ -540,7 +542,8 @@ arith:
} else {
"Istanbul"
},
)
);
f.write_str(&str)
}
}

Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/execution/signextend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ mod test {
let pos_extend = 0u8;
let neg_extend = 0xFFu8;

for (value, byte_extend) in vec![(pos_value, pos_extend), (neg_value, neg_extend)].iter() {
for (value, byte_extend) in [(pos_value, pos_extend), (neg_value, neg_extend)].iter() {
for idx in 0..33 {
test_ok(
(idx as u64).into(),
Expand Down
12 changes: 6 additions & 6 deletions zkevm-circuits/src/evm_circuit/util/math_gadget/add_words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,27 @@ mod tests {

#[test]
fn test_addwords_0_0() {
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, vec![Word::from(0), Word::from(0), Word::from(0)], true);
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, [Word::from(0), Word::from(0), Word::from(0)], true);
}

#[test]
fn test_addwords_1_1() {
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, vec![Word::from(1), Word::from(1), Word::from(2)], true);
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, [Word::from(1), Word::from(1), Word::from(2)], true);
}

#[test]
fn test_addwords_1000_1000() {
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, vec![Word::from(1000), Word::from(1000), Word::from(2000)], true);
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, [Word::from(1000), Word::from(1000), Word::from(2000)], true);
}

#[test]
fn test_addwords_to_wordmax() {
try_test!(AddWordsTestContainer<Fr, 2,0u64, true>, vec![Word::MAX - 1, Word::from(1), Word::MAX], true);
try_test!(AddWordsTestContainer<Fr, 2,0u64, true>, [Word::MAX - 1, Word::from(1), Word::MAX], true);
}

#[test]
fn test_addwords_high_low_max() {
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, vec![WORD_LOW_MAX, WORD_HIGH_MAX, Word::MAX], true);
try_test!(AddWordsTestContainer<Fr, 2, 0u64, true>, [WORD_LOW_MAX, WORD_HIGH_MAX, Word::MAX], true);
}

#[test]
Expand Down Expand Up @@ -291,7 +291,7 @@ mod tests {
let sum_7_low_max = U256([0xfffffffffffffff9u64, 0xffffffffffffffffu64, CARRY_HI, 0u64]);
try_test!(
AddWordsTestContainer<Fr,7, 0u64, true>,
vec![
[
WORD_LOW_MAX,
WORD_LOW_MAX,
WORD_LOW_MAX,
Expand Down
10 changes: 5 additions & 5 deletions zkevm-circuits/src/evm_circuit/util/math_gadget/byte_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,32 @@ mod tests {

#[test]
fn test_bytesize_0() {
try_test!(ByteSizeGadgetContainer<Fr, 0>, vec![Word::from(0)], true)
try_test!(ByteSizeGadgetContainer<Fr, 0>, [Word::from(0)], true)
}

#[test]
fn test_bytesize_1() {
try_test!(ByteSizeGadgetContainer<Fr, 1>, vec![Word::from(1)], true)
try_test!(ByteSizeGadgetContainer<Fr, 1>, [Word::from(1)], true)
}

#[test]
fn test_bytesize_1_neq_0() {
try_test!(ByteSizeGadgetContainer<Fr, 0>,
vec![Word::from(1)],
[Word::from(1)],
false
);
}

#[test]
fn test_bytesize_256_eq_2() {
try_test!(ByteSizeGadgetContainer<Fr, 2>,
vec![Word::from(256)],
[Word::from(256)],
true
);
}

#[test]
fn test_bytesize_wordmax_eq_32() {
try_test!(ByteSizeGadgetContainer<Fr, 32>, vec![Word::MAX], true)
try_test!(ByteSizeGadgetContainer<Fr, 32>, [Word::MAX], true)
}
}
18 changes: 9 additions & 9 deletions zkevm-circuits/src/evm_circuit/util/math_gadget/cmp_words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ mod tests {
// a == b check
try_test!(
CmpWordGadgetTestContainer<Fr, true>,
vec![Word::from(0), Word::from(0)],
[Word::from(0), Word::from(0)],
true,
);
}
Expand All @@ -150,7 +150,7 @@ mod tests {
fn test_cmpword_1_eq() {
try_test!(
CmpWordGadgetTestContainer<Fr, true>,
vec![Word::from(1), Word::from(1)],
[Word::from(1), Word::from(1)],
true,
);
}
Expand All @@ -159,7 +159,7 @@ mod tests {
fn test_cmpword_wordmax_eq() {
try_test!(
CmpWordGadgetTestContainer<Fr, true>,
vec![Word::MAX, Word::MAX],
[Word::MAX, Word::MAX],
true,
);
}
Expand All @@ -168,7 +168,7 @@ mod tests {
fn test_cmpword_0_neq_wordmax() {
try_test!(
CmpWordGadgetTestContainer<Fr, true>,
vec![Word::from(0), Word::MAX],
[Word::from(0), Word::MAX],
false,
);
}
Expand All @@ -178,7 +178,7 @@ mod tests {
fn test_cmpword_0_lt_1() {
try_test!(
CmpWordGadgetTestContainer<Fr, false>,
vec![Word::from(0), Word::from(1)],
[Word::from(0), Word::from(1)],
true,
);
}
Expand All @@ -187,7 +187,7 @@ mod tests {
fn test_cmpword_1_lt_wordmax() {
try_test!(
CmpWordGadgetTestContainer<Fr, false>,
vec![Word::from(1), Word::MAX],
[Word::from(1), Word::MAX],
true,
);
}
Expand All @@ -196,7 +196,7 @@ mod tests {
fn test_cmpword_1_lt_0() {
try_test!(
CmpWordGadgetTestContainer<Fr, false>,
vec![Word::from(1), Word::from(0)],
[Word::from(1), Word::from(0)],
false,
);
}
Expand All @@ -205,7 +205,7 @@ mod tests {
fn test_cmpword_lowmax_lt_highmax() {
try_test!(
CmpWordGadgetTestContainer<Fr, false>,
vec![WORD_LOW_MAX, WORD_HIGH_MAX],
[WORD_LOW_MAX, WORD_HIGH_MAX],
true,
);
}
Expand All @@ -214,7 +214,7 @@ mod tests {
fn test_cmpword_highmax_lt_lowmax() {
try_test!(
CmpWordGadgetTestContainer<Fr, false>,
vec![WORD_HIGH_MAX, WORD_LOW_MAX],
[WORD_HIGH_MAX, WORD_LOW_MAX],
false,
);
}
Expand Down
20 changes: 10 additions & 10 deletions zkevm-circuits/src/evm_circuit/util/math_gadget/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {
// a == b check
try_test!(
ComparisonTestContainer<Fr, 4, true>,
vec![Word::from(0), Word::from(0)],
[Word::from(0), Word::from(0)],
true,
);
}
Expand All @@ -116,7 +116,7 @@ mod tests {
fn test_comparison_1_eq() {
try_test!(
ComparisonTestContainer<Fr, 4, true>,
vec![Word::from(1), Word::from(1)],
[Word::from(1), Word::from(1)],
true,
);
}
Expand All @@ -125,7 +125,7 @@ mod tests {
fn test_comparison_max_eq() {
try_test!(
ComparisonTestContainer<Fr, 4, true>,
vec![Word::from(1 << 4), Word::from(1 << 4)],
[Word::from(1 << 4), Word::from(1 << 4)],
true,
);
}
Expand All @@ -134,7 +134,7 @@ mod tests {
fn test_comparison_0_neq_max() {
try_test!(
ComparisonTestContainer<Fr, 4, true>,
vec![Word::from(0), Word::from(1 << 4)],
[Word::from(0), Word::from(1 << 4)],
false,
);
}
Expand All @@ -144,7 +144,7 @@ mod tests {
fn test_comparison_0_lt_1() {
try_test!(
ComparisonTestContainer<Fr, 4, false>,
vec![Word::from(0), Word::from(1)],
[Word::from(0), Word::from(1)],
true,
);
}
Expand All @@ -153,7 +153,7 @@ mod tests {
fn test_comparison_1_lt_max() {
try_test!(
ComparisonTestContainer<Fr, 4, false>,
vec![Word::from(1), Word::from(1 << 4)],
[Word::from(1), Word::from(1 << 4)],
true,
);
}
Expand All @@ -162,7 +162,7 @@ mod tests {
fn test_comparison_1_lt_0() {
try_test!(
ComparisonTestContainer<Fr, 4, false>,
vec![Word::from(1), Word::from(0)],
[Word::from(1), Word::from(0)],
false,
);
}
Expand All @@ -174,13 +174,13 @@ mod tests {
let half_max_hi = U256([0, u64::MAX, 0, 0]);
try_test!(
ComparisonTestContainer<Fr, N_BYTES, false>,
vec![half_max_lo, half_max_hi],
[half_max_lo, half_max_hi],
true,
);

try_test!(
ComparisonTestContainer<Fr, N_BYTES, false>,
vec![half_max_hi, half_max_lo],
[half_max_hi, half_max_lo],
false,
);
}
Expand All @@ -189,7 +189,7 @@ mod tests {
fn test_comparison_overflow() {
try_test!(
ComparisonTestContainer<Fr, 4, false>,
vec![Word::from(10000), Word::from(1 << (4 + 1))],
[Word::from(10000), Word::from(1 << (4 + 1))],
false,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod tests {
fn test_constantdivisiongadget_0div5_rem0() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 5, 0, 0>,
vec![Word::from(0)],
[Word::from(0)],
true,
);
}
Expand All @@ -163,7 +163,7 @@ mod tests {
fn test_constantdivisiongadget_5div5_rem0() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 5, 1, 0>,
vec![Word::from(5)],
[Word::from(5)],
true,
);
}
Expand All @@ -172,7 +172,7 @@ mod tests {
fn test_constantdivisiongadget_1div5_rem1() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 5, 0, 1>,
vec![Word::from(1)],
[Word::from(1)],
true,
);
}
Expand All @@ -181,7 +181,7 @@ mod tests {
fn test_constantdivisiongadget_1div5_rem4() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 5, 1, 4>,
vec![Word::from(1)],
[Word::from(1)],
false,
);
}
Expand All @@ -190,7 +190,7 @@ mod tests {
fn test_constantdivisiongadget_quotient_overflow() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 5, 4294967296u64, 1>,
vec![Word::from(1u64 << (4 * 8)) * 5 + 1],
[Word::from(1u64 << (4 * 8)) * 5 + 1],
false,
);
}
Expand All @@ -199,7 +199,7 @@ mod tests {
fn test_constantdivisiongadget_33_div16_rem17() {
try_test!(
ConstantDivisionTestContainer<Fr, 4, 16, 1, 17>,
vec![Word::from(33)],
[Word::from(33)],
false,
);
}
Expand Down
Loading

0 comments on commit 150c75c

Please sign in to comment.