From 78556b778ffbe5db23cdb0692aadeb7c14843fd8 Mon Sep 17 00:00:00 2001 From: eftychis Date: Thu, 26 Mar 2020 22:55:41 -0700 Subject: [PATCH] Add e2e for principal identifier used --- e2e/bats/assets/principal_id_mo/patch.bash | 1 + e2e/bats/assets/principal_id_mo/principal.mo | 5 ++++ e2e/bats/principal.bash | 28 ++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 e2e/bats/assets/principal_id_mo/patch.bash create mode 100644 e2e/bats/assets/principal_id_mo/principal.mo create mode 100644 e2e/bats/principal.bash diff --git a/e2e/bats/assets/principal_id_mo/patch.bash b/e2e/bats/assets/principal_id_mo/patch.bash new file mode 100644 index 0000000000..07a4dacd37 --- /dev/null +++ b/e2e/bats/assets/principal_id_mo/patch.bash @@ -0,0 +1 @@ +dfx config canisters/e2e_project/main principal.mo diff --git a/e2e/bats/assets/principal_id_mo/principal.mo b/e2e/bats/assets/principal_id_mo/principal.mo new file mode 100644 index 0000000000..91219e5f49 --- /dev/null +++ b/e2e/bats/assets/principal_id_mo/principal.mo @@ -0,0 +1,5 @@ +actor PrincipalId { + public shared(ctx) func get_principal_id() : async [Word32] { + ctx.caller + }; +} diff --git a/e2e/bats/principal.bash b/e2e/bats/principal.bash new file mode 100644 index 0000000000..a8639b7994 --- /dev/null +++ b/e2e/bats/principal.bash @@ -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" +}