@@ -176,8 +176,11 @@ async fn import_expected_notes() {
176176 tx_request. expected_output_own_notes ( ) . pop ( ) . unwrap ( ) . clone ( ) . into ( ) ;
177177 client_2. sync_state ( ) . await . unwrap ( ) ;
178178
179- // If the verification is requested before execution then the import should fail
180- assert ! ( client_2. import_note( NoteFile :: NoteId ( note. id( ) ) ) . await . is_err( ) ) ;
179+ // Importing a public note before it's committed onchain should fail
180+ assert ! ( matches!(
181+ client_2. import_note( NoteFile :: NoteId ( note. id( ) ) ) . await . unwrap_err( ) ,
182+ ClientError :: NoteNotFoundOnChain ( _)
183+ ) ) ;
181184 execute_tx_and_sync ( & mut client_1, faucet_account. id ( ) , tx_request) . await ;
182185
183186 // Use client 1 to wait until a couple of blocks have passed
@@ -189,13 +192,13 @@ async fn import_expected_notes() {
189192 client_2. import_note ( NoteFile :: NoteId ( note. clone ( ) . id ( ) ) ) . await . unwrap ( ) ;
190193 client_2. sync_state ( ) . await . unwrap ( ) ;
191194 let input_note = client_2. get_input_note ( note. id ( ) ) . await . unwrap ( ) . unwrap ( ) ;
195+ // If imported after execution and syncing then the inclusion proof should be Some
196+ assert ! ( input_note. inclusion_proof( ) . is_some( ) , "Expected inclusion proof to be present" ) ;
197+
192198 assert ! (
193199 new_sync_data. block_num > input_note. inclusion_proof( ) . unwrap( ) . location( ) . block_num( ) + 1
194200 ) ;
195201
196- // If imported after execution and syncing then the inclusion proof should be Some
197- assert ! ( input_note. inclusion_proof( ) . is_some( ) ) ;
198-
199202 // If client 2 successfully consumes the note, we confirm we have MMR and block header data
200203 let tx_id =
201204 consume_notes ( & mut client_2, client_2_account. id ( ) , & [ input_note. try_into ( ) . unwrap ( ) ] )
@@ -213,7 +216,7 @@ async fn import_expected_notes() {
213216 let note: InputNoteRecord =
214217 tx_request. expected_output_own_notes ( ) . pop ( ) . unwrap ( ) . clone ( ) . into ( ) ;
215218
216- // Import an uncommitted note without verification
219+ // Import the node before it's committed onchain works if we have full `NoteDetails`
217220 client_2. add_note_tag ( note. metadata ( ) . unwrap ( ) . tag ( ) ) . await . unwrap ( ) ;
218221 client_2
219222 . import_note ( NoteFile :: NoteDetails {
@@ -225,16 +228,16 @@ async fn import_expected_notes() {
225228 . unwrap ( ) ;
226229 let input_note = client_2. get_input_note ( note. id ( ) ) . await . unwrap ( ) . unwrap ( ) ;
227230
228- // If imported before execution then the inclusion proof should be None
229- assert ! ( input_note. inclusion_proof ( ) . is_none ( ) ) ;
231+ // If imported before execution, the note should be imported in `Expected` state
232+ assert ! ( matches! ( input_note. state ( ) , InputNoteState :: Expected { .. } ) ) ;
230233
231234 execute_tx_and_sync ( & mut client_1, faucet_account. id ( ) , tx_request) . await ;
232235 client_2. sync_state ( ) . await . unwrap ( ) ;
233236
234237 // After sync, the imported note should have inclusion proof even if it's not relevant for its
235238 // accounts.
236239 let input_note = client_2. get_input_note ( note. id ( ) ) . await . unwrap ( ) . unwrap ( ) ;
237- assert ! ( input_note. inclusion_proof( ) . is_some( ) ) ;
240+ assert ! ( input_note. inclusion_proof( ) . is_some( ) , "Expected inclusion proof to be present" ) ;
238241
239242 // If inclusion proof is invalid this should panic
240243 let tx_id =
@@ -315,9 +318,24 @@ async fn import_expected_notes_from_the_past_as_committed() {
315318
316319 // Use client 1 to wait until a couple of blocks have passed
317320 wait_for_blocks ( & mut client_1, 3 ) . await ;
321+
322+ // importing the note before client_2 is synced will result in a note with `Expected` state
323+ let note_id = client_2
324+ . import_note ( NoteFile :: NoteDetails {
325+ details : note. clone ( ) . into ( ) ,
326+ after_block_num : block_height_before,
327+ tag : Some ( note. metadata ( ) . unwrap ( ) . tag ( ) ) ,
328+ } )
329+ . await
330+ . unwrap ( ) ;
331+
332+ let imported_note = client_2. get_input_note ( note_id) . await . unwrap ( ) . unwrap ( ) ;
333+
334+ assert ! ( matches!( imported_note. state( ) , InputNoteState :: Expected { .. } ) ) ;
335+
318336 client_2. sync_state ( ) . await . unwrap ( ) ;
319337
320- // If the verification is requested before execution then the import should fail
338+ // import the note after syncing the client
321339 let note_id = client_2
322340 . import_note ( NoteFile :: NoteDetails {
323341 details : note. clone ( ) . into ( ) ,
@@ -333,6 +351,7 @@ async fn import_expected_notes_from_the_past_as_committed() {
333351 let client_1_note = client_1. get_input_note ( note_id) . await . unwrap ( ) . unwrap ( ) ;
334352
335353 assert_eq ! ( imported_note. state( ) , client_1_note. state( ) ) ;
354+ assert ! ( matches!( imported_note. state( ) , InputNoteState :: Committed { .. } ) ) ;
336355}
337356
338357#[ tokio:: test]
0 commit comments