File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
mithril-aggregator/src/services/signature_consumer Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: future;
2
+
3
+ use async_trait:: async_trait;
4
+
5
+ use super :: SignatureConsumer ;
6
+
7
+ /// A no-op implementation of the [SignatureConsumer] trait that will never return signatures.
8
+ #[ derive( Default ) ]
9
+ pub struct SignatureConsumerNoop ;
10
+
11
+ #[ async_trait]
12
+ impl SignatureConsumer for SignatureConsumerNoop {
13
+ async fn get_signatures (
14
+ & self ,
15
+ ) -> mithril_common:: StdResult <
16
+ Vec < (
17
+ mithril_common:: entities:: SingleSignature ,
18
+ mithril_common:: entities:: SignedEntityType ,
19
+ ) > ,
20
+ > {
21
+ future:: pending ( ) . await
22
+ }
23
+ }
24
+
25
+ #[ cfg( test) ]
26
+ mod tests {
27
+ use anyhow:: anyhow;
28
+ use tokio:: time:: { sleep, Duration } ;
29
+
30
+ use super :: * ;
31
+
32
+ #[ tokio:: test]
33
+ async fn signature_consumer_noop_never_returns ( ) {
34
+ let consumer = SignatureConsumerNoop ;
35
+
36
+ let result = tokio:: select!(
37
+ _res = sleep( Duration :: from_millis( 100 ) ) => { Err ( anyhow!( "Timeout" ) ) } ,
38
+ _res = consumer. get_signatures( ) => { Ok ( ( ) ) } ,
39
+ ) ;
40
+
41
+ result. expect_err ( "Should have timed out" ) ;
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments