Add local KV store commands

This commit is contained in:
Eric Wendland 2026-05-16 21:52:35 +02:00
commit 1a0f1e7671
14 changed files with 395 additions and 13 deletions

View file

@ -454,6 +454,97 @@ fn db_add_and_status_register_local_db_metadata() {
);
}
#[test]
fn kv_create_set_get_use_local_store() {
let home = tempfile::tempdir().expect("tempdir");
let paths = geth_config::GethPaths::from_home(home.path());
let node = geth_node::init_node(&paths).expect("init node");
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::KvCreate {
name: "prefs".to_owned(),
},
)
.expect("create kv");
match response {
geth_control::ControlResponse::KvCreated { kv } => {
assert_eq!(kv.name, "prefs");
assert_eq!(kv.sync_status, "local-only");
}
other => panic!("unexpected response: {other:?}"),
}
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::KvSet {
name: "prefs".to_owned(),
key: "apps/foo/theme".to_owned(),
value: "dark".to_owned(),
},
)
.expect("set kv");
match response {
geth_control::ControlResponse::KvSet { entry } => {
assert_eq!(entry.store.to_string(), "kv:prefs");
assert_eq!(entry.key, "apps/foo/theme");
assert_eq!(entry.value, "dark");
}
other => panic!("unexpected response: {other:?}"),
}
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::KvGet {
name: "prefs".to_owned(),
key: "apps/foo/theme".to_owned(),
},
)
.expect("get kv");
match response {
geth_control::ControlResponse::KvGet { entry } => {
assert_eq!(entry.expect("entry").value, "dark");
}
other => panic!("unexpected response: {other:?}"),
}
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::KvGet {
name: "prefs".to_owned(),
key: "apps/foo/missing".to_owned(),
},
)
.expect("get missing kv");
match response {
geth_control::ControlResponse::KvGet { entry } => {
assert!(entry.is_none());
}
other => panic!("unexpected response: {other:?}"),
}
assert!(
geth_node::handle_request(
&node,
geth_control::ControlRequest::KvCreate {
name: "../bad".to_owned(),
},
)
.is_err()
);
assert!(
geth_node::handle_request(
&node,
geth_control::ControlRequest::KvSet {
name: "missing".to_owned(),
key: "apps/foo/theme".to_owned(),
value: "dark".to_owned(),
},
)
.is_err()
);
}
#[test]
fn ssh_cert_request_approval_and_revocation_export_use_local_state() {
let home = tempfile::tempdir().expect("tempdir");