test listing operators and list vm contracts
This commit is contained in:
		
							parent
							
								
									0543130cd5
								
							
						
					
					
						commit
						bea41c939d
					
				| @ -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
 | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user