forked from ghe0/brain-to-surreal
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
use detee_shared::general_proto::ReportNodeReq;
|
|
use detee_shared::{
|
|
common_proto::Pubkey, general_proto::brain_general_cli_client::BrainGeneralCliClient,
|
|
};
|
|
mod common;
|
|
use common::prepare_test_env::{prepare_test_setup, TEST_STATE};
|
|
use common::test_utils::{get_pub_key, sign_request};
|
|
|
|
#[tokio::test]
|
|
async fn test_general_balance() {
|
|
prepare_test_setup().await;
|
|
let grpc_channel = TEST_STATE.get().unwrap().clone();
|
|
|
|
let mut brain_general_cli_client = BrainGeneralCliClient::new(grpc_channel.clone());
|
|
|
|
let req_data = Pubkey { pubkey: get_pub_key().unwrap() };
|
|
|
|
let acc_bal = brain_general_cli_client
|
|
.get_balance(sign_request(req_data).unwrap())
|
|
.await
|
|
.unwrap()
|
|
.into_inner();
|
|
|
|
// verify it in db also
|
|
|
|
assert_eq!(acc_bal.balance, 0);
|
|
assert_eq!(acc_bal.tmp_locked, 0);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_report_node() {
|
|
prepare_test_setup().await;
|
|
let grpc_channel = TEST_STATE.get().unwrap().clone();
|
|
|
|
let mut brain_general_cli_client = BrainGeneralCliClient::new(grpc_channel.clone());
|
|
|
|
// TODO: create contract, node and operator in db and use it here
|
|
let req_data = ReportNodeReq {
|
|
admin_pubkey: get_pub_key().unwrap(),
|
|
node_pubkey: String::from("node_pubkey"),
|
|
contract: String::from("uuid"),
|
|
reason: String::from("reason"),
|
|
};
|
|
|
|
let report_error =
|
|
brain_general_cli_client.report_node(sign_request(req_data).unwrap()).await.err().unwrap();
|
|
|
|
assert_eq!(report_error.message(), "No contract found by this ID.");
|
|
|
|
// verify report in db
|
|
}
|