primitives: use EMPTY_OMMER_ROOT_HASH const when possible (#11833)

This commit is contained in:
Thomas Coratger
2024-10-17 13:21:40 +02:00
committed by GitHub
parent b77265e61b
commit 3bc3e71699
4 changed files with 10 additions and 13 deletions

View File

@ -300,7 +300,7 @@ pub fn validate_against_parent_4844(
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::{TxEip4844, EMPTY_ROOT_HASH};
use alloy_consensus::{TxEip4844, EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH};
use alloy_primitives::{
hex_literal::hex, Address, BlockHash, BlockNumber, Bytes, Parity, Sealable, U256,
};
@ -441,7 +441,7 @@ mod tests {
let header = Header {
parent_hash: hex!("859fad46e75d9be177c2584843501f2270c7e5231711e90848290d12d7c6dcdd").into(),
ommers_hash: hex!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").into(),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: hex!("4675c7e5baafbffbca748158becba61ef3b0a263").into(),
state_root: hex!("8337403406e368b3e40411138f4868f79f6d835825d55fd0c2f6e17b1a3948e9").into(),
transactions_root: EMPTY_ROOT_HASH,

View File

@ -87,7 +87,7 @@ impl From<HeadersDirection> for bool {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::EMPTY_ROOT_HASH;
use alloy_consensus::{EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH};
use alloy_primitives::{address, b256, bloom, bytes, hex, Address, Bytes, B256, U256};
use alloy_rlp::{Decodable, Encodable};
use reth_primitives::Header;
@ -124,7 +124,7 @@ mod tests {
.unwrap();
let header = Header {
parent_hash: b256!("e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2a"),
ommers_hash: b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: address!("ba5e000000000000000000000000000000000000"),
state_root: b256!("ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7"),
transactions_root: b256!("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf"),
@ -228,10 +228,7 @@ mod tests {
"3a9b485972e7353edd9152712492f0c58d89ef80623686b6bf947a4a6dce6cb6",
)
.unwrap(),
ommers_hash: B256::from_str(
"1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
)
.unwrap(),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: Address::from_str("2adc25665018aa1fe0e6bc666dac8fc2697ff9ba").unwrap(),
state_root: B256::from_str(
"3c837fc158e3e93eafcaf2e658a02f5d8f99abc9f1c4c66cdea96c0ca26406ae",
@ -280,7 +277,7 @@ mod tests {
"13a7ec98912f917b3e804654e37c9866092043c13eb8eab94eb64818e886cff5",
)
.unwrap(),
ommers_hash: b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: address!("f97e180c050e5ab072211ad2c213eb5aee4df134"),
state_root: b256!("ec229dbe85b0d3643ad0f471e6ec1a36bbc87deffbbd970762d22a53b35d068a"),
transactions_root: EMPTY_ROOT_HASH,

View File

@ -126,12 +126,13 @@ impl Compact for AlloyHeader {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::EMPTY_OMMER_ROOT_HASH;
use alloy_primitives::{address, b256, bloom, bytes, hex};
/// Holesky block #1947953
const HOLESKY_BLOCK: Header = Header {
parent_hash: b256!("8605e0c46689f66b3deed82598e43d5002b71a929023b665228728f0c6e62a95"),
ommers_hash: b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: address!("c6e2459991bfe27cca6d86722f35da23a1e4cb97"),
state_root: b256!("edad188ca5647d62f4cca417c11a1afbadebce30d23260767f6f587e9b3b9993"),
transactions_root: b256!("4daf25dc08a841aa22aa0d3cb3e1f159d4dcaf6a6063d4d36bfac11d3fdb63ee"),

View File

@ -1,6 +1,6 @@
//! Dummy blocks and data for tests
use crate::{DatabaseProviderRW, ExecutionOutcome};
use alloy_consensus::TxLegacy;
use alloy_consensus::{TxLegacy, EMPTY_OMMER_ROOT_HASH};
use alloy_primitives::{
b256, hex_literal::hex, map::HashMap, Address, BlockNumber, Bytes, Log, Parity, Sealable,
TxKind, B256, U256,
@ -66,8 +66,7 @@ pub(crate) static TEST_BLOCK: LazyLock<SealedBlock> = LazyLock::new(|| SealedBlo
Header {
parent_hash: hex!("c86e8cc0310ae7c531c758678ddbfd16fc51c8cef8cec650b032de9869e8b94f")
.into(),
ommers_hash: hex!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
.into(),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
beneficiary: hex!("2adc25665018aa1fe0e6bc666dac8fc2697ff9ba").into(),
state_root: hex!("50554882fbbda2c2fd93fdc466db9946ea262a67f7a76cc169e714f105ab583d")
.into(),