chore: port web3.js to solana-test-validator

This commit is contained in:
Michael Vines
2020-12-15 13:24:28 -08:00
committed by mergify[bot]
parent efc091e28a
commit fd7d2f82ae
12 changed files with 373 additions and 131 deletions

View File

@ -1,6 +1,3 @@
# Note: This crate must be built using build.sh
[package]
name = "solana-bpf-rust-noop"
version = "0.1.0"
@ -14,13 +11,9 @@ edition = "2018"
[dependencies]
num-derive = "0.2"
num-traits = "0.2"
solana-sdk = { git = "https://github.com/solana-labs/solana", default-features = false }
solana-program = "1.4.16"
thiserror = "1.0"
[features]
program = ["solana-sdk/program"]
default = ["program"]
[workspace]
members = []

View File

@ -1,69 +0,0 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
usage() {
cat <<EOF
Usage: do.sh action <project>
If relative_project_path is ommitted then action will
be performed on all projects
Supported actions:
build
clean
test
clippy
fmt
EOF
}
sdkDir=../../bpf-sdk
targetDir="$PWD"/target
profile=bpfel-unknown-unknown/release
perform_action() {
set -e
case "$1" in
build)
"$sdkDir"/rust/build.sh "$PWD"
so_path="$targetDir/$profile"
so_name="solana_bpf_rust_noop"
if [ -f "$so_path/${so_name}.so" ]; then
cp "$so_path/${so_name}.so" "$so_path/${so_name}_debug.so"
"$sdkDir"/dependencies/llvm-native/bin/llvm-objcopy --strip-all "$so_path/${so_name}.so" "$so_path/$so_name.so"
fi
;;
clean)
"$sdkDir"/rust/clean.sh "$PWD"
;;
test)
echo "test"
cargo +nightly test
;;
clippy)
echo "clippy"
cargo +nightly clippy
;;
fmt)
echo "formatting"
cargo fmt
;;
help)
usage
exit
;;
*)
echo "Error: Unknown command"
usage
exit
;;
esac
}
set -e
perform_action "$1"

View File

@ -1,10 +1,8 @@
//! @brief Example Rust-based BPF program that prints out the parameters passed to it
#![allow(unreachable_code)]
extern crate solana_sdk;
use solana_sdk::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info, log::*, pubkey::Pubkey,
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, log::*, pubkey::Pubkey,
};
#[derive(Debug, PartialEq)]
@ -25,13 +23,13 @@ fn process_instruction(
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
info!("Program identifier:");
msg!("Program identifier:");
program_id.log();
// Log the provided account keys and instruction input data. In the case of
// the no-op program, no account keys or input data are expected but real
// programs will have specific requirements so they can do their work.
info!("Account keys and instruction input data:");
msg!("Account keys and instruction input data:");
sol_log_params(accounts, instruction_data);
{
@ -42,7 +40,7 @@ fn process_instruction(
let result_str = std::str::from_utf8(&sparkle_heart).unwrap();
assert_eq!(4, result_str.len());
assert_eq!("💖", result_str);
info!(result_str);
msg!(result_str);
}
{