11use async_trait:: async_trait;
2- use std:: collections:: BTreeSet ;
32use std:: { collections:: HashMap , sync:: Arc } ;
43use tokio:: sync:: RwLock ;
54
65use mithril_common:: {
76 StdResult ,
8- entities:: {
9- CardanoTransactionsSigningConfig , Epoch , ProtocolMessage , SignedEntityConfig ,
10- SignedEntityType , SignedEntityTypeDiscriminants , Signer , SingleSignature , TimePoint ,
11- } ,
12- messages:: AggregatorFeaturesMessage ,
7+ entities:: { Epoch , ProtocolMessage , SignedEntityType , Signer , SingleSignature , TimePoint } ,
138 test:: double:: Dummy ,
149} ;
1510use mithril_ticker:: { MithrilTickerService , TickerService } ;
@@ -18,19 +13,14 @@ use mithril_signer::services::{SignaturePublisher, SignerRegistrationPublisher};
1813use mithril_signer:: { entities:: SignerEpochSettings , services:: AggregatorClient } ;
1914
2015pub struct FakeAggregator {
21- signed_entity_config : RwLock < SignedEntityConfig > ,
2216 registered_signers : RwLock < HashMap < Epoch , Vec < Signer > > > ,
2317 ticker_service : Arc < MithrilTickerService > ,
2418 withhold_epoch_settings : RwLock < bool > ,
2519}
2620
2721impl FakeAggregator {
28- pub fn new (
29- signed_entity_config : SignedEntityConfig ,
30- ticker_service : Arc < MithrilTickerService > ,
31- ) -> Self {
22+ pub fn new ( ticker_service : Arc < MithrilTickerService > ) -> Self {
3223 Self {
33- signed_entity_config : RwLock :: new ( signed_entity_config) ,
3424 registered_signers : RwLock :: new ( HashMap :: new ( ) ) ,
3525 ticker_service,
3626 withhold_epoch_settings : RwLock :: new ( true ) ,
@@ -47,14 +37,6 @@ impl FakeAggregator {
4737 * settings = false ;
4838 }
4939
50- pub async fn change_allowed_discriminants (
51- & self ,
52- discriminants : & BTreeSet < SignedEntityTypeDiscriminants > ,
53- ) {
54- let mut signed_entity_config = self . signed_entity_config . write ( ) . await ;
55- signed_entity_config. allowed_discriminants = discriminants. clone ( ) ;
56- }
57-
5840 async fn get_time_point ( & self ) -> StdResult < TimePoint > {
5941 let time_point = self . ticker_service . get_current_time_point ( ) . await ?;
6042 Ok ( time_point)
@@ -123,16 +105,6 @@ impl AggregatorClient for FakeAggregator {
123105 } ) )
124106 }
125107 }
126-
127- async fn retrieve_aggregator_features ( & self ) -> StdResult < AggregatorFeaturesMessage > {
128- let signed_entity_config = self . signed_entity_config . read ( ) . await ;
129-
130- let mut message = AggregatorFeaturesMessage :: dummy ( ) ;
131- message. capabilities . signed_entity_types =
132- signed_entity_config. allowed_discriminants . clone ( ) ;
133-
134- Ok ( message)
135- }
136108}
137109
138110#[ cfg( test) ]
@@ -158,10 +130,7 @@ mod tests {
158130 immutable_observer. clone ( ) ,
159131 ) ) ;
160132
161- (
162- chain_observer,
163- FakeAggregator :: new ( SignedEntityConfig :: dummy ( ) , ticker_service) ,
164- )
133+ ( chain_observer, FakeAggregator :: new ( ticker_service) )
165134 }
166135
167136 #[ tokio:: test]
@@ -249,35 +218,4 @@ mod tests {
249218 assert_eq ! ( 2 , epoch_settings. current_signers. len( ) ) ;
250219 assert_eq ! ( 1 , epoch_settings. next_signers. len( ) ) ;
251220 }
252-
253- #[ tokio:: test]
254- async fn retrieve_aggregator_features ( ) {
255- let ( _chain_observer, fake_aggregator) = init ( ) . await ;
256-
257- {
258- let mut signing_config = fake_aggregator. signed_entity_config . write ( ) . await ;
259- signing_config. allowed_discriminants = SignedEntityTypeDiscriminants :: all ( ) ;
260- signing_config. cardano_transactions_signing_config =
261- CardanoTransactionsSigningConfig :: dummy ( ) ;
262- }
263-
264- let features = fake_aggregator. retrieve_aggregator_features ( ) . await . unwrap ( ) ;
265- assert_eq ! (
266- & SignedEntityTypeDiscriminants :: all( ) ,
267- & features. capabilities. signed_entity_types,
268- ) ;
269-
270- let new_discriminants = BTreeSet :: from ( [
271- SignedEntityTypeDiscriminants :: CardanoTransactions ,
272- SignedEntityTypeDiscriminants :: CardanoImmutableFilesFull ,
273- ] ) ;
274-
275- fake_aggregator. change_allowed_discriminants ( & new_discriminants) . await ;
276-
277- let updated_features = fake_aggregator. retrieve_aggregator_features ( ) . await . unwrap ( ) ;
278- assert_eq ! (
279- & new_discriminants,
280- & updated_features. capabilities. signed_entity_types,
281- ) ;
282- }
283221}
0 commit comments