@@ -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,14 @@ 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 transition
575
+ // from ClosePending -> LocalCloseStart.
576
+ if iteration {
577
+ expectedStates = append (expectedStates , & ClosingNegotiation {})
578
+ }
579
+
574
580
case * ChannelFlushed :
575
581
// If we're sending a flush event here, then this means that we
576
582
// also have enough balance to cover the fee so we'll have
@@ -585,10 +591,6 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
585
591
586
592
// We should transition from the negotiation state back to
587
593
// 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
594
r .assertStateTransitions (expectedStates ... )
593
595
594
596
// If we examine the final resting state, we should see that
@@ -610,14 +612,15 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
610
612
611
613
func (r * rbfCloserTestHarness ) assertSingleRbfIteration (
612
614
initEvent ProtocolEvent , balanceAfterClose , absoluteFee btcutil.Amount ,
613
- dustExpect dustExpectation ) {
615
+ dustExpect dustExpectation , iteration bool ) {
614
616
615
617
ctx := context .Background ()
616
618
617
619
// We'll now send in the send offer event, which should trigger 1/2 of
618
620
// the RBF loop, ending us in the LocalOfferSent state.
619
621
r .expectHalfSignerIteration (
620
622
initEvent , balanceAfterClose , absoluteFee , noDustExpect ,
623
+ iteration ,
621
624
)
622
625
623
626
// Now that we're in the local offer sent state, we'll send the
@@ -1299,7 +1302,7 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
1299
1302
// flow.
1300
1303
closeHarness .expectHalfSignerIteration (
1301
1304
& flushEvent , balanceAfterClose , absoluteFee ,
1302
- noDustExpect ,
1305
+ noDustExpect , false ,
1303
1306
)
1304
1307
})
1305
1308
}
@@ -1418,7 +1421,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1418
1421
// pending state.
1419
1422
closeHarness .assertSingleRbfIteration (
1420
1423
sendOfferEvent , balanceAfterClose , absoluteFee ,
1421
- noDustExpect ,
1424
+ noDustExpect , false ,
1422
1425
)
1423
1426
})
1424
1427
@@ -1434,7 +1437,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1434
1437
// event to advance the state machine.
1435
1438
closeHarness .expectHalfSignerIteration (
1436
1439
sendOfferEvent , balanceAfterClose , absoluteFee ,
1437
- noDustExpect ,
1440
+ noDustExpect , false ,
1438
1441
)
1439
1442
1440
1443
// We'll now craft the local sig received event, but this time
@@ -1489,7 +1492,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1489
1492
// proper field is set.
1490
1493
closeHarness .expectHalfSignerIteration (
1491
1494
sendOfferEvent , balanceAfterClose , absoluteFee ,
1492
- remoteDustExpect ,
1495
+ remoteDustExpect , false ,
1493
1496
)
1494
1497
})
1495
1498
@@ -1516,7 +1519,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1516
1519
dustBalance := btcutil .Amount (100 )
1517
1520
closeHarness .expectHalfSignerIteration (
1518
1521
sendOfferEvent , dustBalance , absoluteFee ,
1519
- localDustExpect ,
1522
+ localDustExpect , false ,
1520
1523
)
1521
1524
})
1522
1525
@@ -1581,7 +1584,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1581
1584
// assuming we start in this negotiation state.
1582
1585
closeHarness .assertSingleRbfIteration (
1583
1586
sendOfferEvent , balanceAfterClose , absoluteFee ,
1584
- noDustExpect ,
1587
+ noDustExpect , false ,
1585
1588
)
1586
1589
1587
1590
// Next, we'll send in a new SendOfferEvent event which
@@ -1596,12 +1599,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
1596
1599
// initiate a new local sig).
1597
1600
closeHarness .assertSingleRbfIteration (
1598
1601
localOffer , balanceAfterClose , absoluteFee ,
1599
- noDustExpect ,
1600
- )
1601
-
1602
- // We should terminate in the negotiation state.
1603
- closeHarness .assertStateTransitions (
1604
- & ClosingNegotiation {},
1602
+ noDustExpect , true ,
1605
1603
)
1606
1604
})
1607
1605
@@ -2004,7 +2002,7 @@ func TestRbfCloseErr(t *testing.T) {
2004
2002
// initiate a new local sig).
2005
2003
closeHarness .assertSingleRbfIteration (
2006
2004
localOffer , balanceAfterClose , absoluteFee ,
2007
- noDustExpect ,
2005
+ noDustExpect , false ,
2008
2006
)
2009
2007
2010
2008
// We should terminate in the negotiation state.
0 commit comments