From 597d4ecbd31d71fe89a0f3a1204f8c854abd357c Mon Sep 17 00:00:00 2001 From: tnv1 Date: Wed, 1 Jan 2025 20:09:07 +0700 Subject: [PATCH] fix --- crates/stages/stages/src/stages/execution.rs | 22 ++++++++---- crates/stages/stages/src/stages/mod.rs | 6 ++-- .../provider/src/providers/database/mod.rs | 2 +- .../src/providers/state/historical.rs | 36 +++++++++---------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index 6ad48e8017bc..efafc904180d 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -702,7 +702,9 @@ mod tests { previous_checkpoint, ); - assert!(matches!(stage_checkpoint, Ok(previous_stage_checkpoint))); + assert!( + matches!(stage_checkpoint, Ok(checkpoint) if checkpoint == previous_stage_checkpoint) + ); } #[test] @@ -938,14 +940,20 @@ mod tests { }; // assert accounts - assert!(matches!(provider.basic_account(&account1), Ok(Some(account1_info)))); - assert!(matches!(provider.basic_account(&account2), Ok(Some(account2_info)))); - assert!(matches!(provider.basic_account(&account3), Ok(Some(account3_info)))); + assert!( + matches!(provider.basic_account(&account1), Ok(Some(acc)) if acc == account1_info) + ); + assert!( + matches!(provider.basic_account(&account2), Ok(Some(acc)) if acc == account2_info) + ); + assert!( + matches!(provider.basic_account(&account3), Ok(Some(acc)) if acc == account3_info) + ); // assert storage // Get on dupsort would return only first value. This is good enough for this test. assert!(matches!( provider.tx_ref().get::(account1), - Ok(Some(StorageEntry { key: B256::with_last_byte(1), value: U256::from(2) })) + Ok(Some(entry)) if entry.key == B256::with_last_byte(1) && entry.value == U256::from(2) )); let mut provider = factory.database_provider_rw().unwrap(); @@ -1061,8 +1069,8 @@ mod tests { } if total == block.gas_used); // assert unwind stage - assert!(matches!(provider.basic_account(&acc1), Ok(Some(acc1_info)))); - assert!(matches!(provider.basic_account(&acc2), Ok(Some(acc2_info)))); + assert!(matches!(provider.basic_account(&acc1), Ok(Some(acc)) if acc == acc1_info)); + assert!(matches!(provider.basic_account(&acc2), Ok(Some(acc)) if acc == acc2_info)); let miner_acc = address!("2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"); assert!(matches!(provider.basic_account(&miner_acc), Ok(None))); diff --git a/crates/stages/stages/src/stages/mod.rs b/crates/stages/stages/src/stages/mod.rs index fc7936ae807e..fc782f26f012 100644 --- a/crates/stages/stages/src/stages/mod.rs +++ b/crates/stages/stages/src/stages/mod.rs @@ -320,7 +320,7 @@ mod tests { assert!(matches!( static_file_provider .check_consistency(&db.factory.database_provider_ro().unwrap(), is_full_node,), - Ok(expected) + Ok(e) if e == expected )); } @@ -342,7 +342,7 @@ mod tests { db.factory .static_file_provider() .check_consistency(&db.factory.database_provider_ro().unwrap(), false,), - Ok(expected) + Ok(e) if e == expected )); } @@ -364,7 +364,7 @@ mod tests { db.factory .static_file_provider() .check_consistency(&db.factory.database_provider_ro().unwrap(), false), - Ok(expected) + Ok(e) if e == expected )); } diff --git a/crates/storage/provider/src/providers/database/mod.rs b/crates/storage/provider/src/providers/database/mod.rs index cabc21eedc17..4d11863c22fa 100644 --- a/crates/storage/provider/src/providers/database/mod.rs +++ b/crates/storage/provider/src/providers/database/mod.rs @@ -778,7 +778,7 @@ mod tests { ); let db_senders = provider.senders_by_tx_range(range); - assert!(matches!(db_senders, Ok(vec![]))); + assert!(matches!(db_senders, Ok(ref v) if v.is_empty())); } } diff --git a/crates/storage/provider/src/providers/state/historical.rs b/crates/storage/provider/src/providers/state/historical.rs index c1e3a20cd3e7..64a8570499c7 100644 --- a/crates/storage/provider/src/providers/state/historical.rs +++ b/crates/storage/provider/src/providers/state/historical.rs @@ -639,35 +639,35 @@ mod tests { )); assert!(matches!( HistoricalStateProviderRef::new(&db, 2).basic_account(&ADDRESS), - Ok(Some(acc_at3)) + Ok(Some(acc)) if acc == acc_at3 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 3).basic_account(&ADDRESS), - Ok(Some(acc_at3)) + Ok(Some(acc)) if acc == acc_at3 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 4).basic_account(&ADDRESS), - Ok(Some(acc_at7)) + Ok(Some(acc)) if acc == acc_at7 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 7).basic_account(&ADDRESS), - Ok(Some(acc_at7)) + Ok(Some(acc)) if acc == acc_at7 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 9).basic_account(&ADDRESS), - Ok(Some(acc_at10)) + Ok(Some(acc)) if acc == acc_at10 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 10).basic_account(&ADDRESS), - Ok(Some(acc_at10)) + Ok(Some(acc)) if acc == acc_at10 )); assert!(matches!( HistoricalStateProviderRef::new(&db, 11).basic_account(&ADDRESS), - Ok(Some(acc_at15)) + 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!(matches!( @@ -676,7 +676,7 @@ mod tests { )); assert!(matches!( HistoricalStateProviderRef::new(&db, 1000).basic_account(&HIGHER_ADDRESS), - Ok(Some(higher_acc_plain)) + Ok(Some(acc)) if acc == higher_acc_plain )); } @@ -743,27 +743,27 @@ mod tests { )); assert!(matches!( HistoricalStateProviderRef::new(&db, 4).storage(ADDRESS, STORAGE), - Ok(Some(entry_at7.value)) + Ok(Some(expected_value)) if expected_value == entry_at7.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 7).storage(ADDRESS, STORAGE), - Ok(Some(entry_at7.value)) + Ok(Some(expected_value)) if expected_value == entry_at7.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 9).storage(ADDRESS, STORAGE), - Ok(Some(entry_at10.value)) + Ok(Some(expected_value)) if expected_value == entry_at10.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 10).storage(ADDRESS, STORAGE), - Ok(Some(entry_at10.value)) + Ok(Some(expected_value)) if expected_value == entry_at10.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 11).storage(ADDRESS, STORAGE), - Ok(Some(entry_at15.value)) + Ok(Some(expected_value)) if expected_value == entry_at15.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 16).storage(ADDRESS, STORAGE), - Ok(Some(entry_plain.value)) + Ok(Some(expected_value)) if expected_value == entry_plain.value )); assert!(matches!( HistoricalStateProviderRef::new(&db, 1).storage(HIGHER_ADDRESS, STORAGE), @@ -771,7 +771,7 @@ mod tests { )); 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 )); } @@ -792,11 +792,11 @@ mod tests { ); assert!(matches!( provider.account_history_lookup(ADDRESS), - Err(ProviderError::StateAtBlockPruned(provider.block_number)) + 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,