Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Jan 17, 2024
1 parent eb99867 commit b50d9b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
9 changes: 4 additions & 5 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -884,13 +884,12 @@ check_permission_failure() {

assert_command dfx canister call --query e2e_project_frontend get '(record{key="/text-with-newlines.txt";accept_encodings=vec{"identity"}})'

assert_command dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 243; 191; 114; 177; 83; 18; 144; 121; 131; 38; 109; 183; 89; 244; 120; 136; 53; 187; 14; 74; 8; 112; 86; 100; 115; 8; 179; 155; 69; 78; 95; 160; }})'
assert_command dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "\f3\bf\72\b1\53\12\90\79\83\26\6d\b7\59\f4\78\88\35\bb\0e\4a\08\70\56\64\73\08\b3\9b\45\4e\5f\a0" })'
assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0})'
assert_match 'sha256 required'
assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 88; 87; 86; }})'
assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "XWV" })'
assert_match 'sha256 mismatch'

assert_command dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 243; 191; 114; 177; 83; 18; 144; 121; 131; 38; 109; 183; 89; 244; 120; 136; 53; 187; 14; 74; 8; 112; 86; 100; 115; 8; 179; 155; 69; 78; 95; 160; }})'
assert_command dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "\f3\bf\72\b1\53\12\90\79\83\26\6d\b7\59\f4\78\88\35\bb\0e\4a\08\70\56\64\73\08\b3\9b\45\4e\5f\a0"})'
assert_command_fail dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 88; 87; 86; }})'
assert_match 'sha256 mismatch'
Expand All @@ -906,14 +905,14 @@ check_permission_failure() {
dfx canister install e2e_project_frontend

assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl
assert_eq '(blob "\b8\01 \80\0aw12 \00xy\0aKL\0b\0ajk")'
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")'

assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")'

assert_command dfx canister call --update e2e_project_frontend store '(record{key="AA"; content_type="text/plain"; content_encoding="identity"; content=blob "hello, world!"})'
assert_eq '()'
assert_command dfx canister call --update e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})'
assert_command dfx canister call --update e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})'
assert_eq '()'

assert_command dfx canister call --query e2e_project_frontend retrieve '("B")' --output idl
Expand Down
11 changes: 9 additions & 2 deletions e2e/tests-dfx/basic-project.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ teardown() {
assert_eq \
'(
variant {
17_724 = record { 153_986_224 = blob "DIDL\00\01q\11Hello, Blueberry!" }
17_724 = record {
153_986_224 = blob "\44\49\44\4c\00\01\71\11\48\65\6c\6c\6f\2c\20\42\6c\75\65\62\65\72\72\79\21";
}
},
)'
}
Expand Down Expand Up @@ -100,7 +102,12 @@ teardown() {
# 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" } })'
assert_eq \
'(
variant {
17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7d\b9\0a" }
},
)'

}

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests-dfx/build_granular.bash
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ teardown() {
dfx canister install e2e_project_frontend

assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl
assert_eq '(blob "\b8\01 \80\0aw12 \00xy\0aKL\0b\0ajk")'
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")'

assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")'
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests-dfx/identity.bash
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ teardown() {
assert_eq '(false)'

# these all fail (other identities are not initializer; cannot store assets):
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity bob
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity default
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})'
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity bob
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity default
assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})'
assert_command_fail dfx canister call e2e_project_frontend retrieve '("B")'

# but alice, the initializer, can store assets:
assert_command dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity alice
assert_command dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity alice
assert_eq '()'
assert_command dfx canister call --output idl e2e_project_frontend retrieve '("B")'
assert_eq '(blob "XWV")'
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests-dfx/wallet.bash
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ teardown() {

assert_command dfx canister call "$WALLET" wallet_call \
"(record { canister = principal \"$(dfx canister id e2e_project_backend)\"; method_name = \"amInitializer\"; args = blob \"DIDL\00\00\"; cycles = (0:nat64)})"
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01~\01" } })' # True in DIDL.
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7e\01" } })' # True in DIDL.
}

@test "forward user call through wallet: deploy" {
Expand All @@ -147,7 +147,7 @@ teardown() {
assert_command dfx canister call e2e_project_backend amInitializer
assert_command dfx canister call "$WALLET" wallet_call \
"(record { canister = principal \"$(dfx canister id e2e_project_backend)\"; method_name = \"amInitializer\"; args = blob \"DIDL\00\00\"; cycles = (0:nat64)})"
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01~\01" } })' # True in DIDL.
assert_eq '(variant { 17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7e\01" } })' # True in DIDL.
}

@test "a 64-bit wallet can still be called in the 128-bit context" {
Expand Down

0 comments on commit b50d9b9

Please sign in to comment.