Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Dec 9, 2024
1 parent 45dfd71 commit bde9c18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions builtins-default-costs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,11 @@ mod test {
// use native cost if migration is planned but not activated
assert_eq!(
Some(solana_stake_program::stake_instruction::DEFAULT_COMPUTE_UNITS),
get_builtin_instruction_cost(&solana_stake_program::id(), &FeatureSet::default())
get_builtin_instruction_cost(&stake::id(), &FeatureSet::default())
);

// None if migration is planned and activated, in which case, it's no longer builtin
assert!(get_builtin_instruction_cost(
&solana_stake_program::id(),
&FeatureSet::all_enabled()
)
.is_none());
assert!(get_builtin_instruction_cost(&stake::id(), &FeatureSet::all_enabled()).is_none());

// None if not builtin
assert!(
Expand All @@ -239,18 +235,17 @@ mod test {
get_builtin_migration_feature_index(&compute_budget::id()),
Some(None)
);
let feature_index = get_builtin_migration_feature_index(&solana_stake_program::id());
let feature_index = get_builtin_migration_feature_index(&stake::id());
assert_eq!(
MIGRATION_FEATURES_ID[feature_index.unwrap().unwrap()],
feature_set::migrate_stake_program_to_core_bpf::id()
);
let feature_index = get_builtin_migration_feature_index(&solana_config_program::id());
let feature_index = get_builtin_migration_feature_index(&config::id());
assert_eq!(
MIGRATION_FEATURES_ID[feature_index.unwrap().unwrap()],
feature_set::migrate_config_program_to_core_bpf::id()
);
let feature_index =
get_builtin_migration_feature_index(&address_lookup_table::program::id());
let feature_index = get_builtin_migration_feature_index(&address_lookup_table::id());
assert_eq!(
MIGRATION_FEATURES_ID[feature_index.unwrap().unwrap()],
feature_set::migrate_address_lookup_table_program_to_core_bpf::id()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl ComputeBudgetInstructionDetails {
.iter()
.enumerate()
.fold((0, 0), |(migrated, not_migrated), (index, count)| {
if feature_set.is_active(&MIGRATION_FEATURES_ID[index]) {
if *count > 0 && feature_set.is_active(&MIGRATION_FEATURES_ID[index]) {
(migrated + count, not_migrated)
} else {
(migrated, not_migrated + count)
Expand Down

0 comments on commit bde9c18

Please sign in to comment.