Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 2 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"type": "git"
},
"dfinity": {
"ref": "v0.5.2",
"ref": "v0.5.4",
"repo": "ssh://git@github.com/dfinity-lab/dfinity",
"rev": "a847ecc0bb8a1893f2cfb8d26dd31d69cb019eb6",
"rev": "a77551d2c630c2f30d18860bfb556ce46a0e8b08",
"type": "git"
},
"motoko": {
Expand Down
8 changes: 4 additions & 4 deletions src/dfx/src/actors/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Replica {
"Replica Configuration (TOML):\n-----\n{}-----\n", config_toml
);

let use_port = config.http_handler.use_port;
let port = config.http_handler.port;
let write_port_to = config.http_handler.write_port_to.clone();
let replica_path = self.config.replica_path.to_path_buf();

Expand All @@ -123,7 +123,7 @@ impl Replica {
let handle = replica_start_thread(
logger,
config_toml,
use_port,
port,
write_port_to,
replica_path,
addr,
Expand Down Expand Up @@ -216,7 +216,7 @@ fn wait_for_child_or_receiver(
fn replica_start_thread(
logger: Logger,
config_toml: String,
use_port: Option<u16>,
port: Option<u16>,
write_port_to: Option<PathBuf>,
replica_path: PathBuf,
addr: Addr<Replica>,
Expand Down Expand Up @@ -246,7 +246,7 @@ fn replica_start_thread(
debug!(logger, "Starting replica...");
let mut child = cmd.spawn().expect("Could not start replica.");

let port = use_port.unwrap_or_else(|| {
let port = port.unwrap_or_else(|| {
Replica::wait_for_port_file(write_port_to.as_ref().unwrap()).unwrap()
});
addr.do_send(signals::ReplicaRestarted { port });
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn get_config(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult<Replica
let file = env.get_temp_dir().join("config").join("port.txt");
http_handler.write_port_to = Some(file);
} else {
http_handler.use_port = Some(port);
http_handler.port = Some(port);
};
let message_gas_limit = get_message_gas_limit(&config, args)?;
let round_gas_limit = get_round_gas_limit(&config, args)?;
Expand Down
8 changes: 4 additions & 4 deletions src/dfx/src/lib/replica_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct HttpHandlerConfig {
/// Instructs the HTTP handler to use the specified port
pub use_port: Option<u16>,
pub port: Option<u16>,

/// Instructs the HTTP handler to bind to any open port and report the port
/// to the specified file.
Expand Down Expand Up @@ -62,7 +62,7 @@ impl ReplicaConfig {
ReplicaConfig {
http_handler: HttpHandlerConfig {
write_port_to: None,
use_port: None,
port: None,
},
scheduler: SchedulerConfig {
exec_gas: None,
Expand All @@ -82,13 +82,13 @@ impl ReplicaConfig {

#[allow(dead_code)]
pub fn with_port(&mut self, port: u16) -> &mut Self {
self.http_handler.use_port = Some(port);
self.http_handler.port = Some(port);
self.http_handler.write_port_to = None;
self
}

pub fn with_random_port(&mut self, write_port_to: &Path) -> &mut Self {
self.http_handler.use_port = None;
self.http_handler.port = None;
self.http_handler.write_port_to = Some(write_port_to.to_path_buf());
self
}
Expand Down
6 changes: 3 additions & 3 deletions src/ic_http_agent/src/agent/agent_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fn install() -> Result<(), AgentError> {

#[test]
fn ping() -> Result<(), AgentError> {
let read_mock = mock("GET", "/api/v1/read").with_status(200).create();
let read_mock = mock("GET", "/api/v1/status").with_status(200).create();

let agent = Agent::new(AgentConfig {
url: &mockito::server_url(),
Expand All @@ -260,7 +260,7 @@ fn ping() -> Result<(), AgentError> {

#[test]
fn ping_okay() -> Result<(), AgentError> {
let read_mock = mock("GET", "/api/v1/read").with_status(405).create();
let read_mock = mock("GET", "/api/v1/status").with_status(200).create();

let agent = Agent::new(AgentConfig {
url: &mockito::server_url(),
Expand All @@ -284,7 +284,7 @@ fn ping_okay() -> Result<(), AgentError> {
fn ping_error() -> Result<(), AgentError> {
// This mock is never asserted as we don't know (nor do we need to know) how many times
// it is called.
let _read_mock = mock("GET", "/api/v1/read").with_status(500).create();
let _read_mock = mock("GET", "/api/v1/status").with_status(500).create();

let agent = Agent::new(AgentConfig {
url: &mockito::server_url(),
Expand Down
8 changes: 5 additions & 3 deletions src/ic_http_agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ impl Agent {
where
A: serde::de::DeserializeOwned,
{
let record = serde_cbor::to_vec(&request)?;
let request = Request::Query(request);
let (_, signed_request) = self.signer.sign(request)?;
let record = serde_cbor::to_vec(&signed_request)?;
let url = self.url.join("read")?;

let mut http_request = reqwest::Request::new(Method::POST, url);
Expand Down Expand Up @@ -225,11 +227,11 @@ impl Agent {
}

pub async fn ping_once(&self) -> Result<(), AgentError> {
let url = self.url.join("read")?;
let url = self.url.join("status")?;
let http_request = reqwest::Request::new(Method::GET, url);
let response = self.client.execute(http_request).await?;

Comment thread
ninegua marked this conversation as resolved.
if response.status().as_u16() == 405 {
if response.status().as_u16() == 200 {
Ok(())
} else {
// Verify the error is 2XX.
Expand Down
2 changes: 1 addition & 1 deletion src/ic_http_agent/src/agent/replica_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct MessageWithSender<T: Serialize> {
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "snake_case")]
pub struct SignedMessage<'a> {
#[serde(flatten)]
#[serde(rename = "content")]
pub request_with_sender: Request<'a>,
pub sender_pubkey: Blob,
#[serde(rename = "sender_sig")]
Expand Down