2020-09-30 20:33:29 -07:00
|
|
|
//! Themis client
|
|
|
|
|
|
|
|
use bn::Fr;
|
|
|
|
use solana_banks_client::start_tcp_client;
|
|
|
|
use solana_cli_config::{Config, CONFIG_FILE};
|
|
|
|
use solana_sdk::signature::read_keypair_file;
|
2020-10-05 17:49:38 -07:00
|
|
|
use spl_themis_bn_client::test_e2e;
|
2020-09-30 20:33:29 -07:00
|
|
|
use std::path::Path;
|
|
|
|
use tokio::runtime::Runtime;
|
|
|
|
use url::Url;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let config_file = CONFIG_FILE.as_ref().unwrap();
|
|
|
|
let config = if Path::new(&config_file).exists() {
|
|
|
|
Config::load(&config_file).unwrap()
|
|
|
|
} else {
|
|
|
|
Config::default()
|
|
|
|
};
|
|
|
|
let rpc_banks_url = Config::compute_rpc_banks_url(&config.json_rpc_url);
|
|
|
|
let url = Url::parse(&rpc_banks_url).unwrap();
|
|
|
|
let host_port = (url.host_str().unwrap(), url.port().unwrap());
|
|
|
|
|
|
|
|
Runtime::new().unwrap().block_on(async {
|
|
|
|
let mut banks_client = start_tcp_client(host_port).await.unwrap();
|
|
|
|
let policies = vec![Fr::new(1u64.into()).unwrap(), Fr::new(2u64.into()).unwrap()];
|
|
|
|
let sender_keypair = read_keypair_file(&config.keypair_path).unwrap();
|
|
|
|
test_e2e(
|
|
|
|
&mut banks_client,
|
|
|
|
sender_keypair,
|
|
|
|
policies,
|
|
|
|
1_000,
|
|
|
|
Fr::new(3u64.into()).unwrap(),
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
});
|
|
|
|
}
|