program-examples icon indicating copy to clipboard operation
program-examples copied to clipboard

Fixes to native program example on CPI

Open 4rjunc opened this issue 7 months ago • 0 comments

Build and Test Fixes

The program was not building and test cases were failing. I made several changes to fix these issues:

Changes Made

1. Updated Borsh Dependency

  • Changed borsh version from 0.10 to 1.5.7 to fix build errors when running pnpm run build-and-test

Error Fixed:

error[E0277]: the trait bound `SetPowerStatus: borsh::ser::BorshSerialize` is not satisfied
  --> programs/hand/src/lib.rs:27:9
   |
25 |     let ix = Instruction::new_with_borsh(
   |              --------------------------- required by a bound introduced by this call
26 |         *lever_program.key,                        // Our lever program's ID
27 |         &set_power_status_instruction,             // Passing instructions through
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `borsh::ser::BorshSerialize` is not implemented for `SetPowerStatus`
   |

2. Updated Borsh API Call

  • Changed .try_to_vec() to .to_vec() to match the latest version of borsh

3. Updated Test Architecture

  • Changed the test architecture to use bankrun

4rjunc avatar Jun 25 '25 05:06 4rjunc