From 93ed317305374787fd293b193f0c97a897285418 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 24 Sep 2024 22:57:32 +0200 Subject: [PATCH] Add tests --- sdk/cargo-build-sbf/tests/crates.rs | 14 +++++++++++++ .../tests/crates/package-metadata/Cargo.toml | 21 +++++++++++++++++++ .../tests/crates/package-metadata/src/lib.rs | 12 +++++++++++ .../crates/workspace-metadata/Cargo.toml | 21 +++++++++++++++++++ .../crates/workspace-metadata/src/lib.rs | 12 +++++++++++ 5 files changed, 80 insertions(+) create mode 100644 sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml create mode 100644 sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs create mode 100644 sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml create mode 100644 sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs diff --git a/sdk/cargo-build-sbf/tests/crates.rs b/sdk/cargo-build-sbf/tests/crates.rs index 09015eb208e437..65fb26b469da93 100644 --- a/sdk/cargo-build-sbf/tests/crates.rs +++ b/sdk/cargo-build-sbf/tests/crates.rs @@ -176,3 +176,17 @@ fn test_sbfv2() { .success(); clean_target("noop"); } + +#[test] +#[serial] +fn test_package_metadata_tools_version() { + run_cargo_build("package-metadata", &[], false); + clean_target("package-metadata"); +} + +#[test] +#[serial] +fn test_workspace_metadata_tools_version() { + run_cargo_build("workspace-metadata", &[], false); + clean_target("workspace-metadata"); +} diff --git a/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml new file mode 100644 index 00000000000000..4de95889d4bf4d --- /dev/null +++ b/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "package-metadata" +version = "2.1.0" +description = "Solana SBF test program with tools version in package metadata" +authors = ["Anza Maintainers "] +repository = "https://github.com/anza-xyz/agave" +license = "Apache-2.0" +homepage = "https://anza.xyz" +edition = "2021" +publish = false + +[package.metadata.solana] +tools-version = "v1.43" + +[dependencies] +solana-program = { path = "../../../../program", version = "=2.1.0" } + +[lib] +crate-type = ["cdylib"] + +[workspace] diff --git a/sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs b/sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs new file mode 100644 index 00000000000000..a6f2c05b770881 --- /dev/null +++ b/sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs @@ -0,0 +1,12 @@ +//! Example Rust-based SBF noop program + +use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; + +solana_program::entrypoint!(process_instruction); +fn process_instruction( + _program_id: &Pubkey, + _accounts: &[AccountInfo], + _instruction_data: &[u8], +) -> ProgramResult { + Ok(()) +} diff --git a/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml new file mode 100644 index 00000000000000..a72b71aab5f9e7 --- /dev/null +++ b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "workspace-metadata" +version = "2.1.0" +description = "Solana SBF test program with tools version in workspace metadata" +authors = ["Anza Maintainers "] +repository = "https://github.com/anza-xyz/agave" +license = "Apache-2.0" +homepage = "https://anza.xyz" +edition = "2021" +publish = false + +[dependencies] +solana-program = { path = "../../../../program", version = "=2.1.0" } + +[lib] +crate-type = ["cdylib"] + +[workspace] + +[workspace.metadata.solana] +tools-version = "v1.43" diff --git a/sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs new file mode 100644 index 00000000000000..a6f2c05b770881 --- /dev/null +++ b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs @@ -0,0 +1,12 @@ +//! Example Rust-based SBF noop program + +use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; + +solana_program::entrypoint!(process_instruction); +fn process_instruction( + _program_id: &Pubkey, + _accounts: &[AccountInfo], + _instruction_data: &[u8], +) -> ProgramResult { + Ok(()) +}