Skip to content

Add Pinocchio cross-program-invocation and repository-layout examples#70

Merged
mikemaccana merged 3 commits into
mainfrom
claude/happy-ride-uwmjrp
Jun 12, 2026
Merged

Add Pinocchio cross-program-invocation and repository-layout examples#70
mikemaccana merged 3 commits into
mainfrom
claude/happy-ride-uwmjrp

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

What

Ports the two newest Pinocchio basics examples contributed to solana-developers/program-examples into this repo:

  • basics/cross-program-invocation/pinocchio — a two-program CPI demo (hand invokes lever's switch_power via CPI). Upstream #584.
  • basics/repository-layout/pinocchio — the recommended multi-file program layout (lib / processor / instructions/ / state/). Upstream #582.

Credit

Both original Pinocchio examples were authored by @MarkFeder in solana-developers/program-examples (PRs #582 and #584). The credit is recorded in each example's README.md and as a Co-authored-by trailer on the commit. 🙏

Why

These are the only two basics examples that were missing a Pinocchio variant in this repo — every other basics example already ships one. The docs at solana.com/docs/programs/examples point developers to this example set, so filling these two gaps keeps the Pinocchio coverage complete.

Tests: Rust + LiteSVM only (no JavaScript)

Per review feedback, these examples have no JS/bankrun tests. Each program is tested on-chain with LiteSVM from Rust:

  • basics/repository-layout/pinocchio/program/tests/test.rs — exercises the ride/game/food instructions plus invalid-attraction rejection.
  • basics/cross-program-invocation/pinocchio/programs/lever/tests/test.rs — exercises the full initialize → pull → pull-again CPI flow plus an invalid-discriminator rejection.

The package.json files keep only the build/deploy scripts needed by CI (no JS deps); pnpm build/build-and-test compile the .so into tests/fixtures so the LiteSVM tests can load it, and the Rust tests run via cargo test.

How it was adapted to this repo's conventions

  • Registered all three program crates in the workspace Cargo.toml; Cargo.lock updated additively (no version bumps).
  • Regenerated each example's pnpm-lock.yaml with the repo's pinned pnpm (10.33.0); both pass pnpm install --frozen-lockfile.
  • Dropped the upstream cicd.sh files to match the existing Pinocchio examples.
  • Added a per-framework README.md for each example.

Verification

  • cargo check passes for all three program crates on the host toolchain.
  • cargo test --no-run compiles both LiteSVM test crates (test code + deps resolve and type-check).
  • cargo fmt --check and biome check are clean on the new files.
  • cargo build-sbf is not available in this environment, so the on-chain .so build + LiteSVM test run is left to CI (the program sources are unchanged from upstream and use the same pinned pinocchio 0.10.2 API as the existing examples).

…ayout examples

Port the two newest Pinocchio basics examples contributed to
solana-developers/program-examples (upstream #582 and #584) into the
Quicknode example set, which already carries Pinocchio variants for every
other basics example.

- cross-program-invocation/pinocchio: hand + lever two-program CPI demo
- repository-layout/pinocchio: recommended multi-file program layout

Both register in the workspace and follow the repo's pnpm build/build-and-test
convention. Tests are written in Rust against LiteSVM (no JavaScript tests):
repository-layout in program/tests/test.rs, cross-program-invocation in
programs/lever/tests/test.rs.

Original Pinocchio examples authored by @MarkFeder.

Co-authored-by: Marco A. <MarkFeder@users.noreply.github.com>
@mikemaccana mikemaccana force-pushed the claude/happy-ride-uwmjrp branch from 8e34292 to a6628c4 Compare June 12, 2026 19:13
Claude added 2 commits June 12, 2026 19:31
…vention

Merge in main's Rust-only Pinocchio test convention (PR #69) and adopt it for
the two new examples:

- Drop package.json / pnpm-lock.yaml (no JS); examples build with
  `cargo build-sbf` and test with `cargo test`.
- include_bytes! the program .so from the workspace target/deploy instead of
  tests/fixtures, matching the CI that builds with
  `cargo build-sbf --manifest-path=<manifest>` (no --sbf-out-dir).
- Update READMEs to the cargo build-sbf / cargo test workflow.
@mikemaccana mikemaccana merged commit 2ba047d into main Jun 12, 2026
18 checks passed
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