Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(crypto): CRP-2382 cleanup CSP constructors
- Loading branch information
Showing
8 changed files
with
66 additions
and
95 deletions.
There are no files selected for viewing
76 changes: 0 additions & 76 deletions
76
rs/crypto/internal/crypto_service_provider/src/builder/mod.rs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
rs/crypto/internal/crypto_service_provider/src/builder_for_test/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::*; | ||
|
||
pub struct CspBuilderForTest { | ||
vault: Box<dyn FnOnce() -> Arc<dyn CspVault>>, | ||
logger: ReplicaLogger, | ||
metrics: Arc<CryptoMetrics>, | ||
} | ||
|
||
impl CspBuilderForTest { | ||
pub fn with_vault<V: CspVault + 'static>(self, vault: V) -> Self { | ||
Self { | ||
vault: Box::new(|| Arc::new(vault)), | ||
logger: self.logger, | ||
metrics: self.metrics, | ||
} | ||
} | ||
|
||
pub fn build(self) -> Csp { | ||
Csp { | ||
csp_vault: (self.vault)(), | ||
logger: self.logger, | ||
metrics: self.metrics, | ||
} | ||
} | ||
} | ||
|
||
impl Csp { | ||
pub fn builder_for_test() -> CspBuilderForTest { | ||
CspBuilderForTest { | ||
vault: Box::new(|| LocalCspVault::builder_for_test().build_into_arc()), | ||
logger: no_op_logger(), | ||
metrics: Arc::new(CryptoMetrics::none()), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters