@@ -596,6 +596,9 @@ mod test {
596
596
597
597
#[ tokio:: test]
598
598
async fn test_chain_configs_with_data ( ) {
599
+ use crate :: api:: get_chain_configs;
600
+ use axum:: { routing:: get, Router } ;
601
+
599
602
// Create a config with actual chain data
600
603
let mut config_chains = HashMap :: new ( ) ;
601
604
config_chains. insert (
@@ -673,16 +676,72 @@ mod test {
673
676
} ,
674
677
} ;
675
678
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 , & [ ] ) ) ;
684
682
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) ;
686
745
let server = TestServer :: new ( app) . unwrap ( ) ;
687
746
688
747
// Test the chain configs endpoint
@@ -706,7 +765,8 @@ mod test {
706
765
) ;
707
766
assert_eq ! ( eth_config. reveal_delay_blocks, 1 ) ;
708
767
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
710
770
711
771
// Find avalanche config
712
772
let avax_config = configs
@@ -719,6 +779,7 @@ mod test {
719
779
) ;
720
780
assert_eq ! ( avax_config. reveal_delay_blocks, 2 ) ;
721
781
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
723
784
}
724
785
}
0 commit comments