test database cleanup
test report node
This commit is contained in:
		
							parent
							
								
									a9168d3204
								
							
						
					
					
						commit
						0543130cd5
					
				| @ -1,4 +1,3 @@ | |||||||
| use super::test_utils::{get_pub_key, sign_request}; |  | ||||||
| use detee_shared::{ | use detee_shared::{ | ||||||
|     general_proto::brain_general_cli_server::BrainGeneralCliServer, |     general_proto::brain_general_cli_server::BrainGeneralCliServer, | ||||||
|     vm_proto::brain_vm_cli_server::BrainVmCliServer, |     vm_proto::brain_vm_cli_server::BrainVmCliServer, | ||||||
| @ -21,7 +20,7 @@ pub async fn prepare_test_db() { | |||||||
|         .expect("Failed to initialize the database"); |         .expect("Failed to initialize the database"); | ||||||
| 
 | 
 | ||||||
|     let old_brain_data = surreal_brain::old_brain::BrainData::load_from_disk().unwrap(); |     let old_brain_data = surreal_brain::old_brain::BrainData::load_from_disk().unwrap(); | ||||||
|     // cleanup old brain data
 |     let _ = surreal_brain::db::DB.query(format!("REMOVE DATABASE {DB_NAME}")).await; | ||||||
|     surreal_brain::db::migration0(&old_brain_data).await.unwrap(); |     surreal_brain::db::migration0(&old_brain_data).await.unwrap(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | use detee_shared::general_proto::ReportNodeReq; | ||||||
| use detee_shared::{ | use detee_shared::{ | ||||||
|     common_proto::Pubkey, general_proto::brain_general_cli_client::BrainGeneralCliClient, |     common_proto::Pubkey, general_proto::brain_general_cli_client::BrainGeneralCliClient, | ||||||
| }; | }; | ||||||
| @ -25,3 +26,26 @@ async fn test_general_balance() { | |||||||
|     assert_eq!(acc_bal.balance, 0); |     assert_eq!(acc_bal.balance, 0); | ||||||
|     assert_eq!(acc_bal.tmp_locked, 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
 | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user