Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leounoki jstz 242/serialize jstz node config #706

Merged
merged 2 commits into from
Dec 6, 2024
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
23 changes: 22 additions & 1 deletion crates/jstz_node/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::path::{Path, PathBuf};

use octez::r#async::endpoint::Endpoint;
use serde::Serialize;

#[derive(Clone)]
#[derive(Clone, Serialize)]
pub struct JstzNodeConfig {
/// The endpoint of the jstz node.
pub endpoint: Endpoint,
Expand All @@ -25,3 +26,23 @@ impl JstzNodeConfig {
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_serialize_config() {
let config = JstzNodeConfig::new(
&Endpoint::localhost(8932),
&Endpoint::localhost(8933),
Path::new("/tmp/kernel.log"),
);

let json = serde_json::to_value(&config).unwrap();

assert_eq!(json["endpoint"], "http://localhost:8932");
assert_eq!(json["rollup_endpoint"], "http://localhost:8933");
assert_eq!(json["kernel_log_file"], "/tmp/kernel.log");
}
}
2 changes: 1 addition & 1 deletion crates/jstzd/src/task/jstzd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct JstzdConfig {
octez_client_config: OctezClientConfig,
#[serde(rename(serialize = "octez-rollup"))]
octez_rollup_config: OctezRollupConfig,
#[serde(skip_serializing)]
#[serde(rename(serialize = "jstz-node"))]
jstz_node_config: JstzNodeConfig,
#[serde(skip_serializing)]
protocol_params: ProtocolParameter,
Expand Down
4 changes: 4 additions & 0 deletions crates/jstzd/tests/jstzd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ async fn fetch_config_test(jstzd_config: JstzdConfig, jstzd_port: u16) {
"octez-rollup",
serde_json::to_value(jstzd_config.octez_rollup_config()).unwrap(),
),
(
"jstz-node",
serde_json::to_value(jstzd_config.jstz_node_config()).unwrap(),
),
] {
let res =
reqwest::get(&format!("http://localhost:{}/config/{}", jstzd_port, key))
Expand Down
2 changes: 1 addition & 1 deletion crates/octez/src/async/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::process::{Child, Command};

const DEFAULT_BINARY_PATH: &str = "octez-smart-rollup-node";

#[derive(Clone, PartialEq, Debug, Deserialize)]
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub enum RollupDataDir {
/// Path to the rollup data directory. This directory
/// should contain the kernel pre image files under `wasm_2_0_0/`
Expand Down
Loading