Skip to content

Commit

Permalink
Clarify TargetProgramBuiltin code docs (#403)
Browse files Browse the repository at this point in the history
* Update comments

* Nitty variable name update
  • Loading branch information
CriesofCarrots authored Mar 22, 2024
1 parent bcaf7a8 commit 6e6acce
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
},
};

/// Used to validate a built-in program's account before migrating to Core BPF.
/// The account details of a built-in program to be migrated to Core BPF.
#[derive(Debug)]
pub(crate) struct TargetProgramBuiltin {
pub program_address: Pubkey,
Expand All @@ -19,7 +19,8 @@ pub(crate) struct TargetProgramBuiltin {
}

impl TargetProgramBuiltin {
/// Create a new migration configuration for a built-in program.
/// Collects the details of a built-in program and verifies it is properly
/// configured
pub(crate) fn new_checked(
bank: &Bank,
program_address: &Pubkey,
Expand Down Expand Up @@ -143,12 +144,12 @@ mod tests {
let program_data_address = get_program_data_address(&program_address);

// Success
let builtin_config =
let target_builtin =
TargetProgramBuiltin::new_checked(&bank, &program_address, &migration_target).unwrap();
assert_eq!(builtin_config.program_address, program_address);
assert_eq!(builtin_config.program_account, program_account);
assert_eq!(builtin_config.program_data_address, program_data_address);
assert_eq!(builtin_config.total_data_size, program_account.data().len());
assert_eq!(target_builtin.program_address, program_address);
assert_eq!(target_builtin.program_account, program_account);
assert_eq!(target_builtin.program_data_address, program_data_address);
assert_eq!(target_builtin.total_data_size, program_account.data().len());

// Fail if the program account is not owned by the native loader
store_account(
Expand Down Expand Up @@ -210,12 +211,12 @@ mod tests {
let program_data_address = get_program_data_address(&program_address);

// Success
let builtin_config =
let target_builtin =
TargetProgramBuiltin::new_checked(&bank, &program_address, &migration_target).unwrap();
assert_eq!(builtin_config.program_address, program_address);
assert_eq!(builtin_config.program_account, program_account);
assert_eq!(builtin_config.program_data_address, program_data_address);
assert_eq!(builtin_config.total_data_size, program_account.data().len());
assert_eq!(target_builtin.program_address, program_address);
assert_eq!(target_builtin.program_account, program_account);
assert_eq!(target_builtin.program_data_address, program_data_address);
assert_eq!(target_builtin.total_data_size, program_account.data().len());

// Fail if the program data account exists
store_account(
Expand Down

0 comments on commit 6e6acce

Please sign in to comment.