Skip to content

ci: add integration tests for write-program-buffer#24

Open
sparten11740 wants to merge 3 commits into
solana-foundation:mainfrom
ExodusForks:main
Open

ci: add integration tests for write-program-buffer#24
sparten11740 wants to merge 3 commits into
solana-foundation:mainfrom
ExodusForks:main

Conversation

@sparten11740

Copy link
Copy Markdown
Contributor

When I worked on the program extension fix for the write-proram-buffer action last week (#22), it would’ve been great to have automated tests running in the CI to increase confidence in the solution. I was trialing a few test scenarios and a way of testing this against a local solana validator. I think this could be helpful for future changes.

These are the scenarios tested for the write-program-buffer action (the workflow has a path filter, so they don’t run on changes to the other actions):

  • fresh — program not deployed yet: buffer created, contents match the artifact byte-for-byte, buffer authority stays with the deployer, resize and authority transfer skipped
  • delta — deployed program grows by more than 10,240 bytes: account extended by exactly the computed delta
  • clamp — deployed program grows by less than 10,240 bytes: extend clamped up to the SIMD-0431 minimum of 10,240
  • authority — same-size artifact with an external buffer-authority-address: buffer authority transferred on-chain, no resize
  • nearmax — program within 10 KiB of the 10 MiB cap: extend equals exactly the remaining headroom, landing the account at the maximum size

Test fixtures are prebuilt binaries, reproducible byte-for-byte from tests/fixtures/program/ via rebuild.sh. Also extracts start-test-validator as a reusable action (not documented yet, lmk if you’d like that added as part of the public set of actions)

@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds end-to-end integration tests for the write-program-buffer action running against a local solana-test-validator, and extracts a new reusable start-test-validator composite action. The five scenarios (fresh, delta, clamp, authority, nearmax) cover the full range of extension behaviour including the SIMD-0431 minimum clamp and the near-maximum-size edge case.

  • Workflow (.github/workflows/test-write-program-buffer.yaml): matrix job over all five scenarios with fail-fast: false, pinned checkout SHA, and minimal contents: read permissions.
  • start-test-validator: composite action that backgrounds solana-test-validator, health-checks via nick-fields/retry, and exposes rpc-url/ledger-dir outputs.
  • Prepare/Assert pairs: each scenario has a dedicated prepare script that seeds state (deploy, extend, airdrop) and a matching assert script that validates Data Length growth and buffer byte-equality against the fixture artifact.

Confidence Score: 5/5

Safe to merge — this is a new test infrastructure addition with no changes to production action logic.

All changes are additive test scaffolding: a new workflow, a new composite action, fixture binaries, and prepare/assert shell scripts. None of the existing action code is modified. The scenario coverage is thorough and the fixture invariants are validated at both build time (rebuild.sh) and run time (prepare scripts). The one finding is a fragile CLI error-message match in assert-fresh.sh that could cause a false test failure after a Solana CLI upgrade, but does not affect production behaviour.

write-program-buffer/tests/integration/assert-fresh.sh — the program-absence check greps for a hardcoded CLI string; consider switching to an exit-code check.

Important Files Changed

Filename Overview
.github/workflows/test-write-program-buffer.yaml New workflow orchestrating 5×1 matrix of integration scenarios; uses pinned action SHA, minimal contents: read permissions, and fail-fast: false.
start-test-validator/action.yaml New composite action that launches solana-test-validator in the background, polls for health via nick-fields/retry, and exposes rpc-url and ledger-dir outputs; shell set to bash -euo pipefail.
write-program-buffer/tests/integration/assert-fresh.sh Checks buffer contents, authority, and program absence for the fresh scenario; the absence check relies on a hardcoded CLI error string that could produce false failures on Solana CLI upgrades.
write-program-buffer/tests/integration/prepare-nearmax.sh Most complex prepare script — decompresses the huge fixture, derives TARGET_CURRENT, validates fixture bounds, extends the on-chain program to exactly TARGET_CURRENT with retry logic, and waits for the next slot before outputting PRE_LEN.
write-program-buffer/tests/integration/assert-nearmax.sh Asserts POST_LEN equals MAX_PROGRAM_SIZE (10485715) and verifies buffer contents match the nearmax artifact byte-for-byte.
write-program-buffer/tests/integration/assert-clamp.sh Verifies the program data length grew by exactly the SIMD-0431 minimum of 10,240 bytes and that the buffer contents match the artifact.
write-program-buffer/tests/integration/assert-delta.sh Verifies the program was extended by the exact computed delta (artifact size minus PRE_LEN) and buffer contents match; includes a sanity guard that the scenario's expected growth exceeds MIN_EXTEND_SIZE.
write-program-buffer/tests/fixtures/rebuild.sh Reproducible build script for all four fixture sizes; validates size-band invariants at build time and gzips the huge variant.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant GHA as GitHub Actions (matrix)
    participant SetupAll as setup-all
    participant Validator as start-test-validator
    participant Prepare as prepare-scenario.sh
    participant Action as write-program-buffer
    participant Assert as assert-scenario.sh

    GHA->>SetupAll: install Solana CLI (v4.1.2)
    GHA->>Validator: start solana-test-validator
    Validator-->>GHA: rpc-url, ledger-dir
    GHA->>Prepare: deploy fixture, airdrop SOL
    Prepare-->>GHA: program-id, keypair, buffer-authority, pre-len
    GHA->>Action: program-id, program artifact, rpc-url, keypair, buffer-authority-address
    Note over Action: extend ProgramData if needed,<br/>write buffer, optionally transfer authority
    Action-->>GHA: buffer address
    GHA->>Assert: BUFFER, PROGRAM_ID, DEPLOYER, BUFFER_AUTHORITY, PRE_LEN
    Note over Assert: check Data Length growth,<br/>dump & cmp buffer vs artifact,<br/>verify authority on-chain
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant GHA as GitHub Actions (matrix)
    participant SetupAll as setup-all
    participant Validator as start-test-validator
    participant Prepare as prepare-scenario.sh
    participant Action as write-program-buffer
    participant Assert as assert-scenario.sh

    GHA->>SetupAll: install Solana CLI (v4.1.2)
    GHA->>Validator: start solana-test-validator
    Validator-->>GHA: rpc-url, ledger-dir
    GHA->>Prepare: deploy fixture, airdrop SOL
    Prepare-->>GHA: program-id, keypair, buffer-authority, pre-len
    GHA->>Action: program-id, program artifact, rpc-url, keypair, buffer-authority-address
    Note over Action: extend ProgramData if needed,<br/>write buffer, optionally transfer authority
    Action-->>GHA: buffer address
    GHA->>Assert: BUFFER, PROGRAM_ID, DEPLOYER, BUFFER_AUTHORITY, PRE_LEN
    Note over Assert: check Data Length growth,<br/>dump & cmp buffer vs artifact,<br/>verify authority on-chain
Loading

Reviews (3): Last reviewed commit: "fix: review findings (#5)" | Re-trigger Greptile

Comment thread start-test-validator/action.yaml Outdated
Comment thread write-program-buffer/tests/integration/prepare-fresh.sh
Comment thread write-program-buffer/tests/integration/assert-clamp.sh Outdated
@sparten11740

Copy link
Copy Markdown
Contributor Author

@Woody4618 lmk if this is a direction you're okay with (absolutely no problem if you prefer not to)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant