Merge api/program into single units (#7061)

This commit is contained in:
Jack May
2019-11-20 16:32:19 -08:00
committed by GitHub
parent 186bf7ae32
commit 3415db9739
105 changed files with 224 additions and 4095 deletions

View File

@@ -0,0 +1,21 @@
[package]
name = "solana-failure-program"
version = "0.21.0"
description = "Solana failure program"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
log = "0.4.8"
solana-sdk = { path = "../../sdk", version = "0.21.0" }
[dev-dependencies]
solana-runtime = { path = "../../runtime", version = "0.21.0" }
[lib]
crate-type = ["lib", "cdylib"]
name = "solana_failure_program"

View File

@@ -0,0 +1,23 @@
use solana_sdk::account::KeyedAccount;
use solana_sdk::instruction::InstructionError;
use solana_sdk::pubkey::Pubkey;
pub const FAILURE_PROGRAM_ID: [u8; 32] = [
3, 188, 64, 34, 171, 255, 206, 240, 89, 4, 11, 161, 30, 250, 18, 135, 195, 82, 6, 72, 220, 142,
53, 26, 45, 144, 70, 112, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
FAILURE_PROGRAM_ID,
"FaiLure111111111111111111111111111111111111",
solana_failure_program,
process_instruction
);
fn process_instruction(
_program_id: &Pubkey,
_keyed_accounts: &mut [KeyedAccount],
_data: &[u8],
) -> Result<(), InstructionError> {
Err(InstructionError::GenericError)
}

View File

@@ -0,0 +1,28 @@
use solana_runtime::bank::Bank;
use solana_runtime::bank_client::BankClient;
use solana_runtime::loader_utils::create_invoke_instruction;
use solana_sdk::client::SyncClient;
use solana_sdk::genesis_config::create_genesis_config;
use solana_sdk::instruction::InstructionError;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::KeypairUtil;
use solana_sdk::transaction::TransactionError;
#[test]
fn test_program_native_failure() {
let (genesis_config, alice_keypair) = create_genesis_config(50);
let program_id = Pubkey::new_rand();
let bank = Bank::new(&genesis_config);
bank.register_native_instruction_processor("solana_failure_program", &program_id);
// Call user program
let instruction = create_invoke_instruction(alice_keypair.pubkey(), program_id, &1u8);
let bank_client = BankClient::new(bank);
assert_eq!(
bank_client
.send_instruction(&alice_keypair, instruction)
.unwrap_err()
.unwrap(),
TransactionError::InstructionError(0, InstructionError::GenericError)
);
}