diff --git a/tests/common/prepare_test_env.rs b/tests/common/prepare_test_env.rs index aa62bb6..7813d3b 100644 --- a/tests/common/prepare_test_env.rs +++ b/tests/common/prepare_test_env.rs @@ -1,4 +1,3 @@ -use super::test_utils::{get_pub_key, sign_request}; use detee_shared::{ general_proto::brain_general_cli_server::BrainGeneralCliServer, vm_proto::brain_vm_cli_server::BrainVmCliServer, @@ -21,7 +20,7 @@ pub async fn prepare_test_db() { .expect("Failed to initialize the database"); 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(); } diff --git a/tests/grpcs_test.rs b/tests/grpcs_test.rs index bcc9ef5..270cb7d 100644 --- a/tests/grpcs_test.rs +++ b/tests/grpcs_test.rs @@ -1,3 +1,4 @@ +use detee_shared::general_proto::ReportNodeReq; use detee_shared::{ 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.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 +}