Skip to content

Commit

Permalink
tests: profile compute units in success cases
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Oct 11, 2024
1 parent a74df09 commit 4fce869
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
10 changes: 5 additions & 5 deletions program/tests/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn buffer_fail_authority_not_signer() {
fn buffer_success() {
let mollusk = setup();

let buffer = Pubkey::new_unique();
let buffer = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
let destination = Pubkey::new_unique();
let authority = Pubkey::new_unique();

Expand All @@ -213,6 +213,7 @@ fn buffer_success() {
],
&[
Check::success(),
Check::compute_units(12_809),
// Closed, but still owned by the loader.
Check::account(&buffer)
.data(&[0, 0, 0, 0]) // Size of Uninitialized.
Expand Down Expand Up @@ -433,9 +434,7 @@ fn programdata_fail_incorrect_authority() {
),
),
],
&[
Check::err(ProgramError::IncorrectAuthority),
],
&[Check::err(ProgramError::IncorrectAuthority)],
);
}

Expand Down Expand Up @@ -491,7 +490,7 @@ fn programdata_success() {

let destination = Pubkey::new_unique();
let authority = Pubkey::new_unique();
let program = Pubkey::new_unique();
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.

let programdata = get_program_data_address(&program);

Expand Down Expand Up @@ -529,6 +528,7 @@ fn programdata_success() {
],
&[
Check::success(),
Check::compute_units(14_450),
// Closed, but still owned by the loader.
Check::account(&programdata)
.data(&[0, 0, 0, 0]) // Size of Uninitialized.
Expand Down
3 changes: 2 additions & 1 deletion program/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ fn success() {
let mollusk = setup();

let payer = Pubkey::new_unique();
let program = Pubkey::new_unique();
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
let buffer = Pubkey::new_unique();
let authority = Pubkey::new_unique();

Expand Down Expand Up @@ -670,6 +670,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(21_870),
Check::account(&program)
.data(
&bincode::serialize(&UpgradeableLoaderState::Program {
Expand Down
3 changes: 2 additions & 1 deletion program/tests/extend_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ fn success() {
let mut mollusk = setup();
mollusk.warp_to_slot(2); // To move past deployment slot.

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

let programdata = get_program_data_address(&program);
Expand Down Expand Up @@ -613,6 +613,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(7_018),
Check::account(&programdata)
.lamports(new_rent_exemption)
.space(new_size)
Expand Down
1 change: 1 addition & 0 deletions program/tests/initialize_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(2_171),
Check::account(&source)
.lamports(100_000_000)
.owner(&solana_loader_v3_program::id())
Expand Down
7 changes: 5 additions & 2 deletions program/tests/set_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn buffer_success() {

let buffer = Pubkey::new_unique();
let current_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.

let elf = &[3; 5_000];

Expand Down Expand Up @@ -204,6 +204,7 @@ fn buffer_success() {
],
&[
Check::success(),
Check::compute_units(14_654),
Check::account(&buffer)
.data(
&check_data(Some(new_authority)), // Updated.
Expand Down Expand Up @@ -317,7 +318,7 @@ fn programdata_success() {

let programdata = Pubkey::new_unique();
let current_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.

let elf = &[3; 5_000];

Expand Down Expand Up @@ -354,6 +355,7 @@ fn programdata_success() {
],
&[
Check::success(),
Check::compute_units(14_657),
Check::account(&programdata)
.data(
&check_data(Some(new_authority)), // Updated.
Expand Down Expand Up @@ -382,6 +384,7 @@ fn programdata_success() {
],
&[
Check::success(),
Check::compute_units(1_936),
Check::account(&programdata)
.data(
&check_data(None), // Updated.
Expand Down
6 changes: 4 additions & 2 deletions program/tests/set_authority_checked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn buffer_success() {

let buffer = Pubkey::new_unique();
let current_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.

let elf = &[3; 5_000];

Expand Down Expand Up @@ -205,6 +205,7 @@ fn buffer_success() {
],
&[
Check::success(),
Check::compute_units(14_136),
Check::account(&buffer)
.data(
&check_data(Some(new_authority)), // Updated.
Expand Down Expand Up @@ -350,7 +351,7 @@ fn programdata_success() {

let programdata = Pubkey::new_unique();
let current_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_unique();
let new_authority = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.

let elf = &[3; 5_000];

Expand Down Expand Up @@ -387,6 +388,7 @@ fn programdata_success() {
],
&[
Check::success(),
Check::compute_units(14_117),
Check::account(&programdata)
.data(
&check_data(Some(new_authority)), // Updated.
Expand Down
3 changes: 2 additions & 1 deletion program/tests/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ fn success() {
let mut mollusk = setup();
mollusk.warp_to_slot(2); // To move past deployment slot.

let program = Pubkey::new_unique();
let program = Pubkey::new_from_array([1; 32]); // Consistent CUs when logging.
let buffer = Pubkey::new_unique();
let spill = Pubkey::new_unique();
let authority = Pubkey::new_unique();
Expand Down Expand Up @@ -899,6 +899,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(16_683),
Check::account(&program)
.data(
&bincode::serialize(&UpgradeableLoaderState::Program {
Expand Down
2 changes: 2 additions & 0 deletions program/tests/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(1_425),
Check::account(&buffer).data(&check_data).build(),
],
);
Expand All @@ -227,6 +228,7 @@ fn success() {
],
&[
Check::success(),
Check::compute_units(1_397),
Check::account(&buffer).data(&check_data).build(),
],
);
Expand Down

0 comments on commit 4fce869

Please sign in to comment.