mirror of
https://github.com/fluencelabs/fluent-pad
synced 2025-04-25 00:42:14 +00:00
fix outofbound, add more complex error msg
This commit is contained in:
parent
93081b4523
commit
c3a45d6c9f
@ -33,7 +33,7 @@ pub struct AddServiceResult {
|
||||
#[fce]
|
||||
fn add(msg: String, auth: bool) -> AddServiceResult {
|
||||
fn add_impl(msg: String, auth: bool) -> Result<u64> {
|
||||
is_authenticated(auth, 2)?;
|
||||
is_authenticated(auth, 1)?;
|
||||
add_message(msg)
|
||||
}
|
||||
|
||||
@ -102,7 +102,8 @@ pub fn is_authenticated(auth: bool, index: u64) -> Result<()> {
|
||||
|
||||
(st.peer_pk == t.peer_pk && st.function_name == t.fn_name
|
||||
&& st.service_id == t.service_id &&
|
||||
st.json_path == t.json_path && auth).ok_or_else(|| Unauthorized("Tetraplet did not pass the check.".to_string()))
|
||||
st.json_path == t.json_path && auth)
|
||||
.ok_or_else(|| Unauthorized(format!("Tetraplet did not pass the check. Expected: {:?}, actual: {:?}", t, st)))
|
||||
}
|
||||
}
|
||||
}
|
@ -41,10 +41,11 @@ pub struct GetMessagesServiceResult {
|
||||
fn get_all() {
|
||||
let mut app_service = create_app_service(TEST_CONFIG_PATH);
|
||||
|
||||
let result = call_app_service!(app_service, "add", json!(["body_1"]));
|
||||
call_app_service!(app_service, "set_tetraplet", json!(["", "", "", ""]));
|
||||
let result = call_app_service!(app_service, "add", json!(["body_1", 1]));
|
||||
assert_eq!(result, json!({ "ret_code": 0, "err_msg": "", "msg_id": 0 }));
|
||||
|
||||
let result = call_app_service!(app_service, "add", json!(["body_2"]));
|
||||
let result = call_app_service!(app_service, "add", json!(["body_2", 1]));
|
||||
assert_eq!(result, json!({ "ret_code": 0, "err_msg": "", "msg_id": 1 }));
|
||||
|
||||
let result = call_app_service!(app_service, "get_all", json!([]));
|
||||
|
Loading…
x
Reference in New Issue
Block a user