-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wallet_call_with_max_cycles (#170)
- Loading branch information
Showing
10 changed files
with
105 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bats | ||
|
||
# shellcheck source=/dev/null | ||
source "$BATS_SUPPORT/load.bash" | ||
|
||
load util/assertions | ||
|
||
setup() { | ||
# We want to work from a temporary directory, different for every test. | ||
x=$(mktemp -d -t dfx-usage-env-home-XXXXXXXX) | ||
cd "$x" || exit | ||
export DFX_CONFIG_ROOT=$x | ||
|
||
dfx new --no-frontend e2e_project | ||
cd e2e_project || exit 1 | ||
dfx start --background --clean | ||
} | ||
|
||
teardown() { | ||
dfx stop | ||
rm -rf "$DFX_CONFIG_ROOT" | ||
} | ||
|
||
@test "wallet_call_with_max_cycles" { | ||
dfx identity new alice | ||
dfx identity new bob | ||
WALLET_ALICE=$(dfx --identity alice identity get-wallet) | ||
WALLET_BOB=$(dfx --identity bob identity get-wallet) | ||
|
||
ALICE_CYCLES_BEFORE_SEND=$(dfx --identity alice wallet balance | sed 's/[^0-9]//g') | ||
if (( ALICE_CYCLES_BEFORE_SEND < 2000000000000 )); then | ||
echo "alice has unexpectedly few cycles before sending: ${ALICE_CYCLES_BEFORE_SEND}" | ||
exit 1 | ||
fi | ||
|
||
# non-controller can't make the call | ||
assert_command_fail dfx --identity bob canister call "${WALLET_ALICE}" wallet_call_with_max_cycles "(record { canister = principal \"${WALLET_BOB}\"; method_name = \"wallet_receive\"; args = blob \"\44\49\44\4c\00\00\"; })" | ||
|
||
assert_command dfx --identity alice canister call "${WALLET_ALICE}" wallet_call_with_max_cycles "(record { canister = principal \"${WALLET_BOB}\"; method_name = \"wallet_receive\"; args = blob \"\44\49\44\4c\00\00\"; })" | ||
|
||
# has less than 0.2T cycles afterwards | ||
ALICE_CYCLES_AFTER_SEND=$(dfx --identity alice wallet balance | sed 's/[^0-9]//g') | ||
if (( ALICE_CYCLES_AFTER_SEND > 200000000000 )); then | ||
echo "expected alice to have <1TC after wallet_call_with_max_cycles, actually has ${ALICE_CYCLES_AFTER_SEND}, before was ${ALICE_CYCLES_BEFORE_SEND}" | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[toolchain] | ||
channel = "1.70.0" | ||
channel = "1.74.1" | ||
components = ["clippy", "rustfmt"] | ||
targets = ["wasm32-unknown-unknown"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters