MCPcopy Create free account
hub / github.com/SeismicSystems/summit / create_test_block

Function create_test_block

finalizer/src/tests/syncing.rs:31–81  ·  view source on GitHub ↗

Helper to create a test block with specific parent and height

(parent_digest: Digest, height: u64, view: u64, unique_seed: u64)

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls

Tested by

no test coverage detected