Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tnv1 committed Jan 1, 2025
1 parent 038ec7d commit 597d4ec
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
22 changes: 15 additions & 7 deletions crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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::<tables::PlainStorageState>(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();
Expand Down Expand Up @@ -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)));
Expand Down
6 changes: 3 additions & 3 deletions crates/stages/stages/src/stages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}

Expand All @@ -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
));
}

Expand All @@ -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
));
}

Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/providers/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down
36 changes: 18 additions & 18 deletions crates/storage/provider/src/providers/state/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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
));
}

Expand Down Expand Up @@ -743,35 +743,35 @@ 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),
Ok(None)
));
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
));
}

Expand All @@ -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,
Expand Down

0 comments on commit 597d4ec

Please sign in to comment.