feat: remove PartialEq+Eq from ProviderError and all others affected (#13592)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Glow
2025-01-04 17:27:35 +07:00
committed by GitHub
parent 91d09de440
commit 86399e2aea
12 changed files with 129 additions and 135 deletions

View File

@ -44,7 +44,7 @@ pub const AVERAGE_COUNT_ACCOUNTS_PER_GB_STATE_DUMP: usize = 285_228;
const SOFT_LIMIT_COUNT_FLUSHED_UPDATES: usize = 1_000_000;
/// Storage initialization error type.
#[derive(Debug, thiserror::Error, PartialEq, Eq, Clone)]
#[derive(Debug, thiserror::Error, Clone)]
pub enum InitStorageError {
/// Genesis header found on static files but the database is empty.
#[error("static files found, but the database is uninitialized. If attempting to re-syncing, delete both.")]
@ -688,13 +688,13 @@ mod tests {
static_file_provider,
));
assert_eq!(
assert!(matches!(
genesis_hash.unwrap_err(),
InitStorageError::GenesisHashMismatch {
chainspec_hash: MAINNET_GENESIS_HASH,
storage_hash: SEPOLIA_GENESIS_HASH
}
)
))
}
#[test]

View File

@ -10,7 +10,7 @@ use reth_static_file_types::StaticFileSegment;
pub type ProviderResult<Ok> = Result<Ok, ProviderError>;
/// Bundled errors variants thrown by various providers.
#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
#[derive(Clone, Debug, thiserror::Error)]
pub enum ProviderError {
/// Database error.
#[error(transparent)]

View File

@ -2740,14 +2740,14 @@ mod tests {
// Even though the block exists, given the order of provider queries done in the method
// above, we do not see it.
assert_eq!(
assert!(matches!(
old_transaction_hash_fn(
to_be_persisted_tx.hash(),
provider.canonical_in_memory_state(),
provider.database.clone()
),
Ok(None)
);
));
}
// CORRECT BEHAVIOUR
@ -2757,14 +2757,14 @@ mod tests {
persist_block_after_db_tx_creation(provider.clone(), in_memory_blocks[1].number);
let to_be_persisted_tx = in_memory_blocks[1].body().transactions[0].clone();
assert_eq!(
assert!(matches!(
correct_transaction_hash_fn(
to_be_persisted_tx.hash(),
provider.canonical_in_memory_state(),
provider.database
),
Ok(Some(to_be_persisted_tx))
);
));
}
Ok(())

View File

@ -778,7 +778,7 @@ mod tests {
);
let db_senders = provider.senders_by_tx_range(range);
assert_eq!(db_senders, Ok(vec![]));
assert!(matches!(db_senders, Ok(ref v) if v.is_empty()));
}
}

View File

@ -633,48 +633,51 @@ mod tests {
let db = factory.provider().unwrap();
// run
assert_eq!(HistoricalStateProviderRef::new(&db, 1).basic_account(&ADDRESS), Ok(None));
assert_eq!(
assert!(matches!(
HistoricalStateProviderRef::new(&db, 1).basic_account(&ADDRESS),
Ok(None)
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 2).basic_account(&ADDRESS),
Ok(Some(acc_at3))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at3
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 3).basic_account(&ADDRESS),
Ok(Some(acc_at3))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at3
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 4).basic_account(&ADDRESS),
Ok(Some(acc_at7))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at7
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 7).basic_account(&ADDRESS),
Ok(Some(acc_at7))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at7
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 9).basic_account(&ADDRESS),
Ok(Some(acc_at10))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at10
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 10).basic_account(&ADDRESS),
Ok(Some(acc_at10))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at10
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 11).basic_account(&ADDRESS),
Ok(Some(acc_at15))
);
assert_eq!(
Ok(Some(acc)) if acc == acc_at15
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 16).basic_account(&ADDRESS),
Ok(Some(acc_plain))
);
Ok(Some(acc)) if acc == acc_plain
));
assert_eq!(
assert!(matches!(
HistoricalStateProviderRef::new(&db, 1).basic_account(&HIGHER_ADDRESS),
Ok(None)
);
assert_eq!(
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 1000).basic_account(&HIGHER_ADDRESS),
Ok(Some(higher_acc_plain))
);
Ok(Some(acc)) if acc == higher_acc_plain
));
}
#[test]
@ -730,43 +733,46 @@ mod tests {
let db = factory.provider().unwrap();
// run
assert_eq!(HistoricalStateProviderRef::new(&db, 0).storage(ADDRESS, STORAGE), Ok(None));
assert_eq!(
assert!(matches!(
HistoricalStateProviderRef::new(&db, 0).storage(ADDRESS, STORAGE),
Ok(None)
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 3).storage(ADDRESS, STORAGE),
Ok(Some(U256::ZERO))
);
assert_eq!(
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 4).storage(ADDRESS, STORAGE),
Ok(Some(entry_at7.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_at7.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 7).storage(ADDRESS, STORAGE),
Ok(Some(entry_at7.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_at7.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 9).storage(ADDRESS, STORAGE),
Ok(Some(entry_at10.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_at10.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 10).storage(ADDRESS, STORAGE),
Ok(Some(entry_at10.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_at10.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 11).storage(ADDRESS, STORAGE),
Ok(Some(entry_at15.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_at15.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 16).storage(ADDRESS, STORAGE),
Ok(Some(entry_plain.value))
);
assert_eq!(
Ok(Some(expected_value)) if expected_value == entry_plain.value
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 1).storage(HIGHER_ADDRESS, STORAGE),
Ok(None)
);
assert_eq!(
));
assert!(matches!(
HistoricalStateProviderRef::new(&db, 1000).storage(HIGHER_ADDRESS, STORAGE),
Ok(Some(higher_entry_plain.value))
);
Ok(Some(expected_value)) if expected_value == higher_entry_plain.value
));
}
#[test]
@ -784,14 +790,14 @@ mod tests {
storage_history_block_number: Some(3),
},
);
assert_eq!(
assert!(matches!(
provider.account_history_lookup(ADDRESS),
Err(ProviderError::StateAtBlockPruned(provider.block_number))
);
assert_eq!(
Err(ProviderError::StateAtBlockPruned(number)) if number == provider.block_number
));
assert!(matches!(
provider.storage_history_lookup(ADDRESS, STORAGE),
Err(ProviderError::StateAtBlockPruned(provider.block_number))
);
Err(ProviderError::StateAtBlockPruned(number)) if number == provider.block_number
));
// provider block_number == lowest available block number,
// i.e. state at provider block is available
@ -803,11 +809,14 @@ mod tests {
storage_history_block_number: Some(2),
},
);
assert_eq!(provider.account_history_lookup(ADDRESS), Ok(HistoryInfo::MaybeInPlainState));
assert_eq!(
assert!(matches!(
provider.account_history_lookup(ADDRESS),
Ok(HistoryInfo::MaybeInPlainState)
));
assert!(matches!(
provider.storage_history_lookup(ADDRESS, STORAGE),
Ok(HistoryInfo::MaybeInPlainState)
);
));
// provider block_number == lowest available block number,
// i.e. state at provider block is available
@ -819,10 +828,13 @@ mod tests {
storage_history_block_number: Some(1),
},
);
assert_eq!(provider.account_history_lookup(ADDRESS), Ok(HistoryInfo::MaybeInPlainState));
assert_eq!(
assert!(matches!(
provider.account_history_lookup(ADDRESS),
Ok(HistoryInfo::MaybeInPlainState)
));
assert!(matches!(
provider.storage_history_lookup(ADDRESS, STORAGE),
Ok(HistoryInfo::MaybeInPlainState)
);
));
}
}

View File

@ -287,7 +287,7 @@ mod tests {
hashed_state.storages.insert(destroyed_address_hashed, HashedStorage::new(true));
let provider_rw = provider_factory.provider_rw().unwrap();
assert_eq!(provider_rw.write_hashed_state(&hashed_state.into_sorted()), Ok(()));
assert!(matches!(provider_rw.write_hashed_state(&hashed_state.into_sorted()), Ok(())));
provider_rw.commit().unwrap();
let provider = provider_factory.provider().unwrap();