Skip to content

Commit a2f4a26

Browse files
chore(starknet_sequencer_node): bundle all deployments in an array
1 parent 26213a5 commit a2f4a26

File tree

4 files changed

+49
-39
lines changed

4 files changed

+49
-39
lines changed
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use starknet_infra_utils::dumping::serialize_to_file;
2-
use starknet_sequencer_node::deployment_definitions::{
3-
create_main_deployment,
4-
create_testing_deployment,
5-
MAIN_DEPLOYMENT_PRESET_PATH,
6-
TESTING_DEPLOYMENT_PRESET_PATH,
7-
};
2+
use starknet_sequencer_node::deployment::DeploymentAndPreset;
3+
use starknet_sequencer_node::deployment_definitions::DEPLOYMENTS;
84

95
// TODO(Tsabary): bundle deployment and its preset path together, and create a list of all of these
106
// pairs. Then in the test, iterate over them and test each one.
117

128
/// Creates the deployment json file.
139
fn main() {
14-
serialize_to_file(create_main_deployment(), MAIN_DEPLOYMENT_PRESET_PATH);
15-
serialize_to_file(create_testing_deployment(), TESTING_DEPLOYMENT_PRESET_PATH);
10+
for deployment_fn in DEPLOYMENTS {
11+
let DeploymentAndPreset { deployment, dump_file_path } = deployment_fn();
12+
serialize_to_file(deployment, dump_file_path);
13+
}
1614
}

crates/starknet_sequencer_node/src/deployment.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ use crate::config::component_execution_config::{
1515

1616
const BASE_PORT: u16 = 55000; // TODO(Tsabary): arbitrary port, need to resolve.
1717

18+
pub struct DeploymentAndPreset<'a> {
19+
pub deployment: Deployment<'a>,
20+
pub dump_file_path: &'static str,
21+
}
22+
23+
impl<'a> DeploymentAndPreset<'a> {
24+
pub fn new(deployment: Deployment<'a>, dump_file_path: &'static str) -> Self {
25+
Self { deployment, dump_file_path }
26+
}
27+
}
28+
1829
#[derive(Clone, Debug, PartialEq, Serialize)]
1930
pub struct Deployment<'a> {
2031
chain_id: ChainId,
Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use starknet_api::core::ChainId;
22

3-
use crate::deployment::{Deployment, DeploymentName};
3+
use crate::deployment::{Deployment, DeploymentAndPreset, DeploymentName};
44

55
#[cfg(test)]
66
#[path = "deployment_definitions_test.rs"]
@@ -15,29 +15,31 @@ pub const SINGLE_NODE_CONFIG_PATH: &str =
1515
"config/sequencer/presets/system_test_presets/single_node/node_0/executable_0/node_config.json";
1616

1717
// TODO(Tsabary): fill and order these.
18-
pub const MAIN_DEPLOYMENT_PRESET_PATH: &str = "config/sequencer/presets/main.json";
19-
pub const MAIN_DEPLOYMENT_APP_CONFIG_SUBDIR: &str =
20-
"config/sequencer/presets/system_test_presets/single_node/";
21-
22-
pub fn create_main_deployment() -> Deployment<'static> {
23-
Deployment::new(
24-
ChainId::Mainnet,
25-
DEPLOYMENT_IMAGE,
26-
MAIN_DEPLOYMENT_APP_CONFIG_SUBDIR,
27-
DeploymentName::DistributedNode,
18+
19+
type DeploymentFn = fn() -> DeploymentAndPreset<'static>;
20+
21+
pub const DEPLOYMENTS: &[DeploymentFn] = &[create_main_deployment, create_testing_deployment];
22+
23+
fn create_main_deployment() -> DeploymentAndPreset<'static> {
24+
DeploymentAndPreset::new(
25+
Deployment::new(
26+
ChainId::Mainnet,
27+
DEPLOYMENT_IMAGE,
28+
"config/sequencer/presets/system_test_presets/single_node/",
29+
DeploymentName::DistributedNode,
30+
),
31+
"config/sequencer/presets/main.json",
2832
)
2933
}
3034

31-
pub const TESTING_DEPLOYMENT_PRESET_PATH: &str =
32-
"config/sequencer/deployment_configs/testing/nightly_test_all_in_one.json";
33-
pub const TESTING_DEPLOYMENT_APP_CONFIG_SUBDIR: &str =
34-
"config/sequencer/presets/system_test_presets/single_node/";
35-
36-
pub fn create_testing_deployment() -> Deployment<'static> {
37-
Deployment::new(
38-
ChainId::IntegrationSepolia,
39-
DEPLOYMENT_IMAGE,
40-
TESTING_DEPLOYMENT_APP_CONFIG_SUBDIR,
41-
DeploymentName::ConsolidatedNode,
35+
fn create_testing_deployment() -> DeploymentAndPreset<'static> {
36+
DeploymentAndPreset::new(
37+
Deployment::new(
38+
ChainId::IntegrationSepolia,
39+
DEPLOYMENT_IMAGE,
40+
"config/sequencer/presets/system_test_presets/single_node/",
41+
DeploymentName::ConsolidatedNode,
42+
),
43+
"config/sequencer/deployment_configs/testing/nightly_test_all_in_one.json",
4244
)
4345
}

crates/starknet_sequencer_node/src/deployment_definitions_test.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ use std::env;
33
use starknet_infra_utils::dumping::serialize_to_file_test;
44
use starknet_infra_utils::path::resolve_project_relative_path;
55

6-
use crate::deployment_definitions::{
7-
create_main_deployment,
8-
create_testing_deployment,
9-
MAIN_DEPLOYMENT_PRESET_PATH,
10-
TESTING_DEPLOYMENT_PRESET_PATH,
11-
};
6+
use crate::deployment::DeploymentAndPreset;
7+
use crate::deployment_definitions::DEPLOYMENTS;
128

139
// TODO(Tsabary): bundle deployment and its preset path together, and create a list of all of these
1410
// pairs. Then in the test, iterate over them and test each one.
@@ -17,15 +13,18 @@ use crate::deployment_definitions::{
1713
/// cargo run --bin deployment_generator -q
1814
#[test]
1915
fn deployment_files_are_up_to_date() {
20-
serialize_to_file_test(create_main_deployment(), MAIN_DEPLOYMENT_PRESET_PATH);
21-
serialize_to_file_test(create_testing_deployment(), TESTING_DEPLOYMENT_PRESET_PATH);
16+
for deployment_fn in DEPLOYMENTS {
17+
let DeploymentAndPreset { deployment, dump_file_path } = deployment_fn();
18+
serialize_to_file_test(deployment, dump_file_path);
19+
}
2220
}
2321

2422
#[test]
2523
fn application_config_files_exist() {
2624
env::set_current_dir(resolve_project_relative_path("").unwrap())
2725
.expect("Couldn't set working dir.");
28-
for deployment in &[create_main_deployment(), create_testing_deployment()] {
26+
for deployment_fn in DEPLOYMENTS {
27+
let DeploymentAndPreset { deployment, dump_file_path: _ } = deployment_fn();
2928
deployment.assert_application_configs_exist();
3029
}
3130
}

0 commit comments

Comments
 (0)