Skip to content

Commit

Permalink
fix: ensure dev flags enables dev api (#2901)
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm authored Jan 13, 2025
1 parent a5377ac commit 56e0bf3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/katana/cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
}
}
10 changes: 10 additions & 0 deletions crates/katana/rpc/rpc/tests/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 56e0bf3

Please sign in to comment.