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: replica-port returns webserver port for pocketic #4053

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion e2e/tests-dfx/info.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ teardown() {
assert_command dfx info replica-port
if [[ "$USE_POCKETIC" ]]
then
assert_eq "$(get_pocketic_port)"
assert_eq "$(get_webserver_port)"
else
assert_eq "$(get_replica_port)"
fi
Expand Down
1 change: 1 addition & 0 deletions e2e/tests-dfx/start.bash
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ teardown() {
}

@test "dfx start honors replica port configuration" {
[[ "$USE_POCKETIC" ]] && skip 'skipped for pocketic: real replica port'
create_networks_json
replica_port=$(get_ephemeral_port)
jq ".local.replica.port=$replica_port" "$E2E_NETWORKS_JSON" | sponge "$E2E_NETWORKS_JSON"
Expand Down
12 changes: 11 additions & 1 deletion src/dfx/src/commands/info/replica_port.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::lib::error::DfxResult;
use crate::Environment;
use anyhow::bail;
use dfx_core::network::provider::{create_network_descriptor, LocalBindDetermination};
use dfx_core::{
config::model::replica_config::CachedReplicaConfig,
network::provider::{create_network_descriptor, LocalBindDetermination},
};

pub(crate) fn get_replica_port(env: &dyn Environment) -> DfxResult<String> {
let network_descriptor = create_network_descriptor(
Expand All @@ -11,6 +14,13 @@ pub(crate) fn get_replica_port(env: &dyn Environment) -> DfxResult<String> {
None,
LocalBindDetermination::AsConfigured,
)?;
if let Some(l) = &network_descriptor.local_server_descriptor {
if l.effective_config()?
.is_some_and(|c| matches!(c.config, CachedReplicaConfig::PocketIc { .. }))
{
return super::get_webserver_port(env);
}
}

let logger = None;
if let Some(port) = network_descriptor
Expand Down
Loading