Skip to content

Commit 8b4856c

Browse files
committed
fix: address pr 24 review findings
1 parent e3c416d commit 8b4856c

9 files changed

Lines changed: 23 additions & 8 deletions

File tree

start-test-validator/action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ runs:
2828
env:
2929
LEDGER_DIR_INPUT: ${{ inputs.ledger-dir }}
3030
run: |
31+
set -euo pipefail
32+
3133
RPC_URL="http://127.0.0.1:8899"
3234
LEDGER_DIR="$LEDGER_DIR_INPUT"
3335
if [ -z "$LEDGER_DIR" ]; then

write-program-buffer/tests/integration/assert-authority.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ fail() {
1515

1616
BUFFER_INFO=$(solana program show "$BUFFER" -u "$RPC_URL")
1717
echo "$BUFFER_INFO"
18-
AUTHORITY=$(echo "$BUFFER_INFO" | grep "Authority:" | awk '{print $2}')
18+
AUTHORITY=$(echo "$BUFFER_INFO" | grep "Authority:" | awk '{print $2}' || true)
19+
[ -n "$AUTHORITY" ] || fail "could not read authority of buffer $BUFFER"
1920
[ "$AUTHORITY" = "$BUFFER_AUTHORITY" ] || fail "buffer authority is $AUTHORITY, expected $BUFFER_AUTHORITY"
2021
[ "$AUTHORITY" != "$DEPLOYER" ] || fail "buffer authority still equals the deployer"
2122

write-program-buffer/tests/integration/assert-clamp.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ fail() {
1414
[ -n "${PROGRAM_ID:-}" ] || fail "PROGRAM_ID env not set"
1515
[ -n "${PRE_LEN:-}" ] || fail "PRE_LEN env not set"
1616

17-
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1)
17+
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true)
18+
[ -n "$POST_LEN" ] || fail "could not read data length of program $PROGRAM_ID"
1819
GROWTH=$((POST_LEN - PRE_LEN))
1920
[ "$GROWTH" -eq "$MIN_EXTEND_SIZE" ] || fail "program grew by $GROWTH bytes, expected exactly $MIN_EXTEND_SIZE"
2021

write-program-buffer/tests/integration/assert-delta.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ REQUIRED_SIZE=$(wc -c < "$ARTIFACT" | tr -d ' ')
1818
EXPECTED_GROWTH=$((REQUIRED_SIZE - PRE_LEN))
1919
[ "$EXPECTED_GROWTH" -gt "$MIN_EXTEND_SIZE" ] || fail "scenario setup invalid: expected growth $EXPECTED_GROWTH must exceed $MIN_EXTEND_SIZE"
2020

21-
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1)
21+
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true)
22+
[ -n "$POST_LEN" ] || fail "could not read data length of program $PROGRAM_ID"
2223
GROWTH=$((POST_LEN - PRE_LEN))
2324
[ "$GROWTH" -eq "$EXPECTED_GROWTH" ] || fail "program grew by $GROWTH bytes, expected the exact delta $EXPECTED_GROWTH"
2425

write-program-buffer/tests/integration/assert-fresh.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ rm -f "$DUMP"
2020

2121
BUFFER_INFO=$(solana program show "$BUFFER" -u "$RPC_URL")
2222
echo "$BUFFER_INFO"
23-
AUTHORITY=$(echo "$BUFFER_INFO" | grep "Authority:" | awk '{print $2}')
23+
AUTHORITY=$(echo "$BUFFER_INFO" | grep "Authority:" | awk '{print $2}' || true)
24+
[ -n "$AUTHORITY" ] || fail "could not read authority of buffer $BUFFER"
2425
[ "$AUTHORITY" = "$DEPLOYER" ] || fail "buffer authority is $AUTHORITY, expected deployer $DEPLOYER"
2526

2627
ABSENCE_CHECK=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" 2>&1 || true)

write-program-buffer/tests/integration/assert-nearmax.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ fail() {
1616
[ -n "${PROGRAM_ID:-}" ] || fail "PROGRAM_ID env not set"
1717
[ -n "${PRE_LEN:-}" ] || fail "PRE_LEN env not set"
1818

19-
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1)
19+
POST_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true)
20+
[ -n "$POST_LEN" ] || fail "could not read data length of program $PROGRAM_ID"
2021
[ "$POST_LEN" -eq "$MAX_PROGRAM_SIZE" ] || fail "program data length is $POST_LEN, expected the exact maximum $MAX_PROGRAM_SIZE"
2122
echo "Program extended from $PRE_LEN to $POST_LEN (exact headroom of $((POST_LEN - PRE_LEN)) bytes)"
2223

write-program-buffer/tests/integration/prepare-clamp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ solana program deploy "$FIXTURES_DIR/program-small.so" \
3434
-u "$RPC_URL" -k "$SCENARIO_DIR/deployer.json" \
3535
--commitment confirmed
3636

37-
PRE_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1)
37+
PRE_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true)
3838
if [ -z "$PRE_LEN" ]; then
3939
echo "Could not read deployed program size" >&2
4040
exit 1

write-program-buffer/tests/integration/prepare-delta.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ solana program deploy "$FIXTURES_DIR/program-small.so" \
3535
-u "$RPC_URL" -k "$SCENARIO_DIR/deployer.json" \
3636
--commitment confirmed
3737

38-
PRE_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1)
38+
PRE_LEN=$(solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true)
3939
if [ -z "$PRE_LEN" ]; then
4040
echo "Could not read deployed program size" >&2
4141
exit 1

write-program-buffer/tests/integration/prepare-nearmax.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ solana program deploy "$FIXTURES_DIR/program-small.so" \
4646
--commitment confirmed
4747

4848
read_data_len() {
49-
solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1
49+
solana program show "$PROGRAM_ID" -u "$RPC_URL" | grep "Data Length:" | sed -E 's/.*Data Length: ([0-9]+).*/\1/' | cut -d ' ' -f1 || true
5050
}
5151

5252
for i in 1 2 3; do
5353
CURRENT_LEN=$(read_data_len)
54+
if [ -z "$CURRENT_LEN" ]; then
55+
echo "Could not read program data length for $PROGRAM_ID" >&2
56+
exit 1
57+
fi
5458
REMAINING=$((TARGET_CURRENT - CURRENT_LEN))
5559
if [ "$REMAINING" -le 0 ]; then
5660
break
@@ -66,6 +70,10 @@ for i in 1 2 3; do
6670
done
6771

6872
PRE_LEN=$(read_data_len)
73+
if [ -z "$PRE_LEN" ]; then
74+
echo "Could not read program data length for $PROGRAM_ID" >&2
75+
exit 1
76+
fi
6977
if [ "$PRE_LEN" -ne "$TARGET_CURRENT" ]; then
7078
echo "Setup failed: program data length is $PRE_LEN, expected $TARGET_CURRENT" >&2
7179
exit 1

0 commit comments

Comments
 (0)