Add local in-memory pubsub

This commit is contained in:
Eric Wendland 2026-05-17 18:23:51 +02:00
commit 6c85a341b8
13 changed files with 246 additions and 14 deletions

View file

@ -734,6 +734,76 @@ fn bearer_access_create_list_revoke_uses_resource_scoped_auth_ops() {
);
}
#[test]
fn pubsub_pub_sub_uses_lossy_in_memory_runtime() {
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::PubsubPub {
topic: "presence/laptop".to_owned(),
message: "online".to_owned(),
},
)
.expect("publish");
match response {
geth_control::ControlResponse::PubsubPublished { message } => {
assert_eq!(message.topic.to_string(), "presence/laptop");
assert_eq!(message.message, "online");
}
other => panic!("unexpected response: {other:?}"),
}
let response = geth_node::handle_request(
&node,
geth_control::ControlRequest::PubsubSub {
topic: "presence/laptop".to_owned(),
},
)
.expect("subscribe snapshot");
match response {
geth_control::ControlResponse::PubsubMessages {
topic,
messages,
note,
} => {
assert_eq!(topic, "presence/laptop");
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].message, "online");
assert!(note.contains("not authoritative storage"));
}
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::PubsubSub {
topic: "presence/laptop".to_owned(),
},
)
.expect("subscribe reopened snapshot");
match response {
geth_control::ControlResponse::PubsubMessages { messages, .. } => {
assert!(messages.is_empty());
}
other => panic!("unexpected response: {other:?}"),
}
assert!(
geth_node::handle_request(
&node,
geth_control::ControlRequest::PubsubPub {
topic: "presence/laptop".to_owned(),
message: String::new(),
},
)
.is_err()
);
}
#[test]
fn ssh_cert_request_approval_and_revocation_export_use_local_state() {
let home = tempfile::tempdir().expect("tempdir");