@@ -82,3 +82,89 @@ impl MithrilNetworkConfigurationProvider for FakeMithrilNetworkConfigurationProv
82
82
} )
83
83
}
84
84
}
85
+
86
+ #[ cfg( test) ]
87
+ mod tests {
88
+ use std:: {
89
+ collections:: { BTreeSet , HashMap } ,
90
+ sync:: Arc ,
91
+ } ;
92
+
93
+ use mithril_common:: {
94
+ entities:: {
95
+ BlockNumber , CardanoTransactionsSigningConfig , ChainPoint , Epoch , ProtocolParameters ,
96
+ SignedEntityTypeDiscriminants , TimePoint ,
97
+ } ,
98
+ test:: double:: Dummy ,
99
+ } ;
100
+ use mithril_ticker:: MithrilTickerService ;
101
+
102
+ use crate :: {
103
+ interface:: MithrilNetworkConfigurationProvider , model:: SignedEntityTypeConfiguration ,
104
+ test:: double:: mithril_network_configuration_provider:: FakeMithrilNetworkConfigurationProvider ,
105
+ } ;
106
+ use mithril_cardano_node_chain:: test:: double:: FakeChainObserver ;
107
+ use mithril_cardano_node_internal_database:: test:: double:: DumbImmutableFileObserver ;
108
+
109
+ async fn ticker_service ( ) -> Arc < MithrilTickerService > {
110
+ let immutable_observer = Arc :: new ( DumbImmutableFileObserver :: new ( ) ) ;
111
+ immutable_observer. shall_return ( Some ( 1 ) ) . await ;
112
+ let chain_observer = Arc :: new ( FakeChainObserver :: new ( Some ( TimePoint {
113
+ epoch : Epoch ( 1 ) ,
114
+ immutable_file_number : 1 ,
115
+ chain_point : ChainPoint :: dummy ( ) ,
116
+ } ) ) ) ;
117
+
118
+ Arc :: new ( MithrilTickerService :: new (
119
+ chain_observer. clone ( ) ,
120
+ immutable_observer. clone ( ) ,
121
+ ) )
122
+ }
123
+
124
+ #[ tokio:: test]
125
+ async fn test_get ( ) {
126
+ let signer_registration_protocol_parameters = ProtocolParameters {
127
+ k : 2 ,
128
+ m : 3 ,
129
+ phi_f : 0.5 ,
130
+ } ;
131
+ let available_signed_entity_types = BTreeSet :: from ( [
132
+ SignedEntityTypeDiscriminants :: MithrilStakeDistribution ,
133
+ SignedEntityTypeDiscriminants :: CardanoTransactions ,
134
+ ] ) ;
135
+ let signed_entity_types_config = HashMap :: from ( [ (
136
+ SignedEntityTypeDiscriminants :: CardanoTransactions ,
137
+ SignedEntityTypeConfiguration :: CardanoTransactions ( CardanoTransactionsSigningConfig {
138
+ security_parameter : BlockNumber ( 12 ) ,
139
+ step : BlockNumber ( 10 ) ,
140
+ } ) ,
141
+ ) ] ) ;
142
+
143
+ let mithril_network_configuration_provider = FakeMithrilNetworkConfigurationProvider :: new (
144
+ signer_registration_protocol_parameters. clone ( ) ,
145
+ available_signed_entity_types. clone ( ) ,
146
+ signed_entity_types_config. clone ( ) ,
147
+ ticker_service ( ) . await ,
148
+ ) ;
149
+
150
+ let actual_config = mithril_network_configuration_provider. get ( ) . await . unwrap ( ) ;
151
+
152
+ assert_eq ! ( actual_config. epoch, Epoch ( 1 ) ) ;
153
+ assert_eq ! (
154
+ actual_config. signer_registration_protocol_parameters,
155
+ ProtocolParameters {
156
+ k: 2 ,
157
+ m: 3 ,
158
+ phi_f: 0.5
159
+ }
160
+ ) ;
161
+ assert_eq ! (
162
+ actual_config. available_signed_entity_types,
163
+ available_signed_entity_types
164
+ ) ;
165
+ assert_eq ! (
166
+ actual_config. signed_entity_types_config,
167
+ signed_entity_types_config
168
+ ) ;
169
+ }
170
+ }
0 commit comments