Use cargo-test-bpf
This commit is contained in:
parent
64823d9968
commit
901d43f965
|
@ -5,5 +5,3 @@ bin
|
|||
config.json
|
||||
node_modules
|
||||
./package-lock.json
|
||||
*.so
|
||||
*-dump.txt
|
||||
|
|
|
@ -10,6 +10,5 @@ if [[ $1 = -v ]]; then
|
|||
export RUST_LOG=solana=debug
|
||||
fi
|
||||
|
||||
bpf=1 cargo test
|
||||
# TODO: bpf=0 not supported until native CPI rework in the monorepo completes
|
||||
#bpf=0 cargo test
|
||||
cargo test
|
||||
cargo test-bpf
|
||||
|
|
|
@ -16,16 +16,17 @@ set -x
|
|||
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
|
||||
program_dir=$(dirname "$Xargo_toml")
|
||||
|
||||
if [ "$program_dir" == "token-swap/program" ]; then
|
||||
address="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8"
|
||||
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" cargo build-bpf --manifest-path=token-swap/program/Cargo.toml --dump --features production
|
||||
mv spl_token_swap.so spl_token_swap_production.so
|
||||
fi
|
||||
if [ "$program_dir" == "token-swap/program" ]; then
|
||||
address="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8"
|
||||
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" cargo build-bpf \
|
||||
--manifest-path=token-swap/program/Cargo.toml \
|
||||
--dump --features production
|
||||
mv target/deploy/spl_token_swap.so target/deploy/spl_token_swap_production.so
|
||||
fi
|
||||
|
||||
cargo +"$rust_stable" build-bpf --manifest-path="$program_dir"/Cargo.toml --dump
|
||||
cargo +"$rust_stable" test-bpf --manifest-path="$program_dir"/Cargo.toml -- --nocapture
|
||||
done
|
||||
|
||||
|
||||
cargo +"$rust_stable" build
|
||||
cargo +"$rust_stable" test -- --nocapture
|
||||
cargo +"$rust_stable" run --manifest-path=utils/test-client/Cargo.toml
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
if [[ -n $SOLANA_VERSION ]]; then
|
||||
solana_version="$SOLANA_VERSION"
|
||||
else
|
||||
solana_version=v1.4.4
|
||||
solana_version=v1.4.5
|
||||
fi
|
||||
|
||||
export solana_version="$solana_version"
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
use std::process::{exit, Command};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("XARGO").is_err()
|
||||
&& std::env::var("RUSTC_WRAPPER").is_err()
|
||||
&& std::env::var("RUSTC_WORKSPACE_WRAPPER").is_err()
|
||||
{
|
||||
println!(
|
||||
"cargo:warning=(not a warning) Building BPF {} program",
|
||||
std::env::var("CARGO_PKG_NAME").unwrap()
|
||||
);
|
||||
if !Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build BPF shared-memory program")
|
||||
.success()
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,14 +11,11 @@ use solana_sdk::{
|
|||
account::Account, keyed_account::KeyedAccount, process_instruction::MockInvokeContext,
|
||||
};
|
||||
use spl_shared_memory::entrypoint;
|
||||
use std::{fs::File, io::Read, path::PathBuf};
|
||||
use std::{fs::File, io::Read};
|
||||
|
||||
fn load_program(name: &str) -> Vec<u8> {
|
||||
let mut path = PathBuf::new();
|
||||
path.push(name);
|
||||
path.set_extension("so");
|
||||
let mut file = File::open(&path)
|
||||
.unwrap_or_else(|err| panic!("Unable to open {}: {}", path.display(), err));
|
||||
let mut file =
|
||||
File::open(&name).unwrap_or_else(|err| panic!("Unable to open {}: {}", name, err));
|
||||
|
||||
let mut program = Vec::new();
|
||||
file.read_to_end(&mut program).unwrap();
|
||||
|
@ -31,7 +28,7 @@ fn run_program(
|
|||
instruction_data: &[u8],
|
||||
) -> Result<u64, InstructionError> {
|
||||
let mut program_account = Account::default();
|
||||
program_account.data = load_program("spl_shared_memory");
|
||||
program_account.data = load_program("../../target/deploy/spl_shared_memory.so");
|
||||
let loader_id = bpf_loader::id();
|
||||
let mut invoke_context = MockInvokeContext::default();
|
||||
let executable = EbpfVm::<solana_bpf_loader_program::BPFError>::create_executable_from_elf(
|
||||
|
|
|
@ -5,16 +5,20 @@ fn main() {
|
|||
&& std::env::var("RUSTC_WRAPPER").is_err()
|
||||
&& std::env::var("RUSTC_WORKSPACE_WRAPPER").is_err()
|
||||
{
|
||||
println!("cargo:warning=(not a warning) Building BPF {} program", std::env::var("CARGO_PKG_NAME").unwrap());
|
||||
println!(
|
||||
"cargo:warning=(not a warning) Building BPF {} program",
|
||||
std::env::var("CARGO_PKG_NAME").unwrap()
|
||||
);
|
||||
if !Command::new("cargo")
|
||||
.args(&[
|
||||
"build-bpf",
|
||||
"--manifest-path",
|
||||
"../program_ristretto/Cargo.toml",
|
||||
])
|
||||
.status()
|
||||
.expect("Failed to build BPF themis program")
|
||||
.success() {
|
||||
.args(&[
|
||||
"build-bpf",
|
||||
"--manifest-path",
|
||||
"../program_ristretto/Cargo.toml",
|
||||
])
|
||||
.status()
|
||||
.expect("Failed to build BPF themis program")
|
||||
.success()
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,10 @@ use spl_themis_ristretto::{
|
|||
instruction::ThemisInstruction,
|
||||
state::{generate_keys, /*recover_scalar,*/ Policies, User},
|
||||
};
|
||||
use std::{fs::File, io::Read, path::PathBuf};
|
||||
use std::{fs::File, io::Read};
|
||||
|
||||
fn load_program(name: &str) -> Vec<u8> {
|
||||
let path = PathBuf::from(name).with_extension("so");
|
||||
let mut file = File::open(path).unwrap();
|
||||
let mut file = File::open(name).unwrap();
|
||||
|
||||
let mut program = Vec::new();
|
||||
file.read_to_end(&mut program).unwrap();
|
||||
|
@ -37,7 +36,7 @@ fn run_program(
|
|||
instruction_data: &[u8],
|
||||
) -> Result<u64, InstructionError> {
|
||||
let mut program_account = Account::default();
|
||||
program_account.data = load_program("spl_themis_ristretto");
|
||||
program_account.data = load_program("../../target/deploy/spl_themis_ristretto.so");
|
||||
let loader_id = bpf_loader::id();
|
||||
let mut invoke_context = MockInvokeContext::default();
|
||||
invoke_context.bpf_compute_budget = BpfComputeBudget {
|
||||
|
|
|
@ -16,15 +16,13 @@ use spl_themis_ristretto_client::{process_transactions_with_commitment, test_e2e
|
|||
use std::{
|
||||
fs::{remove_dir_all, File},
|
||||
io::Read,
|
||||
path::PathBuf,
|
||||
};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
const DATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
||||
|
||||
fn load_program(name: &str) -> Vec<u8> {
|
||||
let path = PathBuf::from(name).with_extension("so");
|
||||
let mut file = File::open(path).unwrap();
|
||||
let mut file = File::open(name).unwrap();
|
||||
|
||||
let mut program = Vec::new();
|
||||
file.read_to_end(&mut program).unwrap();
|
||||
|
@ -161,7 +159,7 @@ fn test_validator_e2e() {
|
|||
..TestValidatorOptions::default()
|
||||
});
|
||||
|
||||
let program = load_program("spl_themis_ristretto");
|
||||
let program = load_program("../../target/deploy/spl_themis_ristretto.so");
|
||||
|
||||
Runtime::new().unwrap().block_on(async {
|
||||
let mut banks_client = start_tcp_client(leader_data.rpc_banks).await.unwrap();
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
use std::process::{exit, Command};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("XARGO").is_err()
|
||||
&& std::env::var("RUSTC_WRAPPER").is_err()
|
||||
&& std::env::var("RUSTC_WORKSPACE_WRAPPER").is_err()
|
||||
{
|
||||
println!("cargo:warning=(not a warning) Building BPF token program");
|
||||
if !Command::new("cargo")
|
||||
.args(&["build-bpf", "--manifest-path", "../program/Cargo.toml"])
|
||||
.status()
|
||||
.expect("Failed to build BPF token program")
|
||||
.success()
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ fn run_program(
|
|||
instruction_data: &[u8],
|
||||
) -> Result<u64, InstructionError> {
|
||||
let mut program_account = SolanaAccount::default();
|
||||
program_account.data = load_program("spl_token.so");
|
||||
program_account.data = load_program("../../target/deploy/spl_token.so");
|
||||
let loader_id = bpf_loader::id();
|
||||
let mut invoke_context = MockInvokeContext::default();
|
||||
|
||||
|
|
Loading…
Reference in New Issue