Skip to content

Commit 74b110a

Browse files
authored
feat: PocketIC supports force and shared network (#4002)
1 parent 8cb62ce commit 74b110a

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# UNRELEASED
44

5+
### feat: `dfx start --pocketic` supports `--force` and shared networks.
6+
7+
`dfx start --pocketic` is now compatible with `--force` and shared networks.
8+
59
### feat: error when using insecure identity on mainnet
610

711
This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.

src/dfx-core/src/config/model/settings_digest.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ struct ReplicaSettings {
4141
}
4242

4343
#[derive(Serialize, Deserialize, PartialEq, Eq)]
44-
#[serde(tag = "type", rename_all = "snake_case")]
45-
enum BackendSettings<'a> {
46-
Replica { settings: Cow<'a, ReplicaSettings> },
47-
PocketIc,
44+
struct BackendSettings<'a> {
45+
settings: Cow<'a, ReplicaSettings>,
46+
pocketic: bool,
4847
}
4948

5049
#[derive(Serialize, Deserialize, PartialEq, Eq)]
@@ -60,11 +59,7 @@ pub fn get_settings_digest(
6059
artificial_delay: u32,
6160
pocketic: bool,
6261
) -> String {
63-
let backend = if pocketic {
64-
BackendSettings::PocketIc
65-
} else {
66-
get_replica_backend_settings(local_server_descriptor, artificial_delay)
67-
};
62+
let backend = get_replica_backend_settings(local_server_descriptor, artificial_delay, pocketic);
6863
let settings = Settings {
6964
ic_repo_commit: ic_repo_commit.into(),
7065
backend,
@@ -77,6 +72,7 @@ pub fn get_settings_digest(
7772
fn get_replica_backend_settings(
7873
local_server_descriptor: &LocalServerDescriptor,
7974
artificial_delay: u32,
75+
pocketic: bool,
8076
) -> BackendSettings {
8177
let http_handler = HttpHandlerSettings {
8278
port: if let Some(port) = local_server_descriptor.replica.port {
@@ -105,7 +101,8 @@ fn get_replica_backend_settings(
105101
.unwrap_or_default(),
106102
artificial_delay,
107103
};
108-
BackendSettings::Replica {
104+
BackendSettings {
109105
settings: Cow::Owned(replica_settings),
106+
pocketic,
110107
}
111108
}

src/dfx/src/commands/start.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct StartOpts {
7575
artificial_delay: u32,
7676

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

8181
/// A list of domains that can be served. These are used for canister resolution [default: localhost]
@@ -338,7 +338,7 @@ pub fn exec(
338338
&local_server_descriptor.scope,
339339
LocalNetworkScopeDescriptor::Shared { .. }
340340
);
341-
if is_shared_network && !pocketic {
341+
if is_shared_network {
342342
save_json_file(
343343
&local_server_descriptor.effective_config_path_by_settings_digest(),
344344
&effective_config,

0 commit comments

Comments
 (0)