* Don't use move semantics if not needed (#8793) * SDK: Deboilerplate `TransportError` with thiserror * Enable interchange between `TransportError` and `ClientError` * SDK: Retval consistency between `Client` and `AsyncClient` traits * Client: Introduce/use `Result` type * Client: Remove unused `RpcResponseIn` type * Client: Rename `RpcResponse` to more appropriate `RpcResult` * Client: Death to `io::Result` return types * Client: Struct-ify `ClientError` * Client: Add optional `command` parameter to `ClientError` * RpcClient: Stop abusing `io::Error` (low-fruit) * ClientError: Use `thiserror`'s `Display` impl * Extend `RpcError`'s utility * RpcClient: Stop abusing `io::Error` (the rest) * CLI: Shim `main()` so we can `Display` format errors * claputils: format input validator errors with `Display` They are intended to be displayed to users * SDK: `thiserror` for hash and sig parse erros * Keygen: Shim main to format errors with `Display` * SDK: `thiserror` for `InstructionError` * CLI: `thiserror` for `CliError` * CLI: Format user messages with `Display` * Client: Tweak `Display` for `ClientError` * RpcClient: Improve messaging when TX cannot be confirmed * fu death io res retval * CLI/Keygen - fix shell return value on error * Tweak `InstructionError` `Display` messages as per review * Cleanup hackjob return code fix * Embrace that which you hate most * Too much... Co-authored-by: Jack May <jack@solana.com>
29 lines
932 B
Rust
29 lines
932 B
Rust
use solana_faucet::faucet::{request_airdrop_transaction, run_local_faucet};
|
|
use solana_sdk::{
|
|
hash::Hash,
|
|
message::Message,
|
|
pubkey::Pubkey,
|
|
signature::{Keypair, Signer},
|
|
system_instruction,
|
|
transaction::Transaction,
|
|
};
|
|
use std::sync::mpsc::channel;
|
|
|
|
#[test]
|
|
fn test_local_faucet() {
|
|
let keypair = Keypair::new();
|
|
let to = Pubkey::new_rand();
|
|
let lamports = 50;
|
|
let blockhash = Hash::new(&to.as_ref());
|
|
let create_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports);
|
|
let message = Message::new(&[create_instruction]);
|
|
let expected_tx = Transaction::new(&[&keypair], message, blockhash);
|
|
|
|
let (sender, receiver) = channel();
|
|
run_local_faucet(keypair, sender, None);
|
|
let faucet_addr = receiver.recv().unwrap();
|
|
|
|
let result = request_airdrop_transaction(&faucet_addr, &to, lamports, blockhash);
|
|
assert_eq!(expected_tx, result.unwrap());
|
|
}
|