Skip to content

Commit

Permalink
update based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Sep 19, 2023
1 parent bba378c commit 7838c94
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/ef-testing/src/models/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn handle_pre_state(
let mut starknet = env.sequencer().sequencer.backend.state.write().await;
let starknet_db = starknet
.maybe_as_cached_db()
.ok_or_else(|| RunnerError::Other("failed to get Katana database".to_string()))?;
.ok_or_else(|| RunnerError::SequencerError("failed to get Katana database".to_string()))?;

let eoa_class_hash = get_eoa_class_hash(env, &starknet_db)?;
let class_hashes = ClassHashes::new(
Expand Down Expand Up @@ -165,6 +165,9 @@ impl BlockchainTestCase {

// Get lock on the Starknet sequencer
let mut starknet = env.sequencer().sequencer.backend.state.write().await;
let starknet_db = starknet.maybe_as_cached_db().ok_or_else(|| {
RunnerError::SequencerError("failed to get Katana database".to_string())
})?;

for (evm_address, expected_state) in post_state.iter() {
let addr: FieldElement = Felt252Wrapper::from(*evm_address).into();
Expand All @@ -173,9 +176,6 @@ impl BlockchainTestCase {
let starknet_contract_address =
StarknetContractAddress(Into::<StarkFelt>::into(starknet_address).try_into()?);

let starknet_db = starknet
.maybe_as_cached_db()
.ok_or_else(|| RunnerError::Other("failed to get Katana database".to_string()))?;
let actual_state = starknet_db.storage.get(&starknet_contract_address);
match actual_state {
None => {
Expand Down
3 changes: 3 additions & 0 deletions crates/ef-testing/src/models/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub enum RunnerError {
/// The specific error
error: String,
},
/// Sequencer error
#[error("An error occurred while running the sequencer: {0}")]
SequencerError(String),
/// Skipped test
#[error("test skipped")]
Skipped,
Expand Down
4 changes: 3 additions & 1 deletion crates/ef-testing/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ pub fn write_test_state(
starknet
.set_class_hash_at(address, ClassHash(class_hashes.proxy_class_hash.into()))
.map_err(|err| {
RunnerError::Other(format!("error setting class hash at {address:#?}: {err}"))
RunnerError::SequencerError(format!(
"error setting class hash at {address:#?}: {err}"
))
})?;
starknet.set_nonce(address, Nonce(StarkFelt::from(account_nonce)));
for (k, v) in starknet_contract_storage.into_iter() {
Expand Down

0 comments on commit 7838c94

Please sign in to comment.