forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 10
Add test to cover error branches of LiveCollector::execute_and_store_block_updates #436
Copy link
Copy link
Closed
Labels
A-trieArea: Merkle Patricia TrieArea: Merkle Patricia TrieK-testKind: testKind: testM-good-first-issueMeta: good issue for first time contributorsMeta: good issue for first time contributorsW-historical-proofsWorkstream: historical-proofsWorkstream: historical-proofs
Description
Describe the feature
Integration test exist for LiveCollector::execute_and_store_block_updates
op-reth/crates/optimism/trie/tests/live.rs
Lines 281 to 314 in b129588
| /// End-to-end test of a single live collector iteration. | |
| /// (1) Creates a chain with some state | |
| /// (2) Stores the genesis state into storage via backfill | |
| /// (3) Executes a block and calculates the state root using the stored state | |
| #[tokio::test] | |
| async fn test_execute_and_store_block_updates() { | |
| let storage = Arc::new(InMemoryProofsStorage::new()).into(); | |
| // Create a keypair for signing transactions | |
| let secp = Secp256k1::new(); | |
| let key_pair = Keypair::new(&secp, &mut thread_rng()); | |
| let sender = public_key_to_address(key_pair.public_key()); | |
| // Create chain spec with the sender address funded in genesis | |
| let chain_spec = chain_spec_with_address(sender); | |
| // Create test database and provider factory | |
| let provider_factory = create_test_provider_factory_with_chain_spec(chain_spec.clone()); | |
| // Insert genesis state into the database | |
| init_genesis(&provider_factory).unwrap(); | |
| // Define the test scenario: | |
| // - No blocks before backfill | |
| // - Backfill to genesis (block 0) | |
| // - Execute one block with a single transaction after backfill | |
| let recipient = Address::repeat_byte(0x42); | |
| let scenario = TestScenario::new( | |
| vec![], | |
| vec![BlockSpec::new(vec![TxSpec::transfer(recipient, U256::from(1))])], | |
| ); | |
| run_test_scenario(scenario, provider_factory, chain_spec, key_pair, storage).await.unwrap(); | |
| } |
Duplicate that test code to add tests to cover the error paths
op-reth/crates/optimism/trie/src/live.rs
Lines 59 to 66 in b129588
| if parent_block_number > latest { | |
| return Err(OpProofsStorageError::MissingParentBlock { | |
| block_number: block.number(), | |
| parent_block_number, | |
| latest_block_number: latest, | |
| } | |
| .into()); | |
| } |
and
op-reth/crates/optimism/trie/src/live.rs
Lines 94 to 101 in b129588
| if state_root != block.state_root() { | |
| return Err(OpProofsStorageError::StateRootMismatch { | |
| block_number: block.number(), | |
| current_state_hash: state_root, | |
| expected_state_hash: block.state_root(), | |
| } | |
| .into()); | |
| } |
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-trieArea: Merkle Patricia TrieArea: Merkle Patricia TrieK-testKind: testKind: testM-good-first-issueMeta: good issue for first time contributorsMeta: good issue for first time contributorsW-historical-proofsWorkstream: historical-proofsWorkstream: historical-proofs
Type
Projects
Status
Done