Skip to content

Commit

Permalink
refactor management example
Browse files Browse the repository at this point in the history
  • Loading branch information
lwshang committed Oct 26, 2023
1 parent 7776978 commit 23666c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 0 additions & 8 deletions examples/management_canister/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,5 @@
"wasm": "target/wasm32-unknown-unknown/release/caller-opt.wasm",
"build": "sh ../build.sh management_canister caller"
}
},
"defaults": {
"canister_http": {
"enabled": true
},
"bitcoin": {
"enabled": true
}
}
}
2 changes: 1 addition & 1 deletion examples/management_canister/src/caller/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mod bitcoin {
assert!(response.is_err());
if let Err((rejection_code, rejection_reason)) = response {
assert_eq!(rejection_code, RejectionCode::CanisterReject);
assert_eq!(&rejection_reason, "bitcoin_send_transaction failed: Can't deserialize transaction because it's malformed.");
assert_eq!(&rejection_reason, "send_transaction failed: MalformedTransaction");
};
}
}
Expand Down
25 changes: 17 additions & 8 deletions examples/management_canister/tests/basic.bats
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# Executed before each test.
setup() {
cd examples/management_canister
bitcoind -regtest -daemonwait
# Make sure the directory is clean.
dfx start --clean --background
}

# executed after each test
teardown() {
dfx stop
bitcoin-cli -regtest stop
}

@test "All management canister methods succeed" {
@test "http_request example succeed" {
dfx start --clean --background --enable-canister-http
dfx deploy
dfx canister call caller http_request_example
}

@test "ecdsa methods succeed" {
dfx start --clean --background
dfx deploy
dfx canister call caller execute_ecdsa_methods
}

@test "bitcoin methods succeed" {
bitcoind -regtest -daemonwait
dfx start --clean --background --enable-bitcoin
dfx deploy
run dfx canister call caller http_request_example
run dfx canister call caller execute_ecdsa_methods
run dfx canister call caller execute_bitcoin_methods
dfx canister call caller execute_bitcoin_methods
bitcoin-cli -regtest stop
}

0 comments on commit 23666c0

Please sign in to comment.