mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
add manual_assert clippy lint (#8578)
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This commit is contained in:
@ -163,6 +163,8 @@ string_lit_as_bytes = "warn"
|
||||
explicit_into_iter_loop = "warn"
|
||||
explicit_iter_loop = "warn"
|
||||
type_repetition_in_bounds = "warn"
|
||||
flat_map_option = "warn"
|
||||
manual_assert = "warn"
|
||||
manual_string_new = "warn"
|
||||
naive_bytecount = "warn"
|
||||
needless_bitwise_bool = "warn"
|
||||
|
||||
@ -45,9 +45,10 @@ impl BlockchainTreeConfig {
|
||||
num_of_additional_canonical_block_hashes: u64,
|
||||
max_unconnected_blocks: u32,
|
||||
) -> Self {
|
||||
if max_reorg_depth > max_blocks_in_chain {
|
||||
panic!("Side chain size should be more than finalization window");
|
||||
}
|
||||
assert!(
|
||||
max_reorg_depth <= max_blocks_in_chain,
|
||||
"Side chain size should be more than finalization window"
|
||||
);
|
||||
Self {
|
||||
max_blocks_in_chain,
|
||||
max_reorg_depth,
|
||||
|
||||
@ -172,9 +172,10 @@ mod tests {
|
||||
// 0xa1 = 0x80 (start of string) + 0x21 (33, length of string)
|
||||
let long_rlp = hex!("a1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
let decode_result = BlockHashOrNumber::decode(&mut &long_rlp[..]);
|
||||
if decode_result.is_ok() {
|
||||
panic!("Decoding a bytestring longer than 32 bytes should not decode successfully");
|
||||
}
|
||||
assert!(
|
||||
decode_result.is_err(),
|
||||
"Decoding a bytestring longer than 32 bytes should not decode successfully"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -183,9 +184,7 @@ mod tests {
|
||||
// 0x89 = 0x80 (start of string) + 0x09 (9, length of string)
|
||||
let long_number = hex!("89ffffffffffffffffff");
|
||||
let decode_result = BlockHashOrNumber::decode(&mut &long_number[..]);
|
||||
if decode_result.is_ok() {
|
||||
panic!("Decoding a number longer than 64 bits (but not exactly 32 bytes) should not decode successfully");
|
||||
}
|
||||
assert!(decode_result.is_err(), "Decoding a number longer than 64 bits (but not exactly 32 bytes) should not decode successfully");
|
||||
}
|
||||
|
||||
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
|
||||
|
||||
@ -353,9 +353,7 @@ where
|
||||
{
|
||||
// Highly unlikely to happen, and given its destructive nature, it's better to panic
|
||||
// instead.
|
||||
if PipelineTarget::Unwind(0) == unwind_target {
|
||||
panic!("A static file <> database inconsistency was found that would trigger an unwind to block 0.")
|
||||
}
|
||||
assert_ne!(unwind_target, PipelineTarget::Unwind(0), "A static file <> database inconsistency was found that would trigger an unwind to block 0");
|
||||
|
||||
info!(target: "reth::cli", unwind_target = %unwind_target, "Executing an unwind after a failed storage consistency check.");
|
||||
|
||||
|
||||
@ -57,9 +57,11 @@ impl ReusableDecompressor {
|
||||
let mut reserved_upper_bound = false;
|
||||
while let Err(err) = self.decompressor.decompress_to_buffer(src, &mut self.buf) {
|
||||
let err = err.to_string();
|
||||
if !err.contains("Destination buffer is too small") {
|
||||
panic!("Failed to decompress {} bytes: {err}", src.len());
|
||||
}
|
||||
assert!(
|
||||
err.contains("Destination buffer is too small"),
|
||||
"Failed to decompress {} bytes: {err}",
|
||||
src.len()
|
||||
);
|
||||
|
||||
let additional = 'b: {
|
||||
// Try to get the upper bound of the decompression for the given source.
|
||||
|
||||
@ -936,11 +936,10 @@ fn from_compact_zstd_unaware(mut buf: &[u8], _len: usize) -> (TransactionSignedN
|
||||
let (signature, buf) = Signature::from_compact(buf, sig_bit);
|
||||
|
||||
let zstd_bit = bitflags >> 3;
|
||||
if zstd_bit != 0 {
|
||||
panic!(
|
||||
"zstd-codec feature is not enabled, cannot decode `TransactionSignedNoHash` with zstd flag"
|
||||
)
|
||||
}
|
||||
assert_eq!(
|
||||
zstd_bit, 0,
|
||||
"zstd-codec feature is not enabled, cannot decode `TransactionSignedNoHash` with zstd flag"
|
||||
);
|
||||
|
||||
let transaction_type = bitflags >> 1;
|
||||
let (transaction, buf) = Transaction::from_compact(buf, transaction_type);
|
||||
|
||||
@ -105,9 +105,7 @@ async fn only_blobs_eviction() {
|
||||
|
||||
// ensure that this is only returned when the sender is over the
|
||||
// pool limit per account
|
||||
if i + 1 < pool_config.max_account_slots {
|
||||
panic!("Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
}
|
||||
assert!(i + 1 >= pool_config.max_account_slots, "Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
// at this point we know that the sender has been limited, so we
|
||||
// keep going
|
||||
}
|
||||
@ -213,9 +211,7 @@ async fn mixed_eviction() {
|
||||
|
||||
// ensure that this is only returned when the sender is over the
|
||||
// pool limit per account
|
||||
if i + 1 < pool_config.max_account_slots {
|
||||
panic!("Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
}
|
||||
assert!(i + 1 >= pool_config.max_account_slots, "Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
}
|
||||
_ => panic!("Failed to insert tx into pool with unexpected error: {e}"),
|
||||
}
|
||||
@ -322,9 +318,7 @@ async fn nonce_gaps_eviction() {
|
||||
|
||||
// ensure that this is only returned when the sender is over the
|
||||
// pool limit per account
|
||||
if i + 1 < pool_config.max_account_slots {
|
||||
panic!("Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
}
|
||||
assert!(i + 1 >= pool_config.max_account_slots, "Spammer exceeded capacity, but it shouldn't have. Max accounts slots: {}, current txs by sender: {}", pool_config.max_account_slots, i + 1);
|
||||
}
|
||||
_ => panic!("Failed to insert tx into pool with unexpected error: {e}"),
|
||||
}
|
||||
|
||||
@ -76,9 +76,7 @@ pub(crate) fn assert_tests_pass(suite_name: &str, path: &Path, results: &[CaseRe
|
||||
|
||||
print_results(suite_name, path, &passed, &failed, &skipped);
|
||||
|
||||
if !failed.is_empty() {
|
||||
panic!("Some tests failed (see above)");
|
||||
}
|
||||
assert!(failed.is_empty(), "Some tests failed (see above)");
|
||||
}
|
||||
|
||||
/// Categorize test results into `(passed, failed, skipped)`.
|
||||
|
||||
Reference in New Issue
Block a user