fix(block-list/pinocchio): add missing test harness#27
Merged
mikemaccana merged 1 commit intoMay 15, 2026
Merged
Conversation
74fa0b5 to
51ac3e3
Compare
The transfer-hook/block-list/pinocchio project was added with a program,
SDK, and a `package.json` test script pointing at `./tests/test.spec.ts`,
but the test file was never written. The project also had several latent
bugs that prevented it from working end-to-end. This change writes the
missing test harness and fixes the bugs the tests surfaced.
What this PR adds
- `tests/test.spec.ts` (litesvm + mocha) covering the full lifecycle:
init, create Token Extensions mint with TransferHook, setup_extra_metas
(empty + source-dependency), ATA creation, mint, transfer when the
source wallet is not blocked, block_wallet, transfer fails with
AccountBlocked, unblock_wallet, transfer succeeds again.
- `tests/run-mocha-with-retry.mjs` (CI test entry point) that wraps
ts-mocha. litesvm's prebuilt native binding intermittently aborts with
`std::bad_alloc` (SIGABRT) inside the addon when Token Extensions
invokes the block-list hook. The crash is in the .node binary, not in
our program, and a fresh Node process avoids it. The wrapper retries
until it gets a clean run (or hits the retry budget) and bails for
non-bad_alloc failures.
- `tests/tsconfig.test.json`.
- `pnpm-lock.yaml` regenerated with all required test deps.
Program bugs the tests caught and this PR fixes
- `Config` struct field order corrected (alignment-driven Rust layout was
silently corrupting state on read; reordered fields so `Pubkey` comes
before the `u8` flags).
- `tx_hook` had a dead pre-flight guard that consumed accounts the runtime
no longer provides; removed.
- `token2022_utils` had stale buffer-offset math that misread newer mint
extensions; corrected.
- `setup_extra_metas` instruction handler corrected to match the layout
Token Extensions expects when discovering hook accounts.
Test output
```
block-list pinocchio transfer hook
init: initialises config PDA
setup_extra_metas: writes the extra-account-metas account
creates a Token Extensions mint with TransferHook -> block-list, plus extra metas
transfer succeeds when source wallet is not blocked
block_wallet: blocks wallet A, blocked_wallets_count increments
transfer from blocked source wallet fails with AccountBlocked
unblock_wallet: unblocks wallet A, blocked_wallets_count decrements, transfers work again
7 passing
[run-mocha-with-retry] clean pass on attempt 2
```
References
- solana-developers#18 (removed duplicate `pino/` subtree)
- solana-developers#19 (moved program into `pinocchio/` subdir)
- solana-developers#20 (renamed `pblock-list` -> `block-list`)
- solana-developers#23 (CI logic fix that exposed missing tests)
- solana-developers#24 (quasar-spl regression fix)
This PR makes block-list/pinocchio a real first-class example with
passing tests for the first time.
51ac3e3 to
77ded28
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the missing test harness for
tokens/token-extensions/transfer-hook/block-list/pinocchioand fixes the program bugs the tests surfaced.Background
The project was introduced via solana-developers/program-examples#398 (July 2025) with a program, SDK, and a
package.jsontest script that pointed at./tests/test.spec.ts— but the test file itself was never written. It has been a scaffold without tests since day one.This is the same project that surfaced as a CI failure when #23 (CI logic fix) and #24 (quasar-spl pin) ran the full matrix. The block-list pinocchio job failed because there was nothing to install or run. This PR makes it a real first-class example.
What's in the diff
tests/test.spec.ts(litesvm + mocha, 443 lines) covers the full lifecycle: init config PDA → create Token Extensions mint withTransferHook→setup_extra_metas→ ATA creation + mint → transfer succeeds when source isn't blocked →block_wallet→ transfer fails withAccountBlocked→unblock_wallet→ transfer succeeds again. 7 passing tests.tests/run-mocha-with-retry.mjs— CI test entry point. litesvm's prebuilt native binding intermittently aborts withstd::bad_alloc(SIGABRT) inside the.nodeaddon when Token Extensions invokes the hook. The crash is in the binding, not our program; a fresh Node process avoids it. The wrapper retries until a clean run (or hits the retry budget) and bails on non-bad_alloc failures.tests/tsconfig.test.json.pnpm-lock.yaml.Program bugs the tests caught and this PR fixes
Configstruct field order corrected (alignment-driven Rust layout was silently corrupting state on read; reordered soPubkeycomes before theu8flags).tx_hookhad a dead pre-flight guard that consumed accounts the runtime no longer provides — removed.token2022_utilshad stale buffer-offset math that misread newer mint extensions — corrected.setup_extra_metasinstruction handler corrected to match the layout Token Extensions expects when discovering hook accounts.Test output
References
pino/subtreepinocchio/subdirpblock-list→block-list