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
1 change: 1 addition & 0 deletions e2e/bats/assets/principal_id_mo/patch.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dfx config canisters/e2e_project/main principal.mo
5 changes: 5 additions & 0 deletions e2e/bats/assets/principal_id_mo/principal.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
actor PrincipalId {
public shared(ctx) func get_principal_id() : async [Word32] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type is async Principal

ctx.caller
};
}
28 changes: 28 additions & 0 deletions e2e/bats/principal.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bats

load utils/_

setup() {
# We want to work from a temporary directory, different for every test.
cd $(mktemp -d -t dfx-e2e-XXXXXXXX)
export RUST_BACKTRACE=1

dfx_new
}

teardown() {
dfx_stop
}

@test "Provides same principal identifier as sender" {
install_asset pricipal_id_mo
dfx build
dfx start --background
dfx canister install --all

assert_command dfx canister -p call e2e_project get_principal_id
assert_match "0"
# Second time must be the same.
assert_command dfx canister -p call e2e_project get_principal_id
assert_match "0"
}