From 6a7f523cdb02d112610cf74fd2df34f424520b0d Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 23 Nov 2017 08:07:46 +0300 Subject: [PATCH] SecretStore: generation_is_not_retried_if_tried_in_the_same_cycle --- .../src/listener/service_contract_listener.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/secret_store/src/listener/service_contract_listener.rs b/secret_store/src/listener/service_contract_listener.rs index 44026107b..3a85efd6a 100644 --- a/secret_store/src/listener/service_contract_listener.rs +++ b/secret_store/src/listener/service_contract_listener.rs @@ -780,4 +780,15 @@ mod tests { ServiceContractListener::process_service_task(&listener.data, ServiceTask::RestoreServerKey(Default::default())).unwrap(); assert_eq!(*contract.published_keys.lock(), vec![(Default::default(), key_share.public)]); } + + #[test] + fn generation_is_not_retried_if_tried_in_the_same_cycle() { + let mut contract = DummyServiceContract::default(); + contract.pending_requests.push((false, ServiceTask::GenerateServerKey(Default::default(), Default::default()))); + let key_server = Arc::new(DummyKeyServer::default()); + let listener = make_service_contract_listener(Some(Arc::new(contract)), Some(key_server.clone()), None); + listener.data.retry_data.lock().generated_keys.insert(Default::default()); + ServiceContractListener::retry_pending_requests(&listener.data); + assert_eq!(key_server.generation_requests_count.load(Ordering::Relaxed), 0); + } }