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