@@ -52,6 +52,48 @@ pub struct ProofAggregator {
5252}
5353
5454impl ProofAggregator {
55+ pub fn new_for_testing ( config : Config ) -> Self {
56+ let rpc_url: reqwest:: Url = config. eth_rpc_url . parse ( ) . expect ( "RPC URL should be valid" ) ;
57+ let signer = LocalSigner :: random ( ) ;
58+ let wallet = EthereumWallet :: from ( signer) ;
59+
60+ let rpc_provider = ProviderBuilder :: new ( ) . connect_http ( rpc_url. clone ( ) ) ;
61+
62+ let signed_rpc_provider = ProviderBuilder :: new ( ) . wallet ( wallet) . connect_http ( rpc_url) ;
63+
64+ let proof_aggregation_service = AlignedProofAggregationService :: new (
65+ Address :: from_str ( & config. proof_aggregation_service_address )
66+ . expect ( "AlignedProofAggregationService address should be valid" ) ,
67+ signed_rpc_provider. clone ( ) ,
68+ ) ;
69+
70+ let engine =
71+ ZKVMEngine :: from_env ( ) . expect ( "AGGREGATOR env variable to be set to one of sp1|risc0" ) ;
72+ let fetcher = ProofsFetcher :: new_for_testing ( & config) ;
73+
74+ let sp1_chunk_aggregator_vk_hash_bytes: [ u8 ; 32 ] =
75+ hex:: decode ( & config. sp1_chunk_aggregator_vk_hash )
76+ . expect ( "Failed to decode SP1 chunk aggregator VK hash" )
77+ . try_into ( )
78+ . expect ( "SP1 chunk aggregator VK hash must be 32 bytes" ) ;
79+
80+ let risc0_chunk_aggregator_image_id_bytes: [ u8 ; 32 ] =
81+ hex:: decode ( & config. risc0_chunk_aggregator_image_id )
82+ . expect ( "Failed to decode Risc0 chunk aggregator image id" )
83+ . try_into ( )
84+ . expect ( "Risc0 chunk aggregator image id must be 32 bytes" ) ;
85+
86+ Self {
87+ engine,
88+ proof_aggregation_service,
89+ fetcher,
90+ config,
91+ rpc_provider,
92+ sp1_chunk_aggregator_vk_hash_bytes,
93+ risc0_chunk_aggregator_image_id_bytes,
94+ }
95+ }
96+
5597 pub fn new ( config : Config ) -> Self {
5698 let rpc_url: reqwest:: Url = config. eth_rpc_url . parse ( ) . expect ( "RPC URL should be valid" ) ;
5799 let signer = LocalSigner :: decrypt_keystore (
@@ -394,16 +436,6 @@ mod tests {
394436
395437 let current_dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
396438
397- panic ! ( "Current dir for tests: {}" , current_dir) ;
398-
399- // Check that the config file paths exist
400- let ecdsa_key_path =
401- format ! ( "{current_dir}/../config-files/anvil.proof-aggregator.ecdsa.key.json" ) ;
402-
403- if !std:: path:: Path :: new ( & ecdsa_key_path) . exists ( ) {
404- info ! ( "ECDSA key file does not exist at path: {}" , ecdsa_key_path) ;
405- }
406-
407439 // These config values are taken from config-files/config-proof-aggregator.yaml
408440 let config = Config {
409441 eth_rpc_url : "http://localhost:8545" . to_string ( ) ,
@@ -432,7 +464,7 @@ mod tests {
432464 "d8cfdd5410c70395c0a1af1842a0148428cc46e353355faccfba694dd4862dbf" . to_string ( ) ,
433465 } ;
434466
435- ProofAggregator :: new ( config)
467+ ProofAggregator :: new_for_testing ( config)
436468 }
437469
438470 #[ test]
0 commit comments