fix: repair three CI-broken native programs#631
Conversation
Greptile SummaryThis PR fixes three CI-broken native Solana programs by upgrading stale dependencies and correcting TypeScript test and serialization bugs. The changes are targeted and mechanical: borsh version bumps for CPI programs, a full migration from borsh v1's class-based Map schema API to borsh v2's plain-object
Confidence Score: 5/5The changes are narrowly scoped dependency upgrades and targeted bug fixes; no new logic is introduced and all corrections are verified against the Rust program source. The borsh v2 schema migration is mechanical and field-for-field faithful to the Rust structs. The isSigner fix matches what the Rust create_address_info handler requires when calling invoke with create_account. The favorites test restructuring correctly addresses the prior catch-swallowing defect. basics/realloc/native/pnpm-lock.yaml — the removed libc constraints on the Linux-specific bankrun native binaries are worth confirming on CI. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[TS Client] -->|createCreateInstruction| B[Build borsh v2 payload]
B -->|struct schema| C[serialize instruction bytes]
C --> D[TransactionInstruction target:isSigner=true payer:isSigner=true]
D --> E[Solana Runtime]
E -->|invoke| F[system_program::create_account]
F --> G[target account created]
G --> H[serialize AddressInfo to account data]
I[favorites test] -->|wrong_seed PDA| O[On-chain PDA check fails]
O --> P{threw = true}
P -->|assert outside catch| Q[Test passes correctly]
%%{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"}}}%%
flowchart TD
A[TS Client] -->|createCreateInstruction| B[Build borsh v2 payload]
B -->|struct schema| C[serialize instruction bytes]
C --> D[TransactionInstruction target:isSigner=true payer:isSigner=true]
D --> E[Solana Runtime]
E -->|invoke| F[system_program::create_account]
F --> G[target account created]
G --> H[serialize AddressInfo to account data]
I[favorites test] -->|wrong_seed PDA| O[On-chain PDA check fails]
O --> P{threw = true}
P -->|assert outside catch| Q[Test passes correctly]
Reviews (2): Last reviewed commit: "fix: correct negative test logic in favo..." | Re-trigger Greptile |
| try { | ||
| await client.processTransaction(tx); | ||
| console.error("Expected the test to fail"); | ||
| assert(false, "Expected transaction to fail with wrong PDA seeds"); | ||
| } catch (_err) { | ||
| assert(true); | ||
| } |
There was a problem hiding this comment.
Negative test always passes — assertion swallowed by catch
assert(false, ...) inside the try block throws an AssertionError, but the catch (_err) clause catches it indiscriminately and then calls assert(true), so the test passes whether processTransaction succeeds or throws. If the program ever stops rejecting wrong seeds, this test will still show green. Consider restructuring to hoist the assertion outside the catch:
let failed = false;
try {
await client.processTransaction(tx);
} catch {
failed = true;
}
assert(failed, "Expected transaction to fail with wrong PDA seeds");
Summary
borsh 1.5.7→1.6.1,borsh-derive 1.5.7→1.6.1,solana-program 3.0→4.0in hand and leverCargo.toml— the isolated workspace was pinning stale versions that conflict with the rest of the workspacets/from borsh v1 Map-based API to borsh v2{struct:...}schema; add missing"borsh": "^2.0.0"direct dependency (it was absent frompackage.json, making the import unresolvable); fixisSigner: false→trueon target account increateCreateInstruction(was causingMissingRequiredSignatureon thecreate_accountCPI); fix CJSrequire("node:fs")→ ESM import inutil.tsu64assertion (new BN(number as Buffer, "le")→Number(favoritesData.number)since borsh v2 deserializes u64 as bigint); fix "wrong seeds" test which was deriving the correct PDA and expecting failure — changed to use a genuinely wrong seed so the on-chain check actually rejects itTest plan
pnpm build-and-testforcross-program-invocation/native— Rust build with updated deps passes, TS test passespnpm build-and-testforrealloc/native— Rust build passes, borsh v2 serialization works at runtime,create_accountCPI succeeds with correct signer flagfavorites/nativetest logic fixes visible in diff; full CI validation pending.ghaignoreremoval once bankrun/SBF compatibility is confirmed on current platform-tools