@@ -596,6 +596,9 @@ mod test {
596596
597597 #[ tokio:: test]
598598 async fn test_chain_configs_with_data ( ) {
599+ use crate :: api:: get_chain_configs;
600+ use axum:: { routing:: get, Router } ;
601+
599602 // Create a config with actual chain data
600603 let mut config_chains = HashMap :: new ( ) ;
601604 config_chains. insert (
@@ -673,16 +676,72 @@ mod test {
673676 } ,
674677 } ;
675678
676- let metrics_registry = Arc :: new ( RwLock :: new ( Registry :: default ( ) ) ) ;
677- let api_state = ApiState :: new (
678- Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
679- metrics_registry,
680- Arc :: new ( History :: new ( ) . await . unwrap ( ) ) ,
681- & config,
682- )
683- . await ;
679+ // Create initialized blockchain states with network IDs
680+ let eth_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
681+ let avax_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
684682
685- let app = api:: routes ( api_state) ;
683+ let eth_state = MonitoredHashChainState :: new (
684+ ETH_CHAIN . clone ( ) ,
685+ Default :: default ( ) ,
686+ "ethereum" . into ( ) ,
687+ PROVIDER ,
688+ ) ;
689+
690+ let eth_blockchain_state = BlockchainState {
691+ id : "ethereum" . into ( ) ,
692+ network_id : 1 , // Ethereum mainnet
693+ state : Arc :: new ( eth_state) ,
694+ contract : eth_read. clone ( ) ,
695+ provider_address : PROVIDER ,
696+ reveal_delay_blocks : 1 ,
697+ confirmed_block_status : BlockStatus :: Latest ,
698+ } ;
699+
700+ let avax_state = MonitoredHashChainState :: new (
701+ AVAX_CHAIN . clone ( ) ,
702+ Default :: default ( ) ,
703+ "avalanche" . into ( ) ,
704+ PROVIDER ,
705+ ) ;
706+
707+ let avax_blockchain_state = BlockchainState {
708+ id : "avalanche" . into ( ) ,
709+ network_id : 43114 , // Avalanche C-Chain
710+ state : Arc :: new ( avax_state) ,
711+ contract : avax_read. clone ( ) ,
712+ provider_address : PROVIDER ,
713+ reveal_delay_blocks : 2 ,
714+ confirmed_block_status : BlockStatus :: Latest ,
715+ } ;
716+
717+ // Create chains HashMap with initialized states
718+ let mut chains = HashMap :: new ( ) ;
719+ chains. insert (
720+ "ethereum" . into ( ) ,
721+ ApiBlockChainState :: Initialized ( eth_blockchain_state) ,
722+ ) ;
723+ chains. insert (
724+ "avalanche" . into ( ) ,
725+ ApiBlockChainState :: Initialized ( avax_blockchain_state) ,
726+ ) ;
727+
728+ // Minimal ApiState for this endpoint
729+ let api_state = ApiState {
730+ chains : Arc :: new ( RwLock :: new ( chains) ) ,
731+ history : Arc :: new ( History :: new ( ) . await . unwrap ( ) ) ,
732+ metrics_registry : Arc :: new ( RwLock :: new ( Registry :: default ( ) ) ) ,
733+ metrics : Arc :: new ( crate :: api:: ApiMetrics {
734+ http_requests : prometheus_client:: metrics:: family:: Family :: default ( ) ,
735+ } ) ,
736+ explorer_metrics : Arc :: new (
737+ crate :: api:: ExplorerMetrics :: new ( Arc :: new ( RwLock :: new ( Registry :: default ( ) ) ) ) . await ,
738+ ) ,
739+ config,
740+ } ;
741+
742+ let app = Router :: new ( )
743+ . route ( "/v1/chains/configs" , get ( get_chain_configs) )
744+ . with_state ( api_state) ;
686745 let server = TestServer :: new ( app) . unwrap ( ) ;
687746
688747 // Test the chain configs endpoint
@@ -706,7 +765,8 @@ mod test {
706765 ) ;
707766 assert_eq ! ( eth_config. reveal_delay_blocks, 1 ) ;
708767 assert_eq ! ( eth_config. gas_limit, 500000 ) ;
709- assert_eq ! ( eth_config. fee, 1500000000000000 ) ;
768+ assert_eq ! ( eth_config. default_fee, 1500000000000000 ) ;
769+ assert_eq ! ( eth_config. network_id, 1 ) ; // Ethereum mainnet
710770
711771 // Find avalanche config
712772 let avax_config = configs
@@ -719,6 +779,7 @@ mod test {
719779 ) ;
720780 assert_eq ! ( avax_config. reveal_delay_blocks, 2 ) ;
721781 assert_eq ! ( avax_config. gas_limit, 600000 ) ;
722- assert_eq ! ( avax_config. fee, 2000000000000000 ) ;
782+ assert_eq ! ( avax_config. default_fee, 2000000000000000 ) ;
783+ assert_eq ! ( avax_config. network_id, 43114 ) ; // Avalanche C-Chain
723784 }
724785}
0 commit comments