Skip to content

Commit

Permalink
Simplify program name env
Browse files Browse the repository at this point in the history
  • Loading branch information
febo committed Oct 31, 2024
1 parent 2167c9e commit 54569ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
12 changes: 1 addition & 11 deletions cpi/tests/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@ use {
std::str::FromStr,
};

/// The name of the program to test when using the `solana_program` library.
const SOLANA_PROGRAM: &str = "solana_program_rosetta_cpi";

/// The name of the program to test when using the `pinocchio` library.
const PINOCCHIO_PROGRAM: &str = "pinocchio_rosetta_cpi";

#[tokio::test]
async fn test_cross_program_invocation() {
let program_id = Pubkey::from_str("invoker111111111111111111111111111111111111").unwrap();
let (allocated_pubkey, bump_seed) =
Pubkey::find_program_address(&[b"You pass butter"], &program_id);

let library = std::env::var("ROSETTA_LIBRARY").unwrap_or(String::from("solana_program"));
let mut program_test = ProgramTest::new(
match library.as_str() {
"pinocchio" => PINOCCHIO_PROGRAM,
_ => SOLANA_PROGRAM,
},
option_env!("PROGRAM_NAME").unwrap_or("solana_program_rosetta_cpi"),
program_id,
None,
);
Expand Down
2 changes: 1 addition & 1 deletion test-pinocchio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ROOT_DIR="$(cd "$(dirname "$0")"; pwd)"
PROGRAM_DIR=$ROOT_DIR/$PROGRAM_NAME
cd $PROGRAM_DIR/pinocchio
cargo build-sbf
ROSETTA_LIBRARY="pinocchio" SBF_OUT_DIR="$ROOT_DIR/target/deploy" cargo test --manifest-path "$PROGRAM_DIR/Cargo.toml"
PROGRAM_NAME="pinocchio_rosetta_${PROGRAM_NAME//-/_}" SBF_OUT_DIR="$ROOT_DIR/target/deploy" cargo test --manifest-path "$PROGRAM_DIR/Cargo.toml"
12 changes: 1 addition & 11 deletions transfer-lamports/tests/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,14 @@ use {
std::str::FromStr,
};

/// The name of the program to test when using the `solana_program` library.
const SOLANA_PROGRAM: &str = "solana_program_rosetta_transfer_lamports";

/// The name of the program to test when using the `pinocchio` library.
const PINOCCHIO_PROGRAM: &str = "pinocchio_rosetta_transfer_lamports";

#[tokio::test]
async fn test_lamport_transfer() {
let program_id = Pubkey::from_str("TransferLamports111111111111111111111111111").unwrap();
let source_pubkey = Pubkey::new_unique();
let destination_pubkey = Pubkey::new_unique();

let library = std::env::var("ROSETTA_LIBRARY").unwrap_or(String::from("solana_program"));
let mut program_test = ProgramTest::new(
match library.as_str() {
"pinocchio" => PINOCCHIO_PROGRAM,
_ => SOLANA_PROGRAM,
},
option_env!("PROGRAM_NAME").unwrap_or("solana_program_rosetta_transfer_lamports"),
program_id,
None,
);
Expand Down

0 comments on commit 54569ec

Please sign in to comment.