2022-12-28 05:01:04 -08:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2023-01-12 00:55:30 -08:00
|
|
|
use bench::helpers::BenchHelper;
|
2023-01-02 05:38:59 -08:00
|
|
|
use lite_rpc::DEFAULT_LITE_RPC_ADDR;
|
2022-12-10 09:31:37 -08:00
|
|
|
use log::info;
|
2023-02-02 03:08:27 -08:00
|
|
|
use solana_rpc_client::{nonblocking::rpc_client::RpcClient, rpc_client::SerializableTransaction};
|
2023-01-16 21:32:19 -08:00
|
|
|
use solana_sdk::commitment_config::CommitmentConfig;
|
2022-12-10 09:31:37 -08:00
|
|
|
|
2022-12-27 02:11:06 -08:00
|
|
|
const AMOUNT: usize = 5;
|
2022-12-10 09:31:37 -08:00
|
|
|
|
|
|
|
#[tokio::test]
|
2023-01-10 10:32:57 -08:00
|
|
|
async fn send_and_confirm_txs_get_signature_statuses() {
|
2023-01-11 23:05:13 -08:00
|
|
|
tracing_subscriber::fmt::init();
|
2022-12-10 09:31:37 -08:00
|
|
|
|
2023-01-02 05:38:59 -08:00
|
|
|
let rpc_client = Arc::new(RpcClient::new(DEFAULT_LITE_RPC_ADDR.to_string()));
|
|
|
|
let bench_helper = BenchHelper::new(rpc_client.clone());
|
2022-12-28 05:01:04 -08:00
|
|
|
|
2023-01-16 21:32:19 -08:00
|
|
|
let funded_payer = bench_helper.get_payer().await.unwrap();
|
2022-12-10 09:31:37 -08:00
|
|
|
|
2022-12-28 05:01:04 -08:00
|
|
|
let txs = bench_helper
|
|
|
|
.generate_txs(AMOUNT, &funded_payer)
|
2022-12-10 09:31:37 -08:00
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
info!("Sending and Confirming {AMOUNT} tx(s)");
|
|
|
|
|
|
|
|
for tx in &txs {
|
2023-01-02 05:38:59 -08:00
|
|
|
rpc_client.send_transaction(tx).await.unwrap();
|
|
|
|
info!("Tx {}", tx.get_signature());
|
2022-12-10 09:31:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
for tx in &txs {
|
|
|
|
let sig = tx.get_signature();
|
|
|
|
info!("Confirming {sig}");
|
2022-12-28 05:01:04 -08:00
|
|
|
bench_helper
|
2023-01-02 05:38:59 -08:00
|
|
|
.wait_till_signature_status(sig, CommitmentConfig::confirmed())
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-12-10 09:31:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
info!("Sent and Confirmed {AMOUNT} tx(s)");
|
|
|
|
}
|
2023-01-10 10:32:57 -08:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn send_and_confirm_tx_rpc_client() {
|
|
|
|
let rpc_client = Arc::new(RpcClient::new(DEFAULT_LITE_RPC_ADDR.to_string()));
|
|
|
|
let bench_helper = BenchHelper::new(rpc_client.clone());
|
|
|
|
|
2023-01-16 21:32:19 -08:00
|
|
|
let funded_payer = bench_helper.get_payer().await.unwrap();
|
2023-01-10 10:32:57 -08:00
|
|
|
|
2023-01-10 11:57:20 -08:00
|
|
|
let tx = &bench_helper.generate_txs(1, &funded_payer).await.unwrap()[0];
|
2023-01-10 10:32:57 -08:00
|
|
|
let sig = tx.get_signature();
|
|
|
|
|
2023-01-10 11:57:20 -08:00
|
|
|
bench_helper.send_and_confirm_transaction(tx).await.unwrap();
|
2023-01-10 10:32:57 -08:00
|
|
|
|
|
|
|
info!("Sent and Confirmed {sig}");
|
|
|
|
}
|