@@ -174,20 +174,9 @@ impl LightWallet {
174
174
<D as Domain >:: Recipient : Recipient ,
175
175
<D as Domain >:: Note : PartialEq + Clone ,
176
176
{
177
- let wallet_tip = self
178
- . blocks
179
- . read ( )
180
- . await
181
- . first ( )
182
- . map ( |block| block. height as u32 )
183
- . unwrap_or ( 0 ) ;
184
177
#[ allow( clippy:: type_complexity) ]
185
178
let filters: & [ Box < dyn Fn ( & & D :: WalletNote , & TransactionRecord ) -> bool > ] = & [
186
- Box :: new ( |_, transaction| {
187
- transaction
188
- . status
189
- . is_confirmed_before_or_at ( & BlockHeight :: from_u32 ( wallet_tip) )
190
- } ) ,
179
+ Box :: new ( |_, transaction| transaction. status . is_confirmed ( ) ) ,
191
180
Box :: new ( |note, _| !note. pending_receipt ( ) ) ,
192
181
Box :: new ( |note, _| note. value ( ) >= MARGINAL_FEE . into_u64 ( ) ) ,
193
182
] ;
@@ -329,17 +318,21 @@ impl LightWallet {
329
318
#[ cfg( test) ]
330
319
mod tests {
331
320
use orchard:: note_encryption:: OrchardDomain ;
321
+ use sapling_crypto:: note_encryption:: SaplingDomain ;
322
+
332
323
use zingo_status:: confirmation_status:: ConfirmationStatus ;
333
324
use zingoconfig:: ZingoConfigBuilder ;
334
325
335
- use crate :: wallet:: {
336
- data:: BlockData ,
337
- notes:: {
338
- orchard:: mocks:: OrchardNoteBuilder , sapling:: mocks:: SaplingNoteBuilder ,
339
- transparent:: mocks:: TransparentOutputBuilder ,
326
+ use crate :: {
327
+ mocks:: { orchard_note:: OrchardCryptoNoteBuilder , SaplingCryptoNoteBuilder } ,
328
+ wallet:: {
329
+ notes:: {
330
+ orchard:: mocks:: OrchardNoteBuilder , sapling:: mocks:: SaplingNoteBuilder ,
331
+ transparent:: mocks:: TransparentOutputBuilder ,
332
+ } ,
333
+ transaction_record:: mocks:: TransactionRecordBuilder ,
334
+ LightWallet , WalletBase ,
340
335
} ,
341
- transaction_record:: mocks:: TransactionRecordBuilder ,
342
- LightWallet , WalletBase ,
343
336
} ;
344
337
345
338
#[ tokio:: test]
@@ -350,30 +343,47 @@ mod tests {
350
343
1 ,
351
344
)
352
345
. unwrap ( ) ;
353
- wallet
354
- . set_blocks ( vec ! [ BlockData {
355
- ecb: [ 0u8 ; 32 ] . to_vec( ) ,
356
- height: 100 ,
357
- } ] )
358
- . await ;
359
346
let confirmed_tx_record = TransactionRecordBuilder :: default ( )
360
347
. status ( ConfirmationStatus :: Confirmed ( 80 . into ( ) ) )
361
348
. transparent_outputs ( TransparentOutputBuilder :: default ( ) )
362
349
. sapling_notes ( SaplingNoteBuilder :: default ( ) )
350
+ . sapling_notes ( SaplingNoteBuilder :: default ( ) )
351
+ . sapling_notes (
352
+ SaplingNoteBuilder :: default ( )
353
+ . note (
354
+ SaplingCryptoNoteBuilder :: default ( )
355
+ . value ( sapling_crypto:: value:: NoteValue :: from_raw ( 3_000 ) )
356
+ . clone ( ) ,
357
+ )
358
+ . clone ( ) ,
359
+ )
360
+ . orchard_notes ( OrchardNoteBuilder :: default ( ) )
363
361
. orchard_notes ( OrchardNoteBuilder :: default ( ) )
362
+ . orchard_notes (
363
+ OrchardNoteBuilder :: default ( )
364
+ . note (
365
+ OrchardCryptoNoteBuilder :: default ( )
366
+ . value ( orchard:: value:: NoteValue :: from_raw ( 5_000 ) )
367
+ . clone ( ) ,
368
+ )
369
+ . clone ( ) ,
370
+ )
371
+ . orchard_notes (
372
+ OrchardNoteBuilder :: default ( )
373
+ . note (
374
+ OrchardCryptoNoteBuilder :: default ( )
375
+ . value ( orchard:: value:: NoteValue :: from_raw ( 2_000 ) )
376
+ . clone ( ) ,
377
+ )
378
+ . clone ( ) ,
379
+ )
364
380
. build ( ) ;
365
381
let pending_tx_record = TransactionRecordBuilder :: default ( )
366
382
. status ( ConfirmationStatus :: Pending ( 95 . into ( ) ) )
367
383
. transparent_outputs ( TransparentOutputBuilder :: default ( ) )
368
384
. sapling_notes ( SaplingNoteBuilder :: default ( ) )
369
385
. orchard_notes ( OrchardNoteBuilder :: default ( ) )
370
386
. build ( ) ;
371
- let confirmed_above_wallet_tip_tx_record = TransactionRecordBuilder :: default ( )
372
- . status ( ConfirmationStatus :: Confirmed ( 110 . into ( ) ) )
373
- . transparent_outputs ( TransparentOutputBuilder :: default ( ) )
374
- . sapling_notes ( SaplingNoteBuilder :: default ( ) )
375
- . orchard_notes ( OrchardNoteBuilder :: default ( ) )
376
- . build ( ) ;
377
387
{
378
388
let mut tx_map = wallet
379
389
. transaction_context
@@ -386,16 +396,19 @@ mod tests {
386
396
tx_map
387
397
. transaction_records_by_id
388
398
. insert_transaction_record ( pending_tx_record) ;
389
- tx_map
390
- . transaction_records_by_id
391
- . insert_transaction_record ( confirmed_above_wallet_tip_tx_record) ;
392
399
}
393
400
401
+ assert_eq ! (
402
+ wallet
403
+ . confirmed_balance_excluding_dust:: <SaplingDomain >( None )
404
+ . await ,
405
+ Some ( 400_000 )
406
+ ) ;
394
407
assert_eq ! (
395
408
wallet
396
409
. confirmed_balance_excluding_dust:: <OrchardDomain >( None )
397
410
. await ,
398
- None
399
- )
411
+ Some ( 1_605_000 )
412
+ ) ;
400
413
}
401
414
}
0 commit comments