@@ -5,7 +5,7 @@ import * as borsh from 'borsh';
55import { start } from 'solana-bankrun' ;
66
77describe ( 'custom-instruction-data' , async ( ) => {
8- const PROGRAM_ID = PublicKey . unique ( ) ;
8+ const PROGRAM_ID = new PublicKey ( 'z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35' ) ;
99 const context = await start ( [ { name : 'processing_instructions_steel_program' , programId : PROGRAM_ID } ] , [ ] ) ;
1010 const client = context . banksClient ;
1111 const payer = context . payer ;
@@ -50,6 +50,14 @@ describe('custom-instruction-data', async () => {
5050 ] ,
5151 ] ) ;
5252
53+ enum ParkInstruction {
54+ Park = 0 ,
55+ }
56+
57+ const addInstructionDiscriminator = ( discriminator : ParkInstruction , instructionData : InstructionData ) => {
58+ return Buffer . concat ( [ Buffer . from ( [ discriminator ] ) , instructionData . toBuffer ( ) ] ) ;
59+ } ;
60+
5361 test ( 'Go to the park!' , async ( ) => {
5462 const blockhash = context . lastBlockhash ;
5563
@@ -66,12 +74,12 @@ describe('custom-instruction-data', async () => {
6674 const ix1 = new TransactionInstruction ( {
6775 keys : [ { pubkey : payer . publicKey , isSigner : true , isWritable : true } ] ,
6876 programId : PROGRAM_ID ,
69- data : jimmy . toBuffer ( ) ,
77+ data : addInstructionDiscriminator ( ParkInstruction . Park , jimmy ) ,
7078 } ) ;
7179
7280 const ix2 = new TransactionInstruction ( {
7381 ...ix1 ,
74- data : mary . toBuffer ( ) ,
82+ data : addInstructionDiscriminator ( ParkInstruction . Park , mary ) ,
7583 } ) ;
7684
7785 const tx = new Transaction ( ) ;
0 commit comments