@@ -6,8 +6,8 @@ use slog::error;
66use slog:: warn;
77use slog:: Logger ;
88
9- use crate :: components:: network_provider:: ChainIdentifierStore ;
10- use crate :: components:: network_provider:: ChainIdentifierStoreError ;
9+ use crate :: components:: network_provider:: ChainIdentifierValidationError ;
10+ use crate :: components:: network_provider:: ChainIdentifierValidator ;
1111use crate :: components:: network_provider:: ChainName ;
1212use crate :: components:: network_provider:: NetworkDetails ;
1313use crate :: components:: network_provider:: ProviderCheck ;
@@ -17,11 +17,11 @@ use crate::components::network_provider::ProviderName;
1717/// Requires providers to have the same network version and genesis hash as one
1818/// previously stored in the database.
1919pub struct GenesisHashCheck {
20- chain_identifier_store : Arc < dyn ChainIdentifierStore > ,
20+ chain_identifier_store : Arc < dyn ChainIdentifierValidator > ,
2121}
2222
2323impl GenesisHashCheck {
24- pub fn new ( chain_identifier_store : Arc < dyn ChainIdentifierStore > ) -> Self {
24+ pub fn new ( chain_identifier_store : Arc < dyn ChainIdentifierValidator > ) -> Self {
2525 Self {
2626 chain_identifier_store,
2727 }
@@ -62,7 +62,7 @@ impl ProviderCheck for GenesisHashCheck {
6262 . chain_identifier_store
6363 . validate_identifier ( chain_name, & chain_identifier) ;
6464
65- use ChainIdentifierStoreError :: * ;
65+ use ChainIdentifierValidationError :: * ;
6666
6767 match check_result {
6868 Ok ( ( ) ) => ProviderCheckStatus :: Valid ,
@@ -154,16 +154,16 @@ mod tests {
154154
155155 #[ derive( Default ) ]
156156 struct TestChainIdentifierStore {
157- validate_identifier_calls : Mutex < Vec < Result < ( ) , ChainIdentifierStoreError > > > ,
158- update_identifier_calls : Mutex < Vec < Result < ( ) , ChainIdentifierStoreError > > > ,
157+ validate_identifier_calls : Mutex < Vec < Result < ( ) , ChainIdentifierValidationError > > > ,
158+ update_identifier_calls : Mutex < Vec < Result < ( ) , ChainIdentifierValidationError > > > ,
159159 }
160160
161161 impl TestChainIdentifierStore {
162- fn validate_identifier_call ( & self , x : Result < ( ) , ChainIdentifierStoreError > ) {
162+ fn validate_identifier_call ( & self , x : Result < ( ) , ChainIdentifierValidationError > ) {
163163 self . validate_identifier_calls . lock ( ) . unwrap ( ) . push ( x)
164164 }
165165
166- fn update_identifier_call ( & self , x : Result < ( ) , ChainIdentifierStoreError > ) {
166+ fn update_identifier_call ( & self , x : Result < ( ) , ChainIdentifierValidationError > ) {
167167 self . update_identifier_calls . lock ( ) . unwrap ( ) . push ( x)
168168 }
169169 }
@@ -181,20 +181,20 @@ mod tests {
181181 }
182182
183183 #[ async_trait]
184- impl ChainIdentifierStore for TestChainIdentifierStore {
184+ impl ChainIdentifierValidator for TestChainIdentifierStore {
185185 fn validate_identifier (
186186 & self ,
187187 _chain_name : & ChainName ,
188188 _chain_identifier : & ChainIdentifier ,
189- ) -> Result < ( ) , ChainIdentifierStoreError > {
189+ ) -> Result < ( ) , ChainIdentifierValidationError > {
190190 self . validate_identifier_calls . lock ( ) . unwrap ( ) . remove ( 0 )
191191 }
192192
193193 fn update_identifier (
194194 & self ,
195195 _chain_name : & ChainName ,
196196 _chain_identifier : & ChainIdentifier ,
197- ) -> Result < ( ) , ChainIdentifierStoreError > {
197+ ) -> Result < ( ) , ChainIdentifierValidationError > {
198198 self . update_identifier_calls . lock ( ) . unwrap ( ) . remove ( 0 )
199199 }
200200 }
@@ -288,10 +288,10 @@ mod tests {
288288 #[ tokio:: test]
289289 async fn check_temporary_failure_on_initial_chain_identifier_update_error ( ) {
290290 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
291- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: IdentifierNotSet (
291+ store. validate_identifier_call ( Err ( ChainIdentifierValidationError :: IdentifierNotSet (
292292 "chain-1" . into ( ) ,
293293 ) ) ) ;
294- store. update_identifier_call ( Err ( ChainIdentifierStoreError :: Store ( anyhow ! ( "error" ) ) ) ) ;
294+ store. update_identifier_call ( Err ( ChainIdentifierValidationError :: Store ( anyhow ! ( "error" ) ) ) ) ;
295295
296296 let check = GenesisHashCheck :: new ( store) ;
297297
@@ -321,7 +321,7 @@ mod tests {
321321 #[ tokio:: test]
322322 async fn check_valid_on_initial_chain_identifier_update ( ) {
323323 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
324- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: IdentifierNotSet (
324+ store. validate_identifier_call ( Err ( ChainIdentifierValidationError :: IdentifierNotSet (
325325 "chain-1" . into ( ) ,
326326 ) ) ) ;
327327 store. update_identifier_call ( Ok ( ( ) ) ) ;
@@ -351,7 +351,7 @@ mod tests {
351351 #[ tokio:: test]
352352 async fn check_valid_when_stored_identifier_network_version_is_zero ( ) {
353353 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
354- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: NetVersionMismatch {
354+ store. validate_identifier_call ( Err ( ChainIdentifierValidationError :: NetVersionMismatch {
355355 chain_name : "chain-1" . into ( ) ,
356356 store_net_version : "0" . to_owned ( ) ,
357357 chain_net_version : "1" . to_owned ( ) ,
@@ -382,7 +382,7 @@ mod tests {
382382 #[ tokio:: test]
383383 async fn check_fails_on_identifier_network_version_mismatch ( ) {
384384 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
385- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: NetVersionMismatch {
385+ store. validate_identifier_call ( Err ( ChainIdentifierValidationError :: NetVersionMismatch {
386386 chain_name : "chain-1" . into ( ) ,
387387 store_net_version : "2" . to_owned ( ) ,
388388 chain_net_version : "1" . to_owned ( ) ,
@@ -413,11 +413,13 @@ mod tests {
413413 #[ tokio:: test]
414414 async fn check_fails_on_identifier_genesis_hash_mismatch ( ) {
415415 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
416- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: GenesisBlockHashMismatch {
417- chain_name : "chain-1" . into ( ) ,
418- store_genesis_block_hash : vec ! [ 2 ] . into ( ) ,
419- chain_genesis_block_hash : vec ! [ 1 ] . into ( ) ,
420- } ) ) ;
416+ store. validate_identifier_call ( Err (
417+ ChainIdentifierValidationError :: GenesisBlockHashMismatch {
418+ chain_name : "chain-1" . into ( ) ,
419+ store_genesis_block_hash : vec ! [ 2 ] . into ( ) ,
420+ chain_genesis_block_hash : vec ! [ 1 ] . into ( ) ,
421+ } ,
422+ ) ) ;
421423
422424 let check = GenesisHashCheck :: new ( store) ;
423425
@@ -444,7 +446,8 @@ mod tests {
444446 #[ tokio:: test]
445447 async fn check_temporary_failure_on_store_errors ( ) {
446448 let store = Arc :: new ( TestChainIdentifierStore :: default ( ) ) ;
447- store. validate_identifier_call ( Err ( ChainIdentifierStoreError :: Store ( anyhow ! ( "error" ) ) ) ) ;
449+ store
450+ . validate_identifier_call ( Err ( ChainIdentifierValidationError :: Store ( anyhow ! ( "error" ) ) ) ) ;
448451
449452 let check = GenesisHashCheck :: new ( store) ;
450453
0 commit comments