From 88b862ce7dea4797b75687005224fc75eb2db0ae Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 12 Nov 2024 18:26:24 +0100 Subject: [PATCH 1/3] fix: dfx start --pocketic does not require --clean --- e2e/tests-dfx/start.bash | 4 ---- src/dfx-core/src/config/model/replica_config.rs | 3 ++- src/dfx/src/commands/start.rs | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/e2e/tests-dfx/start.bash b/e2e/tests-dfx/start.bash index 3b6fe8207c..b4952c88ed 100644 --- a/e2e/tests-dfx/start.bash +++ b/e2e/tests-dfx/start.bash @@ -22,7 +22,6 @@ teardown() { } @test "start and stop with different options" { - [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: clean required" dfx_start --artificial-delay 101 dfx_stop @@ -42,7 +41,6 @@ teardown() { } @test "stop and start with other options does not disrupt projects" { - [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: clean required" dfx_start --artificial-delay 101 dfx_new p1 @@ -457,7 +455,6 @@ teardown() { } @test "modifying networks.json does not require --clean on restart" { - [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: --force" dfx_start dfx stop assert_command dfx_start @@ -467,7 +464,6 @@ teardown() { } @test "project-local networks require --clean if dfx.json was updated" { - [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: --force" dfx_new define_project_network dfx_start diff --git a/src/dfx-core/src/config/model/replica_config.rs b/src/dfx-core/src/config/model/replica_config.rs index ed4164b56d..510f0420e3 100644 --- a/src/dfx-core/src/config/model/replica_config.rs +++ b/src/dfx-core/src/config/model/replica_config.rs @@ -222,7 +222,8 @@ impl<'a> CachedConfig<'a> { } } pub fn can_share_state(&self, other: &Self) -> bool { - self == other + // effective canister id does not matter for ability to share state + self.replica_rev == other.replica_rev && self.config == other.config } pub fn get_effective_canister_id(&self) -> Option { self.effective_canister_id diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index 4e556cbecd..08612d4b7d 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -332,7 +332,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, From 20b05dfeba0d1d4ab884aeed05162d7dcab4b7d1 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 12 Nov 2024 19:07:17 +0100 Subject: [PATCH 2/3] force --- src/dfx/src/commands/start.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index 08612d4b7d..28ac6c34e4 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -70,7 +70,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] From 4948c4e3388d8d6c3b9b9c884f459987e1a40874 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 12 Nov 2024 19:52:46 +0100 Subject: [PATCH 3/3] fix --- e2e/tests-dfx/start.bash | 12 ++++++++++++ src/dfx/src/commands/start.rs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/e2e/tests-dfx/start.bash b/e2e/tests-dfx/start.bash index b4952c88ed..a63d40ffa0 100644 --- a/e2e/tests-dfx/start.bash +++ b/e2e/tests-dfx/start.bash @@ -21,7 +21,16 @@ teardown() { assert_command diff "$NETWORK_ID_PATH" "$NETWORK_ID_BY_SETTINGS_DIGEST_PATH" } +@test "start and stop" { + dfx_start + dfx_stop + + dfx_start + dfx_stop +} + @test "start and stop with different options" { + [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: clean required" dfx_start --artificial-delay 101 dfx_stop @@ -41,6 +50,7 @@ teardown() { } @test "stop and start with other options does not disrupt projects" { + [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: clean required" dfx_start --artificial-delay 101 dfx_new p1 @@ -455,6 +465,7 @@ teardown() { } @test "modifying networks.json does not require --clean on restart" { + [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: --force" dfx_start dfx stop assert_command dfx_start @@ -464,6 +475,7 @@ teardown() { } @test "project-local networks require --clean if dfx.json was updated" { + [[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: --force" dfx_new define_project_network dfx_start diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index 28ac6c34e4..4e556cbecd 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -70,7 +70,7 @@ pub struct StartOpts { artificial_delay: u32, /// Start even if the network config was modified. - #[arg(long)] + #[arg(long, conflicts_with = "pocketic")] force: bool, /// A list of domains that can be served. These are used for canister resolution [default: localhost] @@ -332,7 +332,7 @@ pub fn exec( &local_server_descriptor.scope, LocalNetworkScopeDescriptor::Shared { .. } ); - if is_shared_network { + if is_shared_network && !pocketic { save_json_file( &local_server_descriptor.effective_config_path_by_settings_digest(), &effective_config,