Skip to content

Commit 4ae9ad8

Browse files
authored
feat: Introduce delete GRPC Web proxies (#1071)
Signed-off-by: gsstoykov <[email protected]>
1 parent efc5dda commit 4ae9ad8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/address_book/node_update_transaction.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ impl NodeUpdateTransaction {
225225
self.data_mut().grpc_proxy_endpoint = Some(grpc_proxy_endpoint);
226226
self
227227
}
228+
229+
/// Deletes the gRPC proxy endpoint and sets it to null.
230+
///
231+
/// This clears the gRPC proxy endpoint field, effectively removing it from the node update.
232+
pub fn delete_grpc_proxy_endpoint(&mut self) -> &mut Self {
233+
self.data_mut().grpc_proxy_endpoint = None;
234+
self
235+
}
228236
}
229237

230238
impl TransactionData for NodeUpdateTransactionData {}
@@ -542,6 +550,26 @@ mod tests {
542550
assert_eq!(tx.get_grpc_proxy_endpoint(), Some(&grpc_proxy_endpoint));
543551
}
544552

553+
#[test]
554+
fn delete_grpc_proxy_endpoint() {
555+
let grpc_proxy_endpoint = make_ip_address_list().into_iter().next().unwrap();
556+
let mut tx = NodeUpdateTransaction::new();
557+
558+
// First set the grpc proxy endpoint
559+
tx.grpc_proxy_endpoint(grpc_proxy_endpoint.clone());
560+
assert_eq!(tx.get_grpc_proxy_endpoint(), Some(&grpc_proxy_endpoint));
561+
562+
// Then delete it
563+
tx.delete_grpc_proxy_endpoint();
564+
assert_eq!(tx.get_grpc_proxy_endpoint(), None);
565+
}
566+
567+
#[test]
568+
#[should_panic]
569+
fn delete_grpc_proxy_endpoint_frozen_panic() {
570+
make_transaction().delete_grpc_proxy_endpoint();
571+
}
572+
545573
#[test]
546574
fn get_set_service_endpoints() {
547575
let service_endpoints = make_ip_address_list();

0 commit comments

Comments
 (0)