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

feat: PocketIC supports force and shared network #4002

Merged
merged 3 commits into from
Nov 22, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# UNRELEASED

### feat: `dfx start --pocketic` supports `--force` and shared networks.

`dfx start --pocketic` is now compatible with `--force` and shared networks.

### feat: error when using insecure identity on mainnet

This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.
Expand Down
17 changes: 7 additions & 10 deletions src/dfx-core/src/config/model/settings_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ struct ReplicaSettings {
}

#[derive(Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", rename_all = "snake_case")]
enum BackendSettings<'a> {
Replica { settings: Cow<'a, ReplicaSettings> },
PocketIc,
struct BackendSettings<'a> {
settings: Cow<'a, ReplicaSettings>,
pocketic: bool,
}

#[derive(Serialize, Deserialize, PartialEq, Eq)]
Expand All @@ -60,11 +59,7 @@ pub fn get_settings_digest(
artificial_delay: u32,
pocketic: bool,
) -> String {
let backend = if pocketic {
BackendSettings::PocketIc
} else {
get_replica_backend_settings(local_server_descriptor, artificial_delay)
};
let backend = get_replica_backend_settings(local_server_descriptor, artificial_delay, pocketic);
let settings = Settings {
ic_repo_commit: ic_repo_commit.into(),
backend,
Expand All @@ -77,6 +72,7 @@ pub fn get_settings_digest(
fn get_replica_backend_settings(
local_server_descriptor: &LocalServerDescriptor,
artificial_delay: u32,
pocketic: bool,
) -> BackendSettings {
let http_handler = HttpHandlerSettings {
port: if let Some(port) = local_server_descriptor.replica.port {
Expand Down Expand Up @@ -105,7 +101,8 @@ fn get_replica_backend_settings(
.unwrap_or_default(),
artificial_delay,
};
BackendSettings::Replica {
BackendSettings {
settings: Cow::Owned(replica_settings),
pocketic,
}
}
4 changes: 2 additions & 2 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct StartOpts {
artificial_delay: u32,

/// Start even if the network config was modified.
#[arg(long, conflicts_with = "pocketic")]
#[arg(long)]
force: bool,

/// A list of domains that can be served. These are used for canister resolution [default: localhost]
Expand Down Expand Up @@ -338,7 +338,7 @@ pub fn exec(
&local_server_descriptor.scope,
LocalNetworkScopeDescriptor::Shared { .. }
);
if is_shared_network && !pocketic {
if is_shared_network {
save_json_file(
&local_server_descriptor.effective_config_path_by_settings_digest(),
&effective_config,
Expand Down
Loading