Skip to content

Commit 7b00614

Browse files
committed
tests: profile compute units in success cases
1 parent a74df09 commit 7b00614

File tree

8 files changed

+23
-12
lines changed

8 files changed

+23
-12
lines changed

program/tests/close.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn buffer_fail_authority_not_signer() {
186186
fn buffer_success() {
187187
let mollusk = setup();
188188

189-
let buffer = Pubkey::new_unique();
189+
let buffer = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
190190
let destination = Pubkey::new_unique();
191191
let authority = Pubkey::new_unique();
192192

@@ -213,6 +213,7 @@ fn buffer_success() {
213213
],
214214
&[
215215
Check::success(),
216+
Check::compute_units(12_793),
216217
// Closed, but still owned by the loader.
217218
Check::account(&buffer)
218219
.data(&[0, 0, 0, 0]) // Size of Uninitialized.
@@ -433,9 +434,7 @@ fn programdata_fail_incorrect_authority() {
433434
),
434435
),
435436
],
436-
&[
437-
Check::err(ProgramError::IncorrectAuthority),
438-
],
437+
&[Check::err(ProgramError::IncorrectAuthority)],
439438
);
440439
}
441440

@@ -491,7 +490,7 @@ fn programdata_success() {
491490

492491
let destination = Pubkey::new_unique();
493492
let authority = Pubkey::new_unique();
494-
let program = Pubkey::new_unique();
493+
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
495494

496495
let programdata = get_program_data_address(&program);
497496

@@ -529,6 +528,7 @@ fn programdata_success() {
529528
],
530529
&[
531530
Check::success(),
531+
Check::compute_units(14_432),
532532
// Closed, but still owned by the loader.
533533
Check::account(&programdata)
534534
.data(&[0, 0, 0, 0]) // Size of Uninitialized.

program/tests/deploy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ fn success() {
619619
let mollusk = setup();
620620

621621
let payer = Pubkey::new_unique();
622-
let program = Pubkey::new_unique();
622+
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
623623
let buffer = Pubkey::new_unique();
624624
let authority = Pubkey::new_unique();
625625

@@ -670,6 +670,7 @@ fn success() {
670670
],
671671
&[
672672
Check::success(),
673+
Check::compute_units(21_855),
673674
Check::account(&program)
674675
.data(
675676
&bincode::serialize(&UpgradeableLoaderState::Program {

program/tests/extend_program.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ fn success() {
559559
let mut mollusk = setup();
560560
mollusk.warp_to_slot(2); // To move past deployment slot.
561561

562-
let program = Pubkey::new_unique();
562+
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
563563
let payer = Pubkey::new_unique();
564564

565565
let programdata = get_program_data_address(&program);
@@ -613,6 +613,7 @@ fn success() {
613613
],
614614
&[
615615
Check::success(),
616+
Check::compute_units(7_006),
616617
Check::account(&programdata)
617618
.lamports(new_rent_exemption)
618619
.space(new_size)

program/tests/initialize_buffer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ fn success() {
110110
],
111111
&[
112112
Check::success(),
113+
Check::compute_units(2_149),
113114
Check::account(&source)
114115
.lamports(100_000_000)
115116
.owner(&solana_loader_v3_program::id())

program/tests/set_authority.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn buffer_success() {
171171

172172
let buffer = Pubkey::new_unique();
173173
let current_authority = Pubkey::new_unique();
174-
let new_authority = Pubkey::new_unique();
174+
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
175175

176176
let elf = &[3; 5_000];
177177

@@ -204,6 +204,7 @@ fn buffer_success() {
204204
],
205205
&[
206206
Check::success(),
207+
Check::compute_units(14_635),
207208
Check::account(&buffer)
208209
.data(
209210
&check_data(Some(new_authority)), // Updated.
@@ -317,7 +318,7 @@ fn programdata_success() {
317318

318319
let programdata = Pubkey::new_unique();
319320
let current_authority = Pubkey::new_unique();
320-
let new_authority = Pubkey::new_unique();
321+
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
321322

322323
let elf = &[3; 5_000];
323324

@@ -354,6 +355,7 @@ fn programdata_success() {
354355
],
355356
&[
356357
Check::success(),
358+
Check::compute_units(14_639),
357359
Check::account(&programdata)
358360
.data(
359361
&check_data(Some(new_authority)), // Updated.
@@ -382,6 +384,7 @@ fn programdata_success() {
382384
],
383385
&[
384386
Check::success(),
387+
Check::compute_units(1_918),
385388
Check::account(&programdata)
386389
.data(
387390
&check_data(None), // Updated.

program/tests/set_authority_checked.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn buffer_success() {
172172

173173
let buffer = Pubkey::new_unique();
174174
let current_authority = Pubkey::new_unique();
175-
let new_authority = Pubkey::new_unique();
175+
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
176176

177177
let elf = &[3; 5_000];
178178

@@ -205,6 +205,7 @@ fn buffer_success() {
205205
],
206206
&[
207207
Check::success(),
208+
Check::compute_units(14_121),
208209
Check::account(&buffer)
209210
.data(
210211
&check_data(Some(new_authority)), // Updated.
@@ -350,7 +351,7 @@ fn programdata_success() {
350351

351352
let programdata = Pubkey::new_unique();
352353
let current_authority = Pubkey::new_unique();
353-
let new_authority = Pubkey::new_unique();
354+
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
354355

355356
let elf = &[3; 5_000];
356357

@@ -387,6 +388,7 @@ fn programdata_success() {
387388
],
388389
&[
389390
Check::success(),
391+
Check::compute_units(14_102),
390392
Check::account(&programdata)
391393
.data(
392394
&check_data(Some(new_authority)), // Updated.

program/tests/upgrade.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ fn success() {
848848
let mut mollusk = setup();
849849
mollusk.warp_to_slot(2); // To move past deployment slot.
850850

851-
let program = Pubkey::new_unique();
851+
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
852852
let buffer = Pubkey::new_unique();
853853
let spill = Pubkey::new_unique();
854854
let authority = Pubkey::new_unique();
@@ -899,6 +899,7 @@ fn success() {
899899
],
900900
&[
901901
Check::success(),
902+
Check::compute_units(16_664),
902903
Check::account(&program)
903904
.data(
904905
&bincode::serialize(&UpgradeableLoaderState::Program {

program/tests/write.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ fn success() {
209209
],
210210
&[
211211
Check::success(),
212+
Check::compute_units(1_544),
212213
Check::account(&buffer).data(&check_data).build(),
213214
],
214215
);
@@ -227,6 +228,7 @@ fn success() {
227228
],
228229
&[
229230
Check::success(),
231+
Check::compute_units(1_698),
230232
Check::account(&buffer).data(&check_data).build(),
231233
],
232234
);

0 commit comments

Comments
 (0)