@@ -44,6 +44,27 @@ fn test_tx_conflict_handling() {
44
44
let chain_tip = local_chain. tip ( ) . block_id ( ) ;
45
45
46
46
let scenarios = [
47
+ Scenario {
48
+ name : "only A exists, no other txs" ,
49
+ tx_templates : & [
50
+ TxTemplate {
51
+ tx_name : "A" ,
52
+ inputs : & [ TxInTemplate :: Bogus ] ,
53
+ outputs : & [ TxOutTemplate :: new ( 10000 , Some ( 0 ) ) ] ,
54
+ last_seen : None ,
55
+ ..Default :: default ( )
56
+ } ,
57
+ ] ,
58
+ exp_chain_txs : HashSet :: from ( [ "A" ] ) ,
59
+ exp_chain_txouts : HashSet :: from ( [ ( "A" , 0 ) ] ) ,
60
+ exp_unspents : HashSet :: from ( [ ( "A" , 0 ) ] ) ,
61
+ exp_balance : Balance {
62
+ immature : Amount :: ZERO ,
63
+ trusted_pending : Amount :: from_sat ( 10000 ) ,
64
+ untrusted_pending : Amount :: ZERO ,
65
+ confirmed : Amount :: ZERO ,
66
+ } ,
67
+ } ,
47
68
Scenario {
48
69
name : "coinbase tx cannot be in mempool and be unconfirmed" ,
49
70
tx_templates : & [
@@ -319,6 +340,41 @@ fn test_tx_conflict_handling() {
319
340
confirmed : Amount :: from_sat ( 50000 ) ,
320
341
} ,
321
342
} ,
343
+ Scenario {
344
+ name : "B and B' spend A, B' is confirmed" ,
345
+ tx_templates : & [
346
+ TxTemplate {
347
+ tx_name : "A" ,
348
+ inputs : & [ TxInTemplate :: Bogus ] ,
349
+ outputs : & [ TxOutTemplate :: new ( 10000 , Some ( 0 ) ) ] ,
350
+ last_seen : None ,
351
+ ..Default :: default ( )
352
+ } ,
353
+ TxTemplate {
354
+ tx_name : "B" ,
355
+ inputs : & [ TxInTemplate :: PrevTx ( "A" , 0 ) ] ,
356
+ outputs : & [ TxOutTemplate :: new ( 20000 , Some ( 1 ) ) ] ,
357
+ last_seen : Some ( 100 ) ,
358
+ ..Default :: default ( )
359
+ } ,
360
+ TxTemplate {
361
+ tx_name : "B'" ,
362
+ inputs : & [ TxInTemplate :: PrevTx ( "A" , 0 ) ] ,
363
+ outputs : & [ TxOutTemplate :: new ( 30000 , Some ( 2 ) ) ] ,
364
+ anchors : & [ block_id ! ( 1 , "B" ) ] ,
365
+ ..Default :: default ( )
366
+ } ,
367
+ ] ,
368
+ exp_chain_txs : HashSet :: from ( [ "A" , "B'" ] ) ,
369
+ exp_chain_txouts : HashSet :: from ( [ ( "A" , 0 ) , ( "B'" , 0 ) ] ) ,
370
+ exp_unspents : HashSet :: from ( [ ( "B'" , 0 ) ] ) ,
371
+ exp_balance : Balance {
372
+ immature : Amount :: ZERO ,
373
+ trusted_pending : Amount :: ZERO ,
374
+ untrusted_pending : Amount :: ZERO ,
375
+ confirmed : Amount :: from_sat ( 30000 ) ,
376
+ } ,
377
+ } ,
322
378
Scenario {
323
379
name : "B and B' spend A and conflict, C spends B, all the transactions are unconfirmed, B' has higher last_seen than B" ,
324
380
tx_templates : & [
0 commit comments