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

test: add e2e test for canister request-status with different identity #4047

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
20 changes: 20 additions & 0 deletions e2e/tests-dfx/request_status.bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,23 @@ teardown() {
assert_eq '4449444c0001710b48656c6c6f2c20426f6221'

}

@test "request-status requires same identity" {
install_asset greet
dfx_start --artificial-delay 10000
Copy link
Contributor

Choose a reason for hiding this comment

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

Why such an artificial delay?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question! I copied this from the test above. The delays were introduced in #3920. @lwshang , do you remember?

Copy link
Contributor

Choose a reason for hiding this comment

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

Later in this test, we try to make a call asynchronously and get the request-id (in stdout):

dfx canister call --async hello_backend greet Bob

Then we request-status of the request

dfx canister request-status --output raw "$stdout" "$(dfx canister id hello_backend)"

In my PR #3920, I bumped the agent-rs dependency to v0.38 which contains this change: dfinity/agent-rs#595

Without the --artificial-delay 10000, the first step won't output the request-id, instead it will output the call result ("Hello, Bob!") directly.
Adding --artificial-delay 10000 to dfx start served as a workaround to preserve the existing test behavior.


dfx canister create hello_backend
dfx build hello_backend
dfx canister install hello_backend

assert_command dfx canister call --async hello_backend greet Bob

# shellcheck disable=SC2154
REQUEST_ID="$stdout"

assert_command_fail dfx canister request-status "$REQUEST_ID" "$(dfx canister id hello_backend)" --identity anonymous
assert_contains "The user tries to access Request ID not signed by the caller"

assert_command dfx canister request-status "$REQUEST_ID" "$(dfx canister id hello_backend)"
assert_eq '("Hello, Bob!")'
}
Loading