cuprate_test_utils::rpc::data::json

Constant SET_BANS_IP_REQUEST

Source
pub const SET_BANS_IP_REQUEST: &str = r#"{
  "jsonrpc": "2.0",
  "id": "0",
  "method": "set_bans",
  "params": {
    "bans": [{
      "ip": 838969536,
      "ban": true,
      "seconds": 30
    }]
  }
}"#;
Expand description

Documentation, response.

This is the same as SET_BANS_REQUEST and SET_BANS_RESPONSE but it uses the ip parameter.

use cuprate_test_utils::rpc::data::json::*;
use serde_json::{to_value, Value};

let value = serde_json::from_str::<Value>(&SET_BANS_IP_REQUEST).unwrap();
let Value::Object(map) = value else {
    panic!();
};

assert_eq!(map.get("jsonrpc").unwrap(), "2.0");
map.get("id").unwrap();

if map.get("method").is_some() {
    return;
}

if map.get("result").is_none() {
    map.get("error").unwrap();
}