Skip to content

Commit cb108dd

Browse files
authored
fix: address 2nd round of reviews (#6)
1 parent fcc5ea2 commit cb108dd

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/test-write-program-buffer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
integration:
2121
name: ${{ matrix.scenario }} (solana ${{ matrix.solana-version }})
2222
runs-on: ubuntu-latest
23+
timeout-minutes: 10
2324
strategy:
2425
fail-fast: false
2526
matrix:

start-test-validator/action.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ runs:
3434
LEDGER_DIR="${RUNNER_TEMP:-/tmp}/test-ledger"
3535
fi
3636
37-
rm -rf "$LEDGER_DIR"
3837
solana-test-validator --reset --quiet --ledger "$LEDGER_DIR" > "${RUNNER_TEMP:-/tmp}/validator-stdout.log" 2>&1 &
3938
echo "Validator started with PID $!"
4039

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ fail() {
1212
[ -n "${BUFFER:-}" ] || fail "action did not output a buffer address"
1313
[ -n "${BUFFER_AUTHORITY:-}" ] || fail "BUFFER_AUTHORITY env not set"
1414
[ -n "${DEPLOYER:-}" ] || fail "DEPLOYER env not set"
15+
[ -n "${PROGRAM_ID:-}" ] || fail "PROGRAM_ID env not set"
16+
[ -n "${PRE_LEN:-}" ] || fail "PRE_LEN env not set"
1517

1618
BUFFER_INFO=$(solana program show "$BUFFER" -u "$RPC_URL")
1719
echo "$BUFFER_INFO"
@@ -20,9 +22,13 @@ AUTHORITY=$(echo "$BUFFER_INFO" | grep "Authority:" | awk '{print $2}' || true)
2022
[ "$AUTHORITY" = "$BUFFER_AUTHORITY" ] || fail "buffer authority is $AUTHORITY, expected $BUFFER_AUTHORITY"
2123
[ "$AUTHORITY" != "$DEPLOYER" ] || fail "buffer authority still equals the deployer"
2224

25+
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)
26+
[ -n "$POST_LEN" ] || fail "could not read data length of program $PROGRAM_ID"
27+
[ "$POST_LEN" -eq "$PRE_LEN" ] || fail "program was resized from $PRE_LEN to $POST_LEN bytes, expected no resize"
28+
2329
DUMP="$(mktemp)"
2430
solana program dump "$BUFFER" "$DUMP" -u "$RPC_URL" || fail "could not dump buffer $BUFFER"
2531
cmp -s "$ARTIFACT" "$DUMP" || fail "buffer contents differ from artifact"
2632
rm -f "$DUMP"
2733

28-
echo "Authority transfer assertions passed"
34+
echo "Authority transfer assertions passed: program stayed at $PRE_LEN bytes"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@ solana program deploy "$FIXTURES_DIR/program-small.so" \
2828
-u "$RPC_URL" -k "$SCENARIO_DIR/deployer.json" \
2929
--commitment confirmed
3030

31+
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)
32+
if [ -z "$PRE_LEN" ]; then
33+
echo "Could not read deployed program size" >&2
34+
exit 1
35+
fi
36+
3137
cp "$FIXTURES_DIR/program-small.so" target/deploy/fixture-authority.so
3238

33-
echo "Prepared authority scenario: deployer=$DEPLOYER program-id=$PROGRAM_ID authority-target=$AUTHORITY_TARGET"
39+
echo "Prepared authority scenario: deployer=$DEPLOYER program-id=$PROGRAM_ID authority-target=$AUTHORITY_TARGET pre-len=$PRE_LEN"
3440
{
3541
echo "keypair=$(cat "$SCENARIO_DIR/deployer.json")"
3642
echo "deployer=$DEPLOYER"
3743
echo "program-id=$PROGRAM_ID"
3844
echo "buffer-authority=$AUTHORITY_TARGET"
45+
echo "pre-len=$PRE_LEN"
3946
} >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)