forked from starknet-io/starknet-devnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_restrictive_mode.rs
More file actions
57 lines (48 loc) · 1.61 KB
/
Copy pathtest_restrictive_mode.rs
File metadata and controls
57 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use serde_json::json;
use crate::common::background_devnet::BackgroundDevnet;
use crate::common::errors::RpcError;
use crate::common::reqwest_client::{GetReqwestSender, HttpEmptyResponseBody};
#[tokio::test]
async fn restrictive_mode_with_default_methods_doesnt_affect_other_functionality() {
let devnet = BackgroundDevnet::spawn_with_additional_args(&["--restrictive-mode"])
.await
.expect("Could not start Devnet");
devnet
.reqwest_client()
.get_json_async("/config", None)
.await
.map(|_: HttpEmptyResponseBody| ())
.unwrap();
}
#[tokio::test]
async fn restrictive_mode_with_default_methods() {
let devnet = BackgroundDevnet::spawn_with_additional_args(&["--restrictive-mode"])
.await
.expect("Could not start Devnet");
let json_rpc_error = devnet
.send_custom_rpc("devnet_mint", json!({ "address": "0x1", "amount": 1 }))
.await
.unwrap_err();
assert_eq!(
json_rpc_error,
RpcError { code: -32604, message: "Method forbidden".into(), data: None }
);
}
#[tokio::test]
async fn restrictive_mode_with_custom_methods() {
let devnet = BackgroundDevnet::spawn_with_additional_args(&[
"--restrictive-mode",
"devnet_load",
"devnet_mint",
])
.await
.expect("Could not start Devnet");
let json_rpc_error = devnet
.send_custom_rpc("devnet_mint", json!({ "address": "0x1", "amount": 1 }))
.await
.unwrap_err();
assert_eq!(
json_rpc_error,
RpcError { code: -32604, message: "Method forbidden".into(), data: None }
);
}