Add local document JSON state commands

This commit is contained in:
Eric Wendland 2026-05-17 19:59:03 +02:00
commit e039a4f81f
11 changed files with 153 additions and 10 deletions

View file

@ -589,6 +589,50 @@ fn document_create_and_status_use_local_store() {
other => panic!("unexpected response: {other:?}"),
}
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::DocumentSet {
name: "notes".to_owned(),
state_json: r#"{ "title": "notes", "items": [1, 2] }"#.to_owned(),
},
)
.expect("document set");
match response {
geth_control::ControlResponse::DocumentSet { state } => {
assert_eq!(state.document.name, "notes");
assert_eq!(state.state_json, r#"{"items":[1,2],"title":"notes"}"#);
assert!(state.document.state_bytes > 2);
}
other => panic!("unexpected response: {other:?}"),
}
let reopened = geth_node::open_node(&paths).expect("reopen node");
let response = geth_node::handle_request(
&reopened,
geth_control::ControlRequest::DocumentGet {
name: "notes".to_owned(),
},
)
.expect("document get");
match response {
geth_control::ControlResponse::DocumentGet { state } => {
assert_eq!(state.state_json, r#"{"items":[1,2],"title":"notes"}"#);
assert!(state.updated_at.0 > 0);
}
other => panic!("unexpected response: {other:?}"),
}
assert!(
geth_node::handle_request(
&node,
geth_control::ControlRequest::DocumentSet {
name: "notes".to_owned(),
state_json: "{".to_owned(),
},
)
.is_err()
);
assert!(
geth_node::handle_request(
&node,