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

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[workspace]
members = [
"src/dfx",
"src/ic_identity_manager",
]
3 changes: 1 addition & 2 deletions docs/process/release.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,10 @@ export NEW_DFX_VERSION=<n.n.n>
----
git switch -c $USER/release-$NEW_DFX_VERSION
----
. Update the `version` field for the following files:
. Update the `version` field in this file:
+
....
`src/dfx/Cargo.toml`
`src/ic_identity_manager/Cargo.toml`
....
. Apply these changes to `Cargo.lock` by running the following command:
+
Expand Down
9 changes: 8 additions & 1 deletion e2e/bats/assets/identity/identity.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import P "mo:base/Principal";
import Prim "mo:prim";

actor Self {
private let initializer : Principal = Prim.caller();

public shared(msg) func fromCall(): async Principal {
msg.caller
};
Expand All @@ -12,5 +15,9 @@ actor Self {
};
public query func isMyself(id: Principal) : async Bool {
id == P.fromActor(Self)
};
};

public shared query(msg) func amInitializer() : async Bool {
msg.caller == initializer
};
};
75 changes: 75 additions & 0 deletions e2e/bats/identity.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ setup() {
# We want to work from a temporary directory, different for every test.
cd $(mktemp -d -t dfx-e2e-XXXXXXXX)

# Each test gets its own home directory in order to have its own identities.
mkdir $(pwd)/home-for-test
export HOME=$(pwd)/home-for-test

dfx_new
}

teardown() {
dfx_stop
rm -rf $(pwd)/home-for-test
}

@test "calls and query receive the same principal from dfx" {
Expand All @@ -32,3 +37,73 @@ teardown() {
assert_command dfx canister call e2e_project isMyself "$ID_CALL"
assert_eq '(false)'
}

@test "dfx ping creates the default identity on first run" {
install_asset identity
dfx_start
assert_command dfx ping
assert_match 'Creating the "default" identity.' "$stderr"
assert_match "ic_api_version" "$stdout"
}

@test "dfx canister: creates the default identity on first run" {
install_asset identity
dfx_start
assert_command dfx canister create e2e_project
assert_match 'Creating the "default" identity.' "$stderr"
}

@test "after using a specific identity while creating a canister, that identity is the initializer" {
install_asset identity
dfx_start
assert_command dfx identity new alice
assert_command dfx identity new bob

dfx --identity alice canister create --all
assert_command dfx --identity alice build
assert_command dfx --identity alice canister install --all

assert_command dfx --identity alice canister call e2e_project amInitializer
assert_eq '(true)'

assert_command dfx --identity bob canister call e2e_project amInitializer
assert_eq '(false)'

# these all fail (other identities are not initializer; cannot store assets):
assert_command_fail dfx --identity bob canister call e2e_project_assets store '("B", vec { 88; 87; 86; })'
assert_command_fail dfx --identity default canister call e2e_project_assets store '("B", vec { 88; 87; 86; })'
assert_command_fail dfx canister call e2e_project_assets store '("B", vec { 88; 87; 86; })'
assert_command_fail dfx canister call e2e_project_assets retrieve '("B")'

# but alice, the initializer, can store assets:
assert_command dfx --identity alice canister call e2e_project_assets store '("B", vec { 88; 87; 86; })'
assert_eq '()'
assert_command dfx canister call e2e_project_assets retrieve '("B")'
assert_eq '(vec { 88; 87; 86; })'
}

@test "after renaming an identity, the renamed identity is still initializer" {
install_asset identity
dfx_start
assert_command dfx identity new alice

dfx --identity alice canister create --all
assert_command dfx --identity alice build
assert_command dfx --identity alice canister install --all
assert_command dfx --identity alice canister call e2e_project amInitializer
assert_eq '(true)'
assert_command dfx canister call e2e_project amInitializer
assert_eq '(false)'

assert_command dfx identity rename alice bob

assert_command dfx identity whoami
assert_eq 'default'
assert_command dfx --identity bob canister call e2e_project amInitializer
assert_eq '(true)'

assert_command dfx --identity bob canister call e2e_project_assets store '("B", vec { 40; 67; })'
assert_eq '()'
assert_command dfx canister call e2e_project_assets retrieve '("B")'
assert_eq '(vec { 40; 67; })'
}
Loading