Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: standardize indentation for e2e test scripts #3390

Merged
merged 2 commits into from
Sep 26, 2023
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
1,402 changes: 701 additions & 701 deletions e2e/tests-dfx/assetscanister.bash

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions e2e/tests-dfx/base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
load ../utils/_

setup() {
standard_setup
standard_setup

dfx_new
dfx_new
}

teardown() {
dfx_stop
dfx_stop

standard_teardown
standard_teardown
}

@test "provides base library location by default" {
install_asset base
install_asset base

dfx_start
dfx canister create --all
dfx build
dfx canister install e2e_project_backend
dfx_start
dfx canister create --all
dfx build
dfx canister install e2e_project_backend

assert_command dfx canister call --query e2e_project_backend is_digit '("5")'
assert_eq '(true)'
assert_command dfx canister call --query e2e_project_backend is_digit '("5")'
assert_eq '(true)'

assert_command dfx canister call --query e2e_project_backend is_digit '("w")'
assert_eq '(false)'
assert_command dfx canister call --query e2e_project_backend is_digit '("w")'
assert_eq '(false)'
}

@test "does not provide base library if there is a packtool" {
install_asset base
jq '.defaults.build.packtool="echo"' dfx.json | sponge dfx.json
install_asset base
jq '.defaults.build.packtool="echo"' dfx.json | sponge dfx.json

dfx_start
dfx canister create --all
assert_command_fail dfx build
assert_match 'import error \[M0010\], package "base" not defined'
dfx_start
dfx canister create --all
assert_command_fail dfx build
assert_match 'import error \[M0010\], package "base" not defined'
}
206 changes: 103 additions & 103 deletions e2e/tests-dfx/basic-project.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@
load ../utils/_

setup() {
standard_setup
standard_setup
}

teardown() {
dfx_stop
dfx_stop

standard_teardown
standard_teardown
}

@test "build + install + call + request-status -- greet_mo" {
dfx_new hello
install_asset greet
dfx_start
dfx canister create --all
dfx build
# INSTALL_REQUEST_ID=$(dfx canister install hello_backend --async)
# dfx canister request-status $INSTALL_REQUEST_ID
dfx canister install hello_backend

assert_command dfx canister call hello_backend greet '("Banzai")'
assert_eq '("Hello, Banzai!")'

assert_command dfx canister call hello_backend greet --type raw '4449444c00017103e29883'
assert_eq '("Hello, ☃!")'

assert_command dfx canister call --query hello_backend greet '("Bongalo")'
assert_eq '("Hello, Bongalo!")'

# Using call --async and request-status.
# Call with user Identity as Sender
assert_command dfx canister call --async hello_backend greet Blueberry
# At this point $output is the request ID.
# shellcheck disable=SC2154
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"
assert_eq '("Hello, Blueberry!")'

# Call using the wallet's call forwarding
assert_command dfx canister call --async hello_backend greet Blueberry --wallet="$(dfx identity get-wallet)"
# At this point $output is the request ID.
# shellcheck disable=SC2154
assert_command dfx canister request-status "$stdout" "$(dfx identity get-wallet)"
assert_eq \
dfx_new hello
install_asset greet
dfx_start
dfx canister create --all
dfx build
# INSTALL_REQUEST_ID=$(dfx canister install hello_backend --async)
# dfx canister request-status $INSTALL_REQUEST_ID
dfx canister install hello_backend

assert_command dfx canister call hello_backend greet '("Banzai")'
assert_eq '("Hello, Banzai!")'

assert_command dfx canister call hello_backend greet --type raw '4449444c00017103e29883'
assert_eq '("Hello, ☃!")'

assert_command dfx canister call --query hello_backend greet '("Bongalo")'
assert_eq '("Hello, Bongalo!")'

# Using call --async and request-status.
# Call with user Identity as Sender
assert_command dfx canister call --async hello_backend greet Blueberry
# At this point $output is the request ID.
# shellcheck disable=SC2154
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"
assert_eq '("Hello, Blueberry!")'

# Call using the wallet's call forwarding
assert_command dfx canister call --async hello_backend greet Blueberry --wallet="$(dfx identity get-wallet)"
# At this point $output is the request ID.
# shellcheck disable=SC2154
assert_command dfx canister request-status "$stdout" "$(dfx identity get-wallet)"
assert_eq \
'(
variant {
17_724 = record { 153_986_224 = blob "DIDL\00\01q\11Hello, Blueberry!" }
Expand All @@ -53,79 +53,79 @@ teardown() {
}

@test "build + install + call + request-status -- counter_mo" {
dfx_new hello
install_asset counter
dfx_start
dfx canister create --all
dfx build
dfx canister install hello_backend
dfx_new hello
install_asset counter
dfx_start
dfx canister create --all
dfx build
dfx canister install hello_backend

assert_command dfx canister call hello_backend read
assert_eq "(0 : nat)"
assert_command dfx canister call hello_backend read
assert_eq "(0 : nat)"

assert_command dfx canister call hello_backend inc
assert_eq "()"
assert_command dfx canister call hello_backend inc
assert_eq "()"

assert_command dfx canister call hello_backend read
assert_eq "(1 : nat)"
assert_command dfx canister call hello_backend read
assert_eq "(1 : nat)"

dfx canister call hello_backend inc
assert_command dfx canister call hello_backend read
assert_eq "(2 : nat)"
dfx canister call hello_backend inc
assert_command dfx canister call hello_backend read
assert_eq "(2 : nat)"

assert_command dfx canister call hello_backend read --output raw
assert_eq "4449444c00017d02"
assert_command dfx canister call hello_backend read --output raw
assert_eq "4449444c00017d02"

assert_command_fail dfx canister call --query hello_backend inc
assert_match "Not a query method."
assert_command_fail dfx canister call --query hello_backend inc
assert_match "Not a query method."


dfx canister call hello_backend inc
assert_command dfx canister call --query hello_backend read
assert_eq "(3 : nat)"
dfx canister call hello_backend inc
assert_command dfx canister call --query hello_backend read
assert_eq "(3 : nat)"

assert_command dfx canister call hello_backend inc --async
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"
assert_command dfx canister call hello_backend inc --async
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"

# Call write.
assert_command dfx canister call hello_backend write 1337
assert_eq "()"
# Call write.
assert_command dfx canister call hello_backend write 1337
assert_eq "()"

# Write has no return value. But we can _call_ read too.
# Call with user Identity as Sender
assert_command dfx canister call hello_backend read --async
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"
assert_eq "(1_337 : nat)"
# Write has no return value. But we can _call_ read too.
# Call with user Identity as Sender
assert_command dfx canister call hello_backend read --async
assert_command dfx canister request-status "$stdout" "$(dfx canister id hello_backend)"
assert_eq "(1_337 : nat)"

# Call using the wallet's call forwarding
assert_command dfx canister call hello_backend read --async --wallet="$(dfx identity get-wallet)"
assert_command dfx canister request-status "$stdout" "$(dfx identity get-wallet)"
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01}\b9\0a" } })'
# Call using the wallet's call forwarding
assert_command dfx canister call hello_backend read --async --wallet="$(dfx identity get-wallet)"
assert_command dfx canister request-status "$stdout" "$(dfx identity get-wallet)"
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01}\b9\0a" } })'

}

@test "build + install + call -- counter_idl_mo" {
dfx_new hello
install_asset counter_idl
dfx_start
dfx canister create --all
dfx build
dfx canister install --all

assert_command dfx canister call hello_backend inc '(42,false,"testzZ",vec{1;2;3},opt record{head=42; tail=opt record{head=+43; tail=null}}, variant { cons=record{ 42; variant { cons=record{43; variant { nil }} } } })' --output idl
assert_eq "(43 : int, true, \"uftu{[\", vec { 2 : nat; 3 : nat; 4 : nat;}, opt record { head = 43 : int; tail = opt record { head = 44 : int; tail = null;};}, variant { cons = record { 43 : int; variant { cons = record { 44 : int; variant { nil };} };} })"
dfx_new hello
install_asset counter_idl
dfx_start
dfx canister create --all
dfx build
dfx canister install --all

assert_command dfx canister call hello_backend inc '(42,false,"testzZ",vec{1;2;3},opt record{head=42; tail=opt record{head=+43; tail=null}}, variant { cons=record{ 42; variant { cons=record{43; variant { nil }} } } })' --output idl
assert_eq "(43 : int, true, \"uftu{[\", vec { 2 : nat; 3 : nat; 4 : nat;}, opt record { head = 43 : int; tail = opt record { head = 44 : int; tail = null;};}, variant { cons = record { 43 : int; variant { cons = record { 44 : int; variant { nil };} };} })"
}

@test "build + install + call -- matrix_multiply_mo" {
dfx_new hello
install_asset matrix_multiply
dfx_start
dfx canister create --all
dfx build
dfx canister install --all

assert_command dfx canister call hello_backend multiply '(vec{vec{1;2};vec{3;4};vec{5;6}},vec{vec{1;2;3};vec{4;5;6}})'
assert_eq \
dfx_new hello
install_asset matrix_multiply
dfx_start
dfx canister create --all
dfx build
dfx canister install --all

assert_command dfx canister call hello_backend multiply '(vec{vec{1;2};vec{3;4};vec{5;6}},vec{vec{1;2;3};vec{4;5;6}})'
assert_eq \
"(
vec {
vec { 9 : int; 12 : int; 15 : int };
Expand All @@ -136,27 +136,27 @@ teardown() {
}

@test "inspect message - motoko" {
dfx_new hello
install_asset inspect_message
dfx_start
dfx deploy
dfx_new hello
install_asset inspect_message
dfx_start
dfx deploy

assert_command dfx canister call hello_backend always_accepted
assert_command dfx canister call hello_backend always_accepted

assert_command_fail dfx canister call hello_backend always_rejected
assert_contains "canister_inspect_message explicitly refused message"
assert_command_fail dfx canister call hello_backend always_rejected
assert_contains "canister_inspect_message explicitly refused message"
}

@test "inspect message - rust" {
dfx_new_rust hello
dfx_new_rust hello

install_asset inspect_message_rs
install_asset inspect_message_rs

dfx_start
dfx deploy
dfx_start
dfx deploy

assert_command dfx canister call hello_backend always_accepted
assert_command dfx canister call hello_backend always_accepted

assert_command_fail dfx canister call hello_backend always_rejected
assert_contains "Canister $(dfx canister id hello_backend) rejected the message"
assert_command_fail dfx canister call hello_backend always_rejected
assert_contains "Canister $(dfx canister id hello_backend) rejected the message"
}
Loading
Loading