@@ -614,21 +614,23 @@ async fn test_discover_chain_proof_direct() {
614614 assert_eq ! ( proof. timestamp, timestamp as i64 ) ;
615615}
616616
617- /// Test that discover_chain_proof returns an error for non-existent proofs.
617+ /// Test that discover_chain_proof falls back to RPC when proof not in DB,
618+ /// and returns NoChainProvider error when no RPC provider is configured.
618619#[ tokio:: test]
619- async fn test_discover_chain_proof_not_found ( ) {
620+ async fn test_discover_chain_proof_fallback_no_provider ( ) {
620621 use ceramic_event:: unvalidated;
621622
622623 use crate :: { EventService , UndeliveredEventReview } ;
623624
624625 let pool = SqlitePool :: connect_in_memory ( ) . await . unwrap ( ) ;
626+ // Service created with no RPC providers
625627 let service = EventService :: try_new ( pool. clone ( ) , UndeliveredEventReview :: Skip , false , vec ! [ ] )
626628 . await
627629 . unwrap ( ) ;
628630
629631 // Create a time event for a non-existent chain proof
630- let tx_hash = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" ;
631- let tx_hash_cid = tx_hash_to_cid ( tx_hash ) ;
632+ let tx_hash_cid =
633+ tx_hash_to_cid ( "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" ) ;
632634 let init_cid = super :: deterministic_cid ( b"discover not found test init" ) ;
633635 let prev_cid = super :: deterministic_cid ( b"discover not found test prev" ) ;
634636
@@ -643,29 +645,20 @@ async fn test_discover_chain_proof_not_found() {
643645 . build ( )
644646 . expect ( "test time event should build" ) ;
645647
646- // Call discover_chain_proof - should fail because no proof was stored
648+ // Call discover_chain_proof - should fail because proof not in DB and no RPC provider
647649 let result = service. discover_chain_proof ( & time_event) . await ;
648650
649651 assert ! (
650652 result. is_err( ) ,
651- "discover_chain_proof should fail for non-existent proof "
653+ "discover_chain_proof should fail when no RPC provider configured "
652654 ) ;
653655
654- // Verify it's an InvalidProof error (discover_chain_proof returns InvalidProof when not found )
656+ // Verify it's a NoChainProvider error (RPC fallback fails without provider )
655657 match result. unwrap_err ( ) {
656- crate :: eth_rpc:: Error :: InvalidProof ( msg) => {
657- assert ! (
658- msg. contains( "not found in database" ) ,
659- "Error message should indicate proof not found, got: {}" ,
660- msg
661- ) ;
662- assert ! (
663- msg. contains( tx_hash) ,
664- "Error message should contain tx_hash, got: {}" ,
665- msg
666- ) ;
658+ crate :: eth_rpc:: Error :: NoChainProvider ( chain_id) => {
659+ assert_eq ! ( chain_id. to_string( ) , "eip155:100" ) ;
667660 }
668- other => panic ! ( "Expected InvalidProof error, got: {:?}" , other) ,
661+ other => panic ! ( "Expected NoChainProvider error, got: {:?}" , other) ,
669662 }
670663}
671664
0 commit comments