@@ -13,6 +13,15 @@ pub struct EraMarker {
13
13
epoch : Option < Epoch > ,
14
14
}
15
15
16
+ impl EraMarker {
17
+ /// instanciate a new [EraMarker].
18
+ pub fn new ( name : & str , epoch : Option < Epoch > ) -> Self {
19
+ let name = name. to_string ( ) ;
20
+
21
+ Self { name, epoch }
22
+ }
23
+ }
24
+
16
25
/// Adapters are responsible of technically reading the information of
17
26
/// [EraMarker]s from a backend.
18
27
#[ async_trait]
@@ -146,38 +155,21 @@ impl EraReader {
146
155
147
156
#[ cfg( test) ]
148
157
mod tests {
158
+ use super :: super :: adapters:: DummyAdapter ;
149
159
use super :: * ;
150
160
151
- #[ derive( Default ) ]
152
- struct DummyAdapter {
153
- markers : Vec < EraMarker > ,
154
- }
155
-
156
- impl DummyAdapter {
157
- pub fn set_markers ( & mut self , markers : Vec < EraMarker > ) {
158
- self . markers = markers;
159
- }
160
- }
161
-
162
- #[ async_trait]
163
- impl EraReaderAdapter for DummyAdapter {
164
- async fn read ( & self ) -> Result < Vec < EraMarker > , Box < dyn StdError > > {
165
- Ok ( self . markers . clone ( ) )
166
- }
167
- }
168
-
169
161
fn get_basic_marker_sample ( ) -> Vec < EraMarker > {
170
162
vec ! [
171
163
EraMarker {
172
164
name: "one" . to_string( ) ,
173
165
epoch: Some ( Epoch ( 1 ) ) ,
174
166
} ,
175
167
EraMarker {
176
- name: "thales" . to_string( ) ,
168
+ name: SupportedEra :: dummy ( ) . to_string( ) ,
177
169
epoch: None ,
178
170
} ,
179
171
EraMarker {
180
- name: "thales" . to_string( ) ,
172
+ name: SupportedEra :: dummy ( ) . to_string( ) ,
181
173
epoch: Some ( Epoch ( 10 ) ) ,
182
174
} ,
183
175
]
@@ -196,7 +188,7 @@ mod tests {
196
188
EraEpochToken {
197
189
current_epoch: Epoch ( 10 ) ,
198
190
current_era: EraMarker {
199
- name: "thales" . to_string( ) ,
191
+ name: SupportedEra :: dummy ( ) . to_string( ) ,
200
192
epoch: Some ( Epoch ( 10 ) )
201
193
} ,
202
194
next_era: None ,
@@ -243,7 +235,7 @@ mod tests {
243
235
epoch: Some ( Epoch ( 1 ) )
244
236
} ,
245
237
next_era: Some ( EraMarker {
246
- name: "thales" . to_string( ) ,
238
+ name: SupportedEra :: dummy ( ) . to_string( ) ,
247
239
epoch: Some ( Epoch ( 10 ) )
248
240
} ) ,
249
241
} ,
0 commit comments