Skip to content

Commit ccdf499

Browse files
marc0oloclaude
andcommitted
chore(rust/basic_bitcoin): test.sh over Makefile, bump CI image to 1.0.1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1c0f53d commit ccdf499

4 files changed

Lines changed: 74 additions & 82 deletions

File tree

.github/workflows/basic_bitcoin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ jobs:
7474
run: |
7575
icp network start -d
7676
icp deploy --cycles 30t
77-
make test
77+
bash test.sh

rust/basic_bitcoin/Makefile

Lines changed: 0 additions & 80 deletions
This file was deleted.

rust/basic_bitcoin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ make build-image
4545
```bash
4646
icp network start -d
4747
icp deploy --cycles 30t
48-
make test
48+
bash test.sh
4949
icp network stop
5050
```
5151

rust/basic_bitcoin/test.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
IMAGE_NAME=icp-cli-network-launcher-bitcoin
5+
# Find the running container built from our custom image
6+
BITCOIN_CONTAINER=$(docker ps --filter "ancestor=${IMAGE_NAME}" --format "{{.ID}}" | head -1)
7+
8+
echo "=== Test 1: get_p2pkh_address returns a valid Bitcoin address ==="
9+
result=$(icp canister call backend get_p2pkh_address '()') && \
10+
echo "$result" && \
11+
echo "$result" | grep -q '"' && \
12+
echo "PASS" || (echo "FAIL" && exit 1)
13+
14+
echo "=== Test 2: get_p2wpkh_address returns a valid Bitcoin address ==="
15+
result=$(icp canister call backend get_p2wpkh_address '()') && \
16+
echo "$result" && \
17+
echo "$result" | grep -q '"' && \
18+
echo "PASS" || (echo "FAIL" && exit 1)
19+
20+
echo "=== Test 3: get_p2tr_key_path_only_address returns a valid Bitcoin address ==="
21+
result=$(icp canister call backend get_p2tr_key_path_only_address '()') && \
22+
echo "$result" && \
23+
echo "$result" | grep -q '"' && \
24+
echo "PASS" || (echo "FAIL" && exit 1)
25+
26+
echo "=== Test 4: get_p2tr_script_path_enabled_address returns a valid Bitcoin address ==="
27+
result=$(icp canister call backend get_p2tr_script_path_enabled_address '()') && \
28+
echo "$result" && \
29+
echo "$result" | grep -q '"' && \
30+
echo "PASS" || (echo "FAIL" && exit 1)
31+
32+
echo "=== Test 5: get_current_fee_percentiles returns a vec ==="
33+
result=$(icp canister call backend get_current_fee_percentiles '()') && \
34+
echo "$result" && \
35+
echo "PASS" || (echo "FAIL" && exit 1)
36+
37+
echo "=== Mining 101 blocks to fund test address ==="
38+
[ -n "$BITCOIN_CONTAINER" ] || (echo "ERROR: network launcher container not running — run 'icp network start -d' first" && exit 1)
39+
addr=$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
40+
docker exec "$BITCOIN_CONTAINER" bitcoin-cli -regtest \
41+
-rpcuser=ic-btc-integration -rpcpassword=ic-btc-integration \
42+
generatetoaddress 101 "$addr" > /dev/null && \
43+
echo "mined 101 blocks to $addr"
44+
45+
echo "=== Waiting for IC to sync Bitcoin blocks ==="
46+
sleep 5
47+
48+
echo "=== Test 6: get_balance returns non-zero after mining ==="
49+
addr=$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
50+
result=$(icp canister call backend get_balance "(\"$addr\")") && \
51+
echo "$result" && \
52+
echo "$result" | grep -qE '[1-9]' && \
53+
echo "PASS" || (echo "FAIL" && exit 1)
54+
55+
echo "=== Test 7: get_utxos returns synced chain state after mining ==="
56+
addr=$(icp canister call backend get_p2pkh_address '()' | grep -o '"[^"]*"' | tr -d '"') && \
57+
result=$(icp canister call backend get_utxos "(\"$addr\")") && \
58+
echo "$result" && \
59+
echo "$result" | grep -q 'tip_height = 101' && \
60+
echo "PASS" || (echo "FAIL" && exit 1)
61+
62+
echo "=== Test 8: get_blockchain_info returns tip_height ==="
63+
result=$(icp canister call backend get_blockchain_info '()') && \
64+
echo "$result" && \
65+
echo "$result" | grep -q 'height' && \
66+
echo "PASS" || (echo "FAIL" && exit 1)
67+
68+
echo "=== Test 9: get_block_headers returns headers ==="
69+
result=$(icp canister call backend get_block_headers '(0: nat32, null)') && \
70+
echo "$result" && \
71+
echo "$result" | grep -q 'tip_height' && \
72+
echo "PASS" || (echo "FAIL" && exit 1)

0 commit comments

Comments
 (0)