Pull program stubs into SDK (#10704)
This commit is contained in:
parent
6d81eede93
commit
d77818c18b
|
@ -1446,7 +1446,6 @@ version = "1.3.0"
|
|||
dependencies = [
|
||||
"solana-bpf-rust-128bit-dep 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1454,7 +1453,6 @@ name = "solana-bpf-rust-128bit-dep"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1462,7 +1460,6 @@ name = "solana-bpf-rust-alloc"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1471,7 +1468,6 @@ version = "1.3.0"
|
|||
dependencies = [
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1479,7 +1475,6 @@ name = "solana-bpf-rust-dup-accounts"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1489,7 +1484,6 @@ dependencies = [
|
|||
"num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1498,7 +1492,6 @@ name = "solana-bpf-rust-external-spend"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1507,7 +1500,6 @@ version = "1.3.0"
|
|||
dependencies = [
|
||||
"solana-bpf-rust-invoked 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1515,7 +1507,6 @@ name = "solana-bpf-rust-invoked"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1523,7 +1514,6 @@ name = "solana-bpf-rust-iter"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1532,7 +1522,6 @@ version = "1.3.0"
|
|||
dependencies = [
|
||||
"solana-bpf-rust-many-args-dep 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1540,7 +1529,6 @@ name = "solana-bpf-rust-many-args-dep"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1548,7 +1536,6 @@ name = "solana-bpf-rust-noop"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1556,7 +1543,6 @@ name = "solana-bpf-rust-panic"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1565,7 +1551,6 @@ version = "1.3.0"
|
|||
dependencies = [
|
||||
"solana-bpf-rust-param-passing-dep 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1573,7 +1558,6 @@ name = "solana-bpf-rust-param-passing-dep"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1581,7 +1565,6 @@ name = "solana-bpf-rust-sysval"
|
|||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-bpf-test 1.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1735,10 +1718,6 @@ dependencies = [
|
|||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-bpf-test"
|
||||
version = "1.3.0"
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.3.0"
|
||||
|
|
|
@ -15,9 +15,6 @@ edition = "2018"
|
|||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
solana-bpf-rust-128bit-dep = { path = "../128bit_dep", version = "1.3.0" }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -54,7 +54,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -86,7 +86,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -15,9 +15,6 @@ edition = "2018"
|
|||
byteorder = { version = "1", default-features = false }
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -21,7 +21,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -17,9 +17,6 @@ num-traits = "0.2"
|
|||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -14,7 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-bpf-rust-invoked = { path = "../invoked"}
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
|
|
|
@ -201,4 +201,4 @@ fn process_instruction(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
|
|
@ -13,7 +13,6 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
|
|
|
@ -192,4 +192,4 @@ fn process_instruction(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -22,7 +22,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -15,9 +15,6 @@ edition = "2018"
|
|||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
solana-bpf-rust-many-args-dep = { path = "../many_args_dep", version = "1.3.0" }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -30,7 +30,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -52,7 +52,7 @@ pub fn many_args_sret(
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_many_args() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -68,7 +68,7 @@ fn process_instruction(
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_return_sstruct() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -15,9 +15,6 @@ edition = "2018"
|
|||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
solana-bpf-rust-param-passing-dep = { path = "../param_passing_dep", version = "1.3.0" }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -27,7 +27,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_entrypoint() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<'a> TestDep {
|
|||
mod test {
|
||||
use super::*;
|
||||
// Pulls in the stubs required for `info!()`
|
||||
solana_sdk_bpf_test::stubs!();
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[test]
|
||||
fn test_dep() {
|
||||
|
|
|
@ -14,9 +14,6 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.3.0", default-features = false }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/test", version = "1.3.0" }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program"]
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
/target/
|
||||
/farf/
|
||||
Cargo.lock
|
|
@ -1,15 +0,0 @@
|
|||
[package]
|
||||
name = "solana-sdk-bpf-test"
|
||||
version = "1.3.0"
|
||||
description = "Solana BPF SDK test utilities"
|
||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
|
@ -74,6 +74,7 @@ pub mod entrypoint;
|
|||
pub mod log;
|
||||
pub mod program;
|
||||
pub mod program_error;
|
||||
pub mod program_stubs;
|
||||
|
||||
// Modules not usable by on-chain programs
|
||||
#[cfg(not(feature = "program"))]
|
||||
|
|
|
@ -1,29 +1,40 @@
|
|||
//! @brief Stubs for syscalls when building tests for x86
|
||||
|
||||
fn print_line_to_stdout(_message: &str) {
|
||||
#[cfg(not(feature = "program"))]
|
||||
{
|
||||
use std::io::{self, Write};
|
||||
io::stdout()
|
||||
.write_all(format!("{}\n", _message).as_bytes())
|
||||
.unwrap();
|
||||
io::stdout().flush().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
/// # Safety
|
||||
pub unsafe fn sol_log_(message: *const u8, length: u64) {
|
||||
let slice = std::slice::from_raw_parts(message, length as usize);
|
||||
let string = std::str::from_utf8(&slice).unwrap();
|
||||
std::println!("{}", string);
|
||||
print_line_to_stdout(string);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
|
||||
std::println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5);
|
||||
print_line_to_stdout(&format!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn sol_invoke_signed_rust() {
|
||||
std::println!("sol_invoke_signed_rust()");
|
||||
print_line_to_stdout("sol_invoke_signed_rust()");
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! stubs {
|
||||
macro_rules! program_stubs {
|
||||
() => {
|
||||
#[test]
|
||||
fn pull_in_externs() {
|
||||
use $crate::*;
|
||||
use solana_sdk::program_stubs::{sol_invoke_signed_rust, sol_log_, sol_log_64_};
|
||||
unsafe { sol_log_("sol_log_".as_ptr(), 8) };
|
||||
sol_log_64_(1, 2, 3, 4, 5);
|
||||
sol_invoke_signed_rust();
|
Loading…
Reference in New Issue