litesvm 0.11.0

A fast and lightweight Solana VM simulator for testing solana programs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
// ported from https://github.com/solana-program/config/blob/main/program/tests/functional.rs
use {
    bincode::{deserialize, serialized_size},
    litesvm::LiteSVM,
    serde::{Deserialize, Serialize},
    solana_account::{Account, ReadableAccount},
    solana_address::Address,
    solana_config_interface::{
        instruction::{create_account_with_max_config_space, store},
        state::ConfigKeys,
    },
    solana_instruction::{error::InstructionError, AccountMeta},
    solana_keypair::Keypair,
    solana_rent::Rent,
    solana_signer::Signer,
    solana_transaction::Transaction,
    solana_transaction_error::TransactionError,
};

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
struct MyConfig {
    pub item: u64,
}
impl Default for MyConfig {
    fn default() -> Self {
        Self { item: 123_456_789 }
    }
}
impl MyConfig {
    pub fn new(item: u64) -> Self {
        Self { item }
    }
    pub fn deserialize(input: &[u8]) -> Option<Self> {
        deserialize(input).ok()
    }
}

/// Utility for extracting the `ConfigKeys` data from the account data.
pub fn get_config_data(bytes: &[u8]) -> Result<&[u8], bincode::Error> {
    bincode::deserialize::<ConfigKeys>(bytes)
        .and_then(|keys| bincode::serialized_size(&keys))
        .map(|offset| &bytes[offset as usize..])
}

struct TestContext {
    svm: LiteSVM,
    payer: Keypair,
}

fn setup_test_context() -> TestContext {
    let payer = Keypair::new();
    let mut svm = LiteSVM::new();
    svm.airdrop(&payer.pubkey(), 1_000_000_000).unwrap();
    TestContext { svm, payer }
}

fn get_config_space(key_len: usize) -> usize {
    let entry_size = bincode::serialized_size(&(Address::default(), true)).unwrap() as usize;
    bincode::serialized_size(&(ConfigKeys::default(), MyConfig::default())).unwrap() as usize
        + key_len * entry_size
}

fn create_config_account(
    ctx: &mut TestContext,
    config_keypair: &Keypair,
    keys: Vec<(Address, bool)>,
) {
    let payer = &ctx.payer;

    let space = get_config_space(keys.len());
    let max_space = serialized_size(&MyConfig::default()).unwrap();
    let lamports = ctx.svm.get_sysvar::<Rent>().minimum_balance(space);
    let instructions = create_account_with_max_config_space::<MyConfig>(
        &payer.pubkey(),
        &config_keypair.pubkey(),
        lamports,
        max_space,
        keys,
    );

    ctx.svm
        .send_transaction(Transaction::new_signed_with_payer(
            &instructions,
            Some(&payer.pubkey()),
            &[payer, config_keypair],
            ctx.svm.latest_blockhash(),
        ))
        .unwrap();
}

#[test]
fn test_process_create_ok() {
    let mut context = setup_test_context();
    let config_keypair = Keypair::new();
    create_config_account(&mut context, &config_keypair, vec![]);
    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    assert_eq!(
        Some(MyConfig::default()),
        deserialize(get_config_data(config_account.data()).unwrap()).ok()
    );
}

#[test]
fn test_process_store_ok() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();
    let keys = vec![];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    let payer = &context.payer;

    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    assert_eq!(
        Some(my_config),
        deserialize(get_config_data(config_account.data()).unwrap()).ok()
    );
}

#[test_log::test]
fn test_process_store_fail_instruction_data_too_large() {
    // [Core BPF]: To be clear, this is testing instruction data that's too
    // large for the keys list provided, not the max deserialize length.
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();
    let keys = vec![];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let mut instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    instruction.data = vec![0; 123]; // <-- Replace data with a vector that's too large
    let payer = &context.payer;

    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidInstructionData)
    );
}

#[test]
fn test_process_store_fail_account0_not_signer() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();
    let keys = vec![];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let mut instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    let payer = &context.payer;

    instruction.accounts[0].is_signer = false; // <----- not a signer

    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[&payer],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );
}

#[test]
fn test_process_store_with_additional_signers() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let signer1 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer1.pubkey(), true),
    ];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &my_config);
    let payer = &context.payer;

    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0, &signer1],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    let config_state: ConfigKeys = deserialize(config_account.data()).unwrap();
    assert_eq!(config_state.keys, keys);
    assert_eq!(
        Some(my_config),
        deserialize(get_config_data(config_account.data()).unwrap()).ok()
    );
}

#[test]
fn test_process_store_bad_config_account() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let keys = vec![(pubkey, false), (signer0.pubkey(), true)];
    let my_config = MyConfig::new(42);

    context
        .svm
        .set_account(
            signer0.pubkey(),
            Account::new(100_000, 0, &solana_config_interface::id()),
        )
        .unwrap();

    create_config_account(&mut context, &config_keypair, keys.clone());
    let payer = &context.payer;

    let mut instruction = store(&config_keypair.pubkey(), false, keys, &my_config);
    instruction.accounts.remove(0); // Config popped out of instruction.

    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidAccountData)
    );
}

#[test]
fn test_process_store_with_bad_additional_signer() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();
    let bad_signer = Keypair::new();

    let signer0 = Keypair::new();
    let keys = vec![(signer0.pubkey(), true)];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let payer = &context.payer;

    // Config-data pubkey doesn't match signer.
    let mut instruction = store(&config_keypair.pubkey(), true, keys.clone(), &my_config);
    instruction.accounts[1] = AccountMeta::new(bad_signer.pubkey(), true);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &bad_signer],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );

    // Config-data pubkey not a signer.
    let mut instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    instruction.accounts[1].is_signer = false;
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );
}

#[test]
fn test_config_updates() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let signer1 = Keypair::new();
    let signer2 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer1.pubkey(), true),
    ];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let payer = &context.payer;

    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &my_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0, &signer1],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    // Update with expected signatures.
    let new_config = MyConfig::new(84);
    let instruction = store(&config_keypair.pubkey(), false, keys.clone(), &new_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &signer0, &signer1],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    let config_state: ConfigKeys = deserialize(config_account.data()).unwrap();
    assert_eq!(config_state.keys, keys);
    assert_eq!(
        new_config,
        MyConfig::deserialize(get_config_data(config_account.data()).unwrap()).unwrap()
    );

    // Attempt update with incomplete signatures.
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true), // Missing signer1.
    ];
    let instruction = store(&config_keypair.pubkey(), false, keys, &my_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &signer0], // Missing signer1.
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );

    // Attempt update with incorrect signatures.
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer2.pubkey(), true), // Incorrect signer1.
    ];
    let instruction = store(&config_keypair.pubkey(), false, keys, &my_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &signer0, &signer2], // Incorrect signer1.
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );
}

#[test]
fn test_config_initialize_contains_duplicates_fails() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer0.pubkey(), true), // Duplicate signer0.
    ];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let payer = &context.payer;

    // Attempt initialization with duplicate signer inputs.
    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidArgument)
    );
}

#[test]
fn test_config_update_contains_duplicates_fails() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let signer1 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer1.pubkey(), true),
    ];
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let payer = &context.payer;

    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0, &signer1],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    // Attempt update with duplicate signer inputs.
    let new_config = MyConfig::new(84);
    let dupe_keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (signer0.pubkey(), true), // Duplicate signer0.
    ];
    let instruction = store(&config_keypair.pubkey(), true, dupe_keys, &new_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidArgument)
    );
}

#[test]
fn test_config_updates_requiring_config() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (config_keypair.pubkey(), true),
    ];
    let my_config = MyConfig::new(42);

    create_config_account(
        &mut context,
        &config_keypair,
        vec![(pubkey, false), (pubkey, false), (pubkey, false)], // Dummy keys for account sizing.
    );
    let payer = &context.payer;

    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &my_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    // Update with expected signatures.
    let new_config = MyConfig::new(84);
    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &new_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    let config_state: ConfigKeys = deserialize(config_account.data()).unwrap();
    assert_eq!(config_state.keys, keys);
    assert_eq!(
        Some(new_config),
        deserialize(get_config_data(config_account.data()).unwrap()).ok()
    );

    // Attempt update with incomplete signatures.
    let keys = vec![(pubkey, false), (config_keypair.pubkey(), true)]; // Missing signer0.
    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair], // Missing signer0.
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::MissingRequiredSignature)
    );
}

#[test]
#[allow(deprecated)]
fn test_config_initialize_no_panic() {
    let mut context = setup_test_context();
    let config_keypair = Keypair::new();
    create_config_account(&mut context, &config_keypair, vec![]);
    let payer = &context.payer;
    let max_space = serialized_size(&MyConfig::default()).unwrap();

    let instructions = create_account_with_max_config_space::<MyConfig>(
        &payer.pubkey(),
        &config_keypair.pubkey(),
        1,
        max_space,
        vec![],
    );
    let mut instruction = instructions[1].clone();
    instruction.accounts = vec![];

    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[&payer],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::NotEnoughAccountKeys)
    );
}

#[test]
fn test_config_bad_owner() {
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    let pubkey = Address::new_unique();
    let signer0 = Keypair::new();
    let keys = vec![
        (pubkey, false),
        (signer0.pubkey(), true),
        (config_keypair.pubkey(), true),
    ];
    let my_config = MyConfig::new(42);

    // Store a config account with the wrong owner.
    let space = get_config_space(keys.len());
    let lamports = context.svm.get_sysvar::<Rent>().minimum_balance(space);
    context
        .svm
        .set_account(
            config_keypair.pubkey(),
            Account::new(lamports, 0, &Address::new_unique()),
        )
        .unwrap();

    let payer = &context.payer;

    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);
    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair, &signer0],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidAccountOwner)
    );
}

#[test]
fn test_maximum_keys_input() {
    // `limited_deserialize` allows up to 1232 bytes of input.
    // One config key is `Address` + `bool` = 32 + 1 = 33 bytes.
    // 1232 / 33 = 37 keys max.
    let mut context = setup_test_context();

    let config_keypair = Keypair::new();

    // First store with 37 keys.
    let mut keys = vec![];
    for _ in 0..37 {
        keys.push((Address::new_unique(), false));
    }
    let my_config = MyConfig::new(42);

    create_config_account(&mut context, &config_keypair, keys.clone());
    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &my_config);
    let payer = &context.payer;

    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    let config_account = context.svm.get_account(&config_keypair.pubkey()).unwrap();
    assert_eq!(
        Some(my_config),
        deserialize(get_config_data(config_account.data()).unwrap()).ok()
    );

    // Do an update with 37 keys, forcing the program to deserialize the
    // config account data.
    let new_config = MyConfig::new(84);
    let instruction = store(&config_keypair.pubkey(), true, keys.clone(), &new_config);
    context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap();

    // Now try to store with 38 keys.
    keys.push((Address::new_unique(), false));
    let my_config = MyConfig::new(42);
    let instruction = store(&config_keypair.pubkey(), true, keys, &my_config);

    let err = context
        .svm
        .send_transaction(Transaction::new_signed_with_payer(
            &[instruction],
            Some(&payer.pubkey()),
            &[payer, &config_keypair],
            context.svm.latest_blockhash(),
        ))
        .unwrap_err()
        .err;
    assert_eq!(
        err,
        TransactionError::InstructionError(0, InstructionError::InvalidInstructionData)
    );
}