Skip to content

Commit

Permalink
Switching back to list because it's faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 7, 2023
1 parent 89c64a8 commit 30a1cf4
Showing 1 changed file with 35 additions and 45 deletions.
80 changes: 35 additions & 45 deletions program/tests/namespace_royalty_enforcement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use utils::{
MetadataDelegateRole, Operation, PayloadKey, TokenDelegateRole, TransferScenario,
};

const ADDITIONAL_COMPUTE: u32 = 1_400_000;
const ADDITIONAL_COMPUTE: u32 = 400_000;
const RULE_SET_NAME: &str = "Metaplex Royalty RuleSet Dev";

// --------------------------------
Expand Down Expand Up @@ -70,38 +70,32 @@ fn get_composed_rules() -> ComposedRules {
};

// Generate some random programs to add to the base lists.
let random_programs = (0..68).map(|_| Keypair::new().pubkey()).collect::<Vec<_>>();

let source_program_allow_list = Rule::ProgramOwnedSet {
programs: HashSet::from_iter(
[
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
),
let random_programs = (0..18).map(|_| Keypair::new().pubkey()).collect::<Vec<_>>();

let source_program_allow_list = Rule::ProgramOwnedList {
programs: [
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
field: PayloadKey::Source.to_string(),
};

let dest_program_allow_list = Rule::ProgramOwnedSet {
programs: HashSet::from_iter(
[
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
),
let dest_program_allow_list = Rule::ProgramOwnedList {
programs: [
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
field: PayloadKey::Destination.to_string(),
};

let authority_program_allow_list = Rule::ProgramOwnedSet {
programs: HashSet::from_iter(
[
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
),
let authority_program_allow_list = Rule::ProgramOwnedList {
programs: [
TRANSFER_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
field: PayloadKey::Authority.to_string(),
};

Expand All @@ -113,25 +107,21 @@ fn get_composed_rules() -> ComposedRules {
field: PayloadKey::Destination.to_string(),
};

let delegate_program_allow_list = Rule::ProgramOwnedSet {
programs: HashSet::from_iter(
[
DELEGATE_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
),
let delegate_program_allow_list = Rule::ProgramOwnedList {
programs: [
DELEGATE_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs.clone(),
]
.concat(),
field: PayloadKey::Delegate.to_string(),
};

let advanced_delegate_program_allow_list = Rule::ProgramOwnedSet {
programs: HashSet::from_iter(
[
ADVANCED_DELEGATE_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs,
]
.concat(),
),
let advanced_delegate_program_allow_list = Rule::ProgramOwnedList {
programs: [
ADVANCED_DELEGATE_PROGRAM_BASE_ALLOW_LIST.to_vec(),
random_programs,
]
.concat(),
field: PayloadKey::Delegate.to_string(),
};

Expand Down Expand Up @@ -1027,7 +1017,7 @@ async fn prog_owner_not_on_list_fails() {
solana_program_test::BanksClientError::TransactionError(
TransactionError::InstructionError(_, InstructionError::Custom(error)),
) => {
assert_eq!(error, RuleSetError::ProgramOwnedSetCheckFailed as u32);
assert_eq!(error, RuleSetError::ProgramOwnedListCheckFailed as u32);
}
_ => panic!("Unexpected error: {:?}", err),
}
Expand Down Expand Up @@ -1126,7 +1116,7 @@ async fn prog_owned_but_zero_data_length() {
solana_program_test::BanksClientError::TransactionError(
TransactionError::InstructionError(_, InstructionError::Custom(error)),
) => {
assert_eq!(error, RuleSetError::ProgramOwnedSetCheckFailed as u32);
assert_eq!(error, RuleSetError::ProgramOwnedListCheckFailed as u32);
}
_ => panic!("Unexpected error: {:?}", err),
}
Expand Down

0 comments on commit 30a1cf4

Please sign in to comment.