test listing operators and list vm contracts

This commit is contained in:
Noor 2025-04-25 00:00:05 +05:30
parent 413ac50324
commit 55549ba10d
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146

@ -1,10 +1,14 @@
use detee_shared::common_proto::Empty;
use detee_shared::general_proto::ReportNodeReq;
use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient;
use detee_shared::vm_proto::ListVmContractsReq;
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};
use tokio_stream::StreamExt;
#[tokio::test]
async fn test_general_balance() {
@ -49,3 +53,71 @@ async fn test_report_node() {
// verify report in db
}
#[tokio::test]
// TODO: register some operators before testing this
async fn test_list_operators() {
prepare_test_setup().await;
let grpc_channel = TEST_STATE.get().unwrap().clone();
let mut brain_general_cli_client = BrainGeneralCliClient::new(grpc_channel.clone());
let mut grpc_stream = brain_general_cli_client
.list_operators(sign_request(Empty {}).unwrap())
.await
.unwrap()
.into_inner();
let mut operators = Vec::new();
while let Some(stream_update) = grpc_stream.next().await {
match stream_update {
Ok(op) => {
operators.push(op);
}
Err(e) => {
panic!("Received error instead of operators: {e:?}");
}
}
}
assert!(!operators.is_empty())
// verify report in db
}
#[tokio::test]
// TODO: create vm for this user before testing this
async fn test_list_vm_contracts() {
prepare_test_setup().await;
let grpc_channel = TEST_STATE.get().unwrap().clone();
let mut brain_general_cli_client = BrainVmCliClient::new(grpc_channel.clone());
let req_data = ListVmContractsReq {
wallet: get_pub_key().unwrap(),
uuid: String::from("uuid"),
as_operator: false,
};
let mut grpc_stream = brain_general_cli_client
.list_vm_contracts(sign_request(req_data).unwrap())
.await
.unwrap()
.into_inner();
let mut vm_contracts = Vec::new();
while let Some(stream_update) = grpc_stream.next().await {
match stream_update {
Ok(vm_c) => {
vm_contracts.push(vm_c);
}
Err(e) => {
panic!("Received error instead of vm_contracts: {e:?}");
}
}
}
assert!(vm_contracts.is_empty())
// verify report in db
}