From 56e0bf3616807e795d77a37db209f9e50edd94cc Mon Sep 17 00:00:00 2001 From: glihm Date: Mon, 13 Jan 2025 10:09:03 -0600 Subject: [PATCH] fix: ensure dev flags enables dev api (#2901) --- crates/katana/cli/src/args.rs | 17 ++++++++++++++++- crates/katana/rpc/rpc/tests/dev.rs | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/katana/cli/src/args.rs b/crates/katana/cli/src/args.rs index 27a0ddde71..44c146d388 100644 --- a/crates/katana/cli/src/args.rs +++ b/crates/katana/cli/src/args.rs @@ -216,7 +216,14 @@ impl NodeArgs { modules.clone() } else { // Expose the default modules if none is specified. - RpcModulesList::default() + let mut modules = RpcModulesList::default(); + + // Ensures the `--dev` flag enabled the dev module. + if self.development.dev { + modules.add(RpcModuleKind::Dev); + } + + modules }; Ok(RpcConfig { @@ -673,4 +680,12 @@ chain_id.Named = "Mainnet" .contains("The `dev` module can only be enabled in dev mode (ie `--dev` flag)") ); } + + #[test] + fn test_dev_api_enabled() { + let args = NodeArgs::parse_from(["katana", "--dev"]); + let config = args.config().unwrap(); + + assert!(config.rpc.apis.contains(&RpcModuleKind::Dev)); + } } diff --git a/crates/katana/rpc/rpc/tests/dev.rs b/crates/katana/rpc/rpc/tests/dev.rs index 8b53f42c4a..4708e19326 100644 --- a/crates/katana/rpc/rpc/tests/dev.rs +++ b/crates/katana/rpc/rpc/tests/dev.rs @@ -99,6 +99,16 @@ async fn test_increase_next_block_timestamp() { ); } +#[tokio::test] +async fn test_dev_api_enabled() { + let sequencer = create_test_sequencer().await; + + let client = HttpClientBuilder::default().build(sequencer.url()).unwrap(); + + let accounts = client.predeployed_accounts().await.unwrap(); + assert!(!accounts.is_empty(), "predeployed accounts should not be empty"); +} + // #[tokio::test] // async fn test_set_storage_at_on_instant_mode() { // let sequencer = create_test_sequencer().await;