@@ -508,7 +508,7 @@ func (d dustExpectation) String() string {
508
508
// message to the remote party, and all the other intermediate steps.
509
509
func (r * rbfCloserTestHarness ) expectHalfSignerIteration (
510
510
initEvent ProtocolEvent , balanceAfterClose , absoluteFee btcutil.Amount ,
511
- dustExpect dustExpectation ) {
511
+ dustExpect dustExpectation , iteration bool ) {
512
512
513
513
ctx := context .Background ()
514
514
numFeeCalls := 2
@@ -569,8 +569,16 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
569
569
}
570
570
571
571
case * SendOfferEvent :
572
-
573
572
expectedStates = []RbfState {& ClosingNegotiation {}}
573
+
574
+ // If we're in the middle of an iteration, then we expect a
575
+ // transition from ClosePending -> LocalCloseStart.
576
+ if iteration {
577
+ expectedStates = append (
578
+ expectedStates , & ClosingNegotiation {},
579
+ )
580
+ }
581
+
574
582
case * ChannelFlushed :
575
583
// If we're sending a flush event here, then this means that we
576
584
// also have enough balance to cover the fee so we'll have
@@ -585,10 +593,6 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
585
593
586
594
// We should transition from the negotiation state back to
587
595
// itself.
588
- //
589
- // TODO(roasbeef): take in expected set of transitions!!!
590
- // * or base off of event, if shutdown recv'd know we're doing a full
591
- // loop
592
596
r .assertStateTransitions (expectedStates ... )
593
597
594
598
// If we examine the final resting state, we should see that
@@ -610,14 +614,15 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
610
614
611
615
func (r * rbfCloserTestHarness ) assertSingleRbfIteration (
612
616
initEvent ProtocolEvent , balanceAfterClose , absoluteFee btcutil.Amount ,
613
- dustExpect dustExpectation ) {
617
+ dustExpect dustExpectation , iteration bool ) {
614
618
615
619
ctx := context .Background ()
616
620
617
621
// We'll now send in the send offer event, which should trigger 1/2 of
618
622
// the RBF loop, ending us in the LocalOfferSent state.
619
623
r .expectHalfSignerIteration (
620
624
initEvent , balanceAfterClose , absoluteFee , noDustExpect ,
625
+ iteration ,
621
626
)
622
627
623
628
// Now that we're in the local offer sent state, we'll send the
@@ -1299,7 +1304,7 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
1299
1304
// flow.
1300
1305
closeHarness .expectHalfSignerIteration (
1301
1306
& flushEvent , balanceAfterClose , absoluteFee ,
1302
- noDustExpect ,
1307
+ noDustExpect , false ,
1303
1308
)
1304
1309
})
1305
1310
}
@@ -1418,7 +1423,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1418
1423
// pending state.
1419
1424
closeHarness .assertSingleRbfIteration (
1420
1425
sendOfferEvent , balanceAfterClose , absoluteFee ,
1421
- noDustExpect ,
1426
+ noDustExpect , false ,
1422
1427
)
1423
1428
})
1424
1429
@@ -1434,7 +1439,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1434
1439
// event to advance the state machine.
1435
1440
closeHarness .expectHalfSignerIteration (
1436
1441
sendOfferEvent , balanceAfterClose , absoluteFee ,
1437
- noDustExpect ,
1442
+ noDustExpect , false ,
1438
1443
)
1439
1444
1440
1445
// We'll now craft the local sig received event, but this time
@@ -1489,7 +1494,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1489
1494
// proper field is set.
1490
1495
closeHarness .expectHalfSignerIteration (
1491
1496
sendOfferEvent , balanceAfterClose , absoluteFee ,
1492
- remoteDustExpect ,
1497
+ remoteDustExpect , false ,
1493
1498
)
1494
1499
})
1495
1500
@@ -1516,7 +1521,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1516
1521
dustBalance := btcutil .Amount (100 )
1517
1522
closeHarness .expectHalfSignerIteration (
1518
1523
sendOfferEvent , dustBalance , absoluteFee ,
1519
- localDustExpect ,
1524
+ localDustExpect , false ,
1520
1525
)
1521
1526
})
1522
1527
@@ -1581,7 +1586,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1581
1586
// assuming we start in this negotiation state.
1582
1587
closeHarness .assertSingleRbfIteration (
1583
1588
sendOfferEvent , balanceAfterClose , absoluteFee ,
1584
- noDustExpect ,
1589
+ noDustExpect , false ,
1585
1590
)
1586
1591
1587
1592
// Next, we'll send in a new SendOfferEvent event which
@@ -1596,12 +1601,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1596
1601
// initiate a new local sig).
1597
1602
closeHarness .assertSingleRbfIteration (
1598
1603
localOffer , balanceAfterClose , absoluteFee ,
1599
- noDustExpect ,
1600
- )
1601
-
1602
- // We should terminate in the negotiation state.
1603
- closeHarness .assertStateTransitions (
1604
- & ClosingNegotiation {},
1604
+ noDustExpect , true ,
1605
1605
)
1606
1606
})
1607
1607
@@ -2004,7 +2004,7 @@ func TestRbfCloseErr(t *testing.T) {
2004
2004
// initiate a new local sig).
2005
2005
closeHarness .assertSingleRbfIteration (
2006
2006
localOffer , balanceAfterClose , absoluteFee ,
2007
- noDustExpect ,
2007
+ noDustExpect , false ,
2008
2008
)
2009
2009
2010
2010
// We should terminate in the negotiation state.
0 commit comments