Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/apollo_starknet_os_program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build = "build/main.rs"

[features]
dump_source_files = []
test_programs = []

[lints]
workspace = true
Expand Down
11 changes: 11 additions & 0 deletions crates/apollo_starknet_os_program/build/compile_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ pub async fn compile_and_output_program(
});
}

#[cfg(feature = "test_programs")]
pub async fn compile_test_contracts(out_dir: PathBuf) {
let mut task_set = tokio::task::JoinSet::new();
task_set.spawn(compile_and_output_program(
out_dir,
"starkware/starknet/core/os/state/aliases_test.cairo",
"aliases_test",
));
task_set.join_all().await;
}

fn cairo_root_path() -> PathBuf {
PathBuf::from(compile_time_cargo_manifest_dir!()).join("src/cairo")
}
2 changes: 2 additions & 0 deletions crates/apollo_starknet_os_program/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ async fn main() {
dump_source::dump_source_files(&out_dir.join("cairo_files_map.json"));

let mut task_set = tokio::task::JoinSet::new();
#[cfg(feature = "test_programs")]
task_set.spawn(compile_program::compile_test_contracts(out_dir.clone()));
task_set.spawn(compile_program::compile_and_output_program(
out_dir.clone(),
"starkware/starknet/core/os/os.cairo",
Expand Down
2 changes: 2 additions & 0 deletions crates/apollo_starknet_os_program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use crate::program_hash::ProgramHashes;
#[cfg(test)]
mod constants_test;
pub mod program_hash;
#[cfg(feature = "test_programs")]
pub mod test_programs;

#[cfg(feature = "dump_source_files")]
pub static CAIRO_FILES_MAP: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
Expand Down
2 changes: 2 additions & 0 deletions crates/apollo_starknet_os_program/src/test_programs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub const ALIASES_TEST_BYTES: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/aliases_test_bytes"));
5 changes: 3 additions & 2 deletions crates/starknet_committer_and_os_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ tempfile.workspace = true

# TODO(Amos): Add `testing` feature and move Python test dependencies under it.
[dependencies]
# The 'dump_source_files' feature should be moved under `testing` feature, when it exists.
apollo_starknet_os_program = { workspace = true, features = ["dump_source_files"] }
# The 'dump_source_files' and 'test_programs' features should be moved under `testing` feature, when
# it exists.
apollo_starknet_os_program = { workspace = true, features = ["dump_source_files", "test_programs"] }
blake2s.workspace = true
cairo-lang-starknet-classes.workspace = true
cairo-vm = { workspace = true, features = [
Expand Down
2 changes: 2 additions & 0 deletions crates/starknet_committer_and_os_cli/src/os_cli/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fs;
use std::path::Path;

use apollo_starknet_os_program::test_programs::ALIASES_TEST_BYTES;
use apollo_starknet_os_program::{
AGGREGATOR_PROGRAM_BYTES,
CAIRO_FILES_MAP,
Expand Down Expand Up @@ -115,6 +116,7 @@ pub(crate) fn dump_source_files(output_path: String) {
pub(crate) fn dump_program(output_path: String, program: ProgramToDump) {
let bytes = match program {
ProgramToDump::Aggregator => AGGREGATOR_PROGRAM_BYTES,
ProgramToDump::AliasesTest => ALIASES_TEST_BYTES,
ProgramToDump::Os => OS_PROGRAM_BYTES,
};
// Dumping the `Program` struct won't work - it is not deserializable via cairo-lang's Program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct OsCliCommand {
#[serde(rename_all = "kebab-case")]
pub enum ProgramToDump {
Aggregator,
AliasesTest,
Os,
}

Expand Down
Loading