@@ -844,6 +844,9 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(anchors: bool, revoked_c
844
844
check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
845
845
check_added_monitors ( & nodes[ 0 ] , 1 ) ;
846
846
check_closed_event ( & nodes[ 0 ] , 1 , ClosureReason :: HTLCsTimedOut , false , & [ nodes[ 1 ] . node . get_our_node_id ( ) ] , 100_000 ) ;
847
+ if anchors {
848
+ handle_bump_close_event ( & nodes[ 0 ] ) ;
849
+ }
847
850
848
851
{
849
852
let mut txn = nodes[ 0 ] . tx_broadcaster . txn_broadcast ( ) ;
@@ -870,6 +873,9 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(anchors: bool, revoked_c
870
873
check_added_monitors ( & nodes[ 1 ] , 1 ) ;
871
874
let reason = ClosureReason :: HolderForceClosed { broadcasted_latest_txn : Some ( true ) , message } ;
872
875
check_closed_event ( & nodes[ 1 ] , 1 , reason, false , & [ nodes[ 0 ] . node . get_our_node_id ( ) ] , 100_000 ) ;
876
+ if anchors {
877
+ handle_bump_close_event ( & nodes[ 1 ] ) ;
878
+ }
873
879
874
880
let commitment_b = {
875
881
let mut txn = nodes[ 1 ] . tx_broadcaster . txn_broadcast ( ) ;
@@ -882,13 +888,23 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(anchors: bool, revoked_c
882
888
// Confirm B's commitment, A should now broadcast an HTLC timeout for commitment B.
883
889
mine_transaction ( & nodes[ 0 ] , & commitment_b) ;
884
890
{
885
- let mut txn = nodes[ 0 ] . tx_broadcaster . txn_broadcast ( ) ;
886
891
if nodes[ 0 ] . connect_style . borrow ( ) . updates_best_block_first ( ) {
887
892
// `commitment_a` is rebroadcast because the best block was updated prior to seeing
888
893
// `commitment_b`.
889
- assert_eq ! ( txn. len( ) , 2 ) ;
890
- check_spends ! ( txn. last( ) . unwrap( ) , commitment_b) ;
894
+ if anchors {
895
+ handle_bump_close_event ( & nodes[ 0 ] ) ;
896
+ let mut txn = nodes[ 0 ] . tx_broadcaster . txn_broadcast ( ) ;
897
+ assert_eq ! ( txn. len( ) , 3 ) ;
898
+ check_spends ! ( txn[ 0 ] , commitment_b) ;
899
+ check_spends ! ( txn[ 1 ] , funding_tx) ;
900
+ check_spends ! ( txn[ 2 ] , txn[ 1 ] ) ; // Anchor output spend transaction.
901
+ } else {
902
+ let mut txn = nodes[ 0 ] . tx_broadcaster . txn_broadcast ( ) ;
903
+ assert_eq ! ( txn. len( ) , 2 ) ;
904
+ check_spends ! ( txn. last( ) . unwrap( ) , commitment_b) ;
905
+ }
891
906
} else {
907
+ let mut txn = nodes[ 0 ] . tx_broadcaster . txn_broadcast ( ) ;
892
908
assert_eq ! ( txn. len( ) , 1 ) ;
893
909
check_spends ! ( txn[ 0 ] , commitment_b) ;
894
910
}
@@ -898,11 +914,15 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(anchors: bool, revoked_c
898
914
// blocks, one to get us back to the original height, and another to retry our pending claims.
899
915
disconnect_blocks ( & nodes[ 0 ] , 1 ) ;
900
916
connect_blocks ( & nodes[ 0 ] , 2 ) ;
917
+ if anchors {
918
+ handle_bump_close_event ( & nodes[ 0 ] ) ;
919
+ }
901
920
{
902
921
let mut txn = nodes[ 0 ] . tx_broadcaster . unique_txn_broadcast ( ) ;
903
922
if anchors {
904
- assert_eq ! ( txn. len( ) , 1 ) ;
923
+ assert_eq ! ( txn. len( ) , 2 ) ;
905
924
check_spends ! ( txn[ 0 ] , funding_tx) ;
925
+ check_spends ! ( txn[ 1 ] , txn[ 0 ] ) ; // Anchor output spend.
906
926
} else {
907
927
assert_eq ! ( txn. len( ) , 2 ) ;
908
928
check_spends ! ( txn[ 0 ] , txn[ 1 ] ) ; // HTLC timeout A
@@ -977,6 +997,7 @@ fn do_test_split_htlc_expiry_tracking(use_third_htlc: bool, reorg_out: bool) {
977
997
let message = "Channel force-closed" . to_owned ( ) ;
978
998
let reason = ClosureReason :: HolderForceClosed { broadcasted_latest_txn : Some ( true ) , message } ;
979
999
check_closed_event ( & nodes[ 1 ] , 1 , reason, false , & [ node_a_id] , 10_000_000 ) ;
1000
+ handle_bump_close_event ( & nodes[ 1 ] ) ;
980
1001
981
1002
let mut txn = nodes[ 1 ] . tx_broadcaster . txn_broadcast ( ) ;
982
1003
assert_eq ! ( txn. len( ) , 1 ) ;
@@ -990,19 +1011,13 @@ fn do_test_split_htlc_expiry_tracking(use_third_htlc: bool, reorg_out: bool) {
990
1011
check_added_monitors ( & nodes[ 0 ] , 1 ) ;
991
1012
992
1013
mine_transaction ( & nodes[ 1 ] , & commitment_tx) ;
993
- let mut bump_events = nodes[ 1 ] . chain_monitor . chain_monitor . get_and_clear_pending_events ( ) ;
994
- assert_eq ! ( bump_events. len( ) , 1 ) ;
995
- match bump_events. pop ( ) . unwrap ( ) {
996
- Event :: BumpTransaction ( bump_event) => {
997
- nodes[ 1 ] . bump_tx_handler . handle_event ( & bump_event) ;
998
- } ,
999
- ev => panic ! ( "Unexpected event {ev:?}" ) ,
1000
- }
1014
+ handle_bump_events ( & nodes[ 1 ] , nodes[ 1 ] . connect_style . borrow ( ) . updates_best_block_first ( ) , 1 ) ;
1001
1015
1002
1016
let mut txn = nodes[ 1 ] . tx_broadcaster . txn_broadcast ( ) ;
1003
1017
if nodes[ 1 ] . connect_style . borrow ( ) . updates_best_block_first ( ) {
1004
- assert_eq ! ( txn. len( ) , 2 , "{txn:?}" ) ;
1018
+ assert_eq ! ( txn. len( ) , 3 , "{txn:?}" ) ;
1005
1019
check_spends ! ( txn[ 0 ] , funding_tx) ;
1020
+ check_spends ! ( txn[ 1 ] , txn[ 0 ] ) ; // Anchor output spend.
1006
1021
} else {
1007
1022
assert_eq ! ( txn. len( ) , 1 , "{txn:?}" ) ;
1008
1023
}
0 commit comments