Skip to content
Closed
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
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ members = [

[patch.crates-io.ic-agent]
version = "0.1.0"
#path = "../agent-rs/ic-agent"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"

[patch.crates-io.ic-types]
version = "0.1.2"
#path = "../agent-rs/ic-types"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"

[patch.crates-io.ic-utils]
version = "0.1.0"
#path = "../agent-rs/ic-utils"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"
17 changes: 9 additions & 8 deletions e2e/bats/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ teardown() {
dfx_start

webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
assert_command dfx canister --network ic create --all
assert_command dfx build --network ic
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json

assert_command dfx canister --network actuallylocal create --all
assert_command dfx build --network actuallylocal
}

@test "build output for local network is in expected directory" {
Expand All @@ -110,10 +111,10 @@ teardown() {
@test "build output for non-local network is in expected directory" {
dfx_start
webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
dfx canister --network ic create --all
assert_command dfx build --network ic
assert_command ls .dfx/ic/canisters/e2e_project/
assert_command ls .dfx/ic/canisters/e2e_project/e2e_project.wasm
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json
dfx canister --network actuallylocal create --all
assert_command dfx build --network actuallylocal
assert_command ls .dfx/actuallylocal/canisters/e2e_project/
assert_command ls .dfx/actuallylocal/canisters/e2e_project/e2e_project.wasm
}

11 changes: 6 additions & 5 deletions e2e/bats/create.bash
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@ teardown() {
dfx_start

webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
assert_command dfx canister --network ic create --all
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json
assert_command dfx canister --network actuallylocal create --all
}

@test "create fails if selected network exists but has no providers" {
dfx_start

assert_command dfx config networks.ic.providers '[ ]'
assert_command_fail dfx canister --network ic create --all
cat <<<$(jq .networks.actuallylocal.providers=[] dfx.json) >dfx.json
assert_command_fail dfx canister --network actuallylocal create --all
assert_match "ComputeNetworkHasNoProviders"
}

@test "create fails with network parameter when network does not exist" {
dfx_start
assert_command dfx config networks.ic.providers '[ "http://not-real.nowhere.test." ]'
assert_command_fail dfx canister --network ic create --all
cat <<<$(jq .networks.actuallylocal.providers=[\"http://not-real.nowhere.test.\"] dfx.json) >dfx.json
assert_command_fail dfx canister --network actuallylocal create --all
assert_match "ConnectError"
}
24 changes: 12 additions & 12 deletions e2e/bats/network.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ teardown() {
dfx_start

webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json

assert_command dfx canister --network ic create --all
assert_command dfx canister --network actuallylocal create --all

# canister creates writes to a spinner (stderr), not stdout
assert_command dfx canister --network ic id e2e_project
assert_match $(cat canister_ids.json | jq -r .e2e_project.ic)
assert_command dfx canister --network actuallylocal id e2e_project
assert_match $(cat canister_ids.json | jq -r .e2e_project.actuallylocal)
}

@test "create stores canister ids for configured-ephemeral networks in canister_ids.json" {
dfx_start

webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
cat <<<$(jq .networks.ic.type=\"ephemeral\" dfx.json) >dfx.json
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json
cat <<<$(jq .networks.actuallylocal.type=\"ephemeral\" dfx.json) >dfx.json

assert_command dfx canister --network ic create --all
assert_command dfx canister --network actuallylocal create --all

# canister creates writes to a spinner (stderr), not stdout
assert_command dfx canister --network ic id e2e_project
assert_match $(cat .dfx/ic/canister_ids.json | jq -r .e2e_project.ic)
assert_command dfx canister --network actuallylocal id e2e_project
assert_match $(cat .dfx/actuallylocal/canister_ids.json | jq -r .e2e_project.actuallylocal)
}

@test "create stores canister ids for default-ephemeral local networks in .dfx/{network}canister_ids.json" {
Expand Down Expand Up @@ -74,8 +74,8 @@ teardown() {
dfx_start

webserver_port=$(cat .dfx/webserver-port)
assert_command dfx config networks.ic.providers '[ "http://127.0.0.1:'$webserver_port'" ]'
cat <<<$(jq .networks.actuallylocal.providers=[\"http://127.0.0.1:$webserver_port\"] dfx.json) >dfx.json

assert_command_fail dfx build --network ic
assert_match "Cannot find canister id. Please issue 'dfx canister --network ic create e2e_project"
assert_command_fail dfx build --network actuallylocal
assert_match "Cannot find canister id. Please issue 'dfx canister --network actuallylocal create e2e_project"
}
2 changes: 1 addition & 1 deletion nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dfinity": {
"branch": "master",
"repo": "ssh://git@github.com/dfinity-lab/dfinity",
"rev": "482ba09bfa3a0ac41209684e947e83b8e0c83138",
"rev": "19da081c7fb438f10b25abcb7fee0796ec79ad7b",
"type": "git"
},
"ic-ref": {
Expand Down
15 changes: 9 additions & 6 deletions src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,24 @@ wasmparser = "0.45.0"

[dependencies.ic-agent]
version = "0.1.0"
#path = "../../../agent-rs/ic-agent"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"

[dependencies.ic-types]
version = "0.1.2"
#path = "../../../agent-rs/ic-types"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"

[dependencies.ic-utils]
version = "0.1.0"
#path = "../../../agent-rs/ic-utils"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
branch = "es-wip-resp-auth"
rev = "d8d2649ad0e4e8bb5328d5e97b6705c5275afe7a"

[dev-dependencies]
env_logger = "0.6"
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::lib::canister_info::CanisterInfo;
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::{blob_from_arguments, expiry_duration, get_candid_type, print_idl_blob};
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -110,6 +111,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
.ok_or(DfxError::CommandMustBeRunInAProject)?;
let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

let timeout = expiry_duration();

if is_query {
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/create.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::operations::canister::create_canister;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -32,6 +33,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {

let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

if let Some(canister_name) = opts.canister_name {
runtime.block_on(create_canister(env, canister_name.as_str(), timeout))?;
Ok(())
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/delete.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -67,6 +68,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {

let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

if let Some(canister_name) = opts.canister_name.as_deref() {
runtime.block_on(delete_canister(env, &agent, canister_name, timeout))?;
Ok(())
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::operations::canister::install_canister;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::clap::validators::{compute_allocation_validator, memory_allocation_validator};
use crate::util::{blob_from_arguments, expiry_duration, get_candid_init_type};
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -99,6 +100,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {

let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

let canister_id_store = CanisterIdStore::for_env(env)?;

if let Some(canister_name) = opts.canister_name.as_deref() {
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/request_status.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::clap::validators;
use crate::util::{expiry_duration, print_idl_blob};
Expand Down Expand Up @@ -34,6 +35,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
.ok_or(DfxError::CommandMustBeRunInAProject)?;
let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

let timeout = expiry_duration();

let mut waiter = waiter_with_timeout(timeout);
Expand Down
2 changes: 2 additions & 0 deletions src/dfx/src/commands/canister/set_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::identity::identity_manager::IdentityManager;
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -49,6 +50,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
);

let mut runtime = Runtime::new().expect("Unable to create a runtime");
runtime.block_on(fetch_root_key_if_needed(env))?;
runtime.block_on(
mgr.set_controller(&canister_id, &controller_principal)
.call_and_wait(waiter_with_timeout(timeout)),
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/start.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -64,6 +65,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {

let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

let timeout = expiry_duration();

if let Some(canister_name) = opts.canister_name.as_deref() {
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/status.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -59,6 +60,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {

let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;

let timeout = expiry_duration();

if let Some(canister_name) = opts.canister_name.as_deref() {
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/canister/stop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::waiter::waiter_with_timeout;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
Expand Down Expand Up @@ -63,6 +64,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
.ok_or(DfxError::CommandMustBeRunInAProject)?;

let mut runtime = Runtime::new().expect("Unable to create a runtime");
runtime.block_on(fetch_root_key_if_needed(env))?;

let timeout = expiry_duration();

if let Some(canister_name) = opts.canister_name.as_deref() {
Expand Down
2 changes: 2 additions & 0 deletions src/dfx/src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::operations::canister::deploy_canisters;
use crate::lib::provider::create_agent_environment;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::expiry_duration;
use clap::{App, ArgMatches, Clap, FromArgMatches, IntoApp};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -41,6 +42,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches) -> DfxResult {
let argument_type = opts.argument_type.as_deref();

let mut runtime = Runtime::new().expect("Unable to create a runtime");
runtime.block_on(fetch_root_key_if_needed(&env))?;

runtime.block_on(deploy_canisters(
&env,
Expand Down
1 change: 1 addition & 0 deletions src/dfx/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ pub mod package_arguments;
pub mod progress_bar;
pub mod provider;
pub mod replica_config;
pub mod root_key;
pub mod waiter;
pub mod webserver;
Loading