Skip to content

Commit

Permalink
Improve coverage in exe mod
Browse files Browse the repository at this point in the history
  • Loading branch information
LKozlowski committed Nov 4, 2024
1 parent f95a911 commit 47c2e4f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gloo-timers = { version = "0.3.0", features = ["futures"] }
[dev-dependencies]
anyhow = "1.0.89"
alloy-primitives = { version = "0.8.5", default-features = false }
blockifier = { git = "https://github.com/sergey-melnychuk/sequencer.git", tag = "beerus-wasm-2024-09-22", version = "=0.8.0-rc.2", features = ["testing"] }
chrono = "0.4.38"
katana-core = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" }
katana-executor = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" }
Expand Down
50 changes: 50 additions & 0 deletions src/exe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,53 @@ impl<T: gen::client::blocking::HttpClient> BlockifierState for StateProxy<T> {
tracing::info!(?class_hash, pcs.len = pcs.len(), "add_visited_pcs");
}
}

#[cfg(test)]
mod tests {

use blockifier::execution::contract_class::ContractClassV1;
use starknet_api::core::PatriciaKey;

use super::*;
struct MockHttpClient;

impl crate::gen::client::blocking::HttpClient for MockHttpClient {
fn post(
&self,
_url: &str,
_request: &iamgroot::jsonrpc::Request,
) -> std::result::Result<iamgroot::jsonrpc::Response, iamgroot::jsonrpc::Error> {
Err(iamgroot::jsonrpc::Error {code: 0, message: "0".into()})
}
}

#[test]
fn test_luke() {
let mock = MockHttpClient{};
let mut proxy = StateProxy {
client: gen::client::blocking::Client::new("test", mock),
state: State {
block_number: 0,
block_hash: gen::Felt::try_new("0x0").unwrap(),
root: gen::Felt::try_new("0x0").unwrap(),
}
};

proxy.set_storage_at(
ContractAddress(PatriciaKey::try_from(starknet_crypto::Felt::ZERO).unwrap()),
StarknetStorageKey(PatriciaKey::try_from(starknet_crypto::Felt::ZERO).unwrap()),
starknet_crypto::Felt::ZERO,
).unwrap();
proxy.increment_nonce(
ContractAddress(PatriciaKey::try_from(starknet_crypto::Felt::ZERO).unwrap()),
).unwrap();
proxy.set_class_hash_at(
ContractAddress(PatriciaKey::try_from(starknet_crypto::Felt::ZERO).unwrap()),
ClassHash(starknet_crypto::Felt::ZERO),
).unwrap();
proxy.set_contract_class(ClassHash(starknet_crypto::Felt::ZERO), ContractClass::V1(ContractClassV1::empty_for_testing())).unwrap();
proxy.set_compiled_class_hash(ClassHash(starknet_crypto::Felt::ZERO), CompiledClassHash(starknet_crypto::Felt::ZERO)).unwrap();
proxy.add_visited_pcs(ClassHash(starknet_crypto::Felt::ZERO), &HashSet::new());

}
}

0 comments on commit 47c2e4f

Please sign in to comment.