Helper to create a test block with specific parent and height
(parent_digest: Digest, height: u64, view: u64, unique_seed: u64)
| 29 | |
| 30 | /// Helper to create a test block with specific parent and height |
| 31 | fn create_test_block(parent_digest: Digest, height: u64, view: u64, unique_seed: u64) -> Block { |
| 32 | let mut block_hash = [0u8; 32]; |
| 33 | block_hash[0..8].copy_from_slice(&unique_seed.to_le_bytes()); |
| 34 | block_hash[8..16].copy_from_slice(&height.to_le_bytes()); |
| 35 | |
| 36 | let parent_bytes: [u8; 32] = parent_digest.0; |
| 37 | |
| 38 | let payload = ExecutionPayloadV3 { |
| 39 | payload_inner: ExecutionPayloadV2 { |
| 40 | payload_inner: ExecutionPayloadV1 { |
| 41 | base_fee_per_gas: U256::from(1000000000u64), |
| 42 | block_number: height, |
| 43 | block_hash: block_hash.into(), |
| 44 | logs_bloom: Default::default(), |
| 45 | extra_data: Default::default(), |
| 46 | gas_limit: 30000000, |
| 47 | gas_used: 0, |
| 48 | timestamp: height * 12, |
| 49 | fee_recipient: Default::default(), |
| 50 | parent_hash: if height == 0 { |
| 51 | [0u8; 32].into() |
| 52 | } else { |
| 53 | parent_bytes.into() |
| 54 | }, |
| 55 | prev_randao: Default::default(), |
| 56 | receipts_root: Default::default(), |
| 57 | state_root: Default::default(), |
| 58 | transactions: Vec::new(), |
| 59 | }, |
| 60 | withdrawals: Vec::new(), |
| 61 | }, |
| 62 | blob_gas_used: 0, |
| 63 | excess_blob_gas: 0, |
| 64 | }; |
| 65 | |
| 66 | Block::compute_digest( |
| 67 | parent_digest, |
| 68 | height, |
| 69 | height * 12, |
| 70 | payload, |
| 71 | Vec::new(), |
| 72 | height / 10, |
| 73 | view, |
| 74 | None, |
| 75 | [0u8; 32].into(), |
| 76 | Vec::new(), |
| 77 | Vec::new(), |
| 78 | [0u8; 32], |
| 79 | ) |
| 80 | } |
| 81 | |
| 82 | /// Create a minimal initial ConsensusState for testing |
| 83 | fn create_test_initial_state(genesis_hash: [u8; 32], epoch_length: NonZeroU64) -> ConsensusState { |
| 84 | use rand::SeedableRng; |
no outgoing calls
no test coverage detected