Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Sep 24, 2024
1 parent 684cc45 commit 9b1c639
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/cargo-build-sbf/tests/crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
21 changes: 21 additions & 0 deletions sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
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]
12 changes: 12 additions & 0 deletions sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
21 changes: 21 additions & 0 deletions sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
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"
12 changes: 12 additions & 0 deletions sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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(())
}

0 comments on commit 9b1c639

Please sign in to comment.