diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index eedec9aa..99cf4b61 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -11,7 +11,7 @@ Library for automating workflows and testing NEAR smart contracts. [dependencies] async-trait = "0.1" -async-process = { version = "1.3", optional = true } +async-process = "1.3" base64 = "0.13" borsh = "0.9" cargo_metadata = { version = "0.14.2", optional = true } @@ -54,7 +54,7 @@ tracing-subscriber = { version = "0.3.5", features = ["env-filter"] } [features] default = ["install"] install = [] # Install the sandbox binary during compile time -unstable = ["cargo_metadata", "async-process"] +unstable = ["cargo_metadata"] [package.metadata.docs.rs] features = ["unstable"] \ No newline at end of file diff --git a/workspaces/src/network/sandbox.rs b/workspaces/src/network/sandbox.rs index d57f3820..22e0b058 100644 --- a/workspaces/src/network/sandbox.rs +++ b/workspaces/src/network/sandbox.rs @@ -47,7 +47,7 @@ impl Sandbox { pub(crate) async fn new() -> Result { let mut server = SandboxServer::default(); - server.start()?; + server.start().await?; let client = Client::new(&server.rpc_addr()); client.wait_for_rpc().await?; diff --git a/workspaces/src/network/server.rs b/workspaces/src/network/server.rs index 769d89b5..85393d09 100644 --- a/workspaces/src/network/server.rs +++ b/workspaces/src/network/server.rs @@ -1,15 +1,12 @@ -use std::process::Child; - use crate::error::SandboxErrorCode; use crate::network::Sandbox; use crate::result::Result; +use async_process::Child; use portpicker::pick_unused_port; use tracing::info; -// TODO: swap over the async version of this in the future. Won't be a breaking API -// since we already have async marked in the functions that we are exposing. -use near_sandbox_utils::sync as sandbox; +use near_sandbox_utils as sandbox; pub struct SandboxServer { pub(crate) rpc_port: u16, @@ -26,7 +23,7 @@ impl SandboxServer { } } - pub fn start(&mut self) -> Result<()> { + pub async fn start(&mut self) -> Result<()> { if self.process.is_some() { return Err(SandboxErrorCode::AlreadyStarted.into()); } @@ -39,10 +36,12 @@ impl SandboxServer { // Remove dir if it already exists: let _ = std::fs::remove_dir_all(&home_dir); - sandbox::init(&home_dir) + let output = sandbox::init(&home_dir) .map_err(|e| SandboxErrorCode::InitFailure.custom(e))? - .wait() + .output() + .await .map_err(|e| SandboxErrorCode::InitFailure.custom(e))?; + info!(target: "workspaces", "sandbox init: {:?}", output); let child = sandbox::run(&home_dir, self.rpc_port, self.net_port) .map_err(|e| SandboxErrorCode::RunFailure.custom(e))?;