@@ -508,7 +508,7 @@ func (d dustExpectation) String() string {
508508// message to the remote party, and all the other intermediate steps.
509509func (r * rbfCloserTestHarness ) expectHalfSignerIteration (
510510 initEvent ProtocolEvent , balanceAfterClose , absoluteFee btcutil.Amount ,
511- dustExpect dustExpectation ) {
511+ dustExpect dustExpectation , iteration bool ) {
512512
513513 ctx := context .Background ()
514514 numFeeCalls := 2
@@ -569,8 +569,16 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
569569 }
570570
571571 case * SendOfferEvent :
572-
573572 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+
574582 case * ChannelFlushed :
575583 // If we're sending a flush event here, then this means that we
576584 // also have enough balance to cover the fee so we'll have
@@ -585,10 +593,6 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
585593
586594 // We should transition from the negotiation state back to
587595 // 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
592596 r .assertStateTransitions (expectedStates ... )
593597
594598 // If we examine the final resting state, we should see that
@@ -610,14 +614,15 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
610614
611615func (r * rbfCloserTestHarness ) assertSingleRbfIteration (
612616 initEvent ProtocolEvent , balanceAfterClose , absoluteFee btcutil.Amount ,
613- dustExpect dustExpectation ) {
617+ dustExpect dustExpectation , iteration bool ) {
614618
615619 ctx := context .Background ()
616620
617621 // We'll now send in the send offer event, which should trigger 1/2 of
618622 // the RBF loop, ending us in the LocalOfferSent state.
619623 r .expectHalfSignerIteration (
620624 initEvent , balanceAfterClose , absoluteFee , noDustExpect ,
625+ iteration ,
621626 )
622627
623628 // Now that we're in the local offer sent state, we'll send the
@@ -1299,7 +1304,7 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
12991304 // flow.
13001305 closeHarness .expectHalfSignerIteration (
13011306 & flushEvent , balanceAfterClose , absoluteFee ,
1302- noDustExpect ,
1307+ noDustExpect , false ,
13031308 )
13041309 })
13051310 }
@@ -1418,7 +1423,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
14181423 // pending state.
14191424 closeHarness .assertSingleRbfIteration (
14201425 sendOfferEvent , balanceAfterClose , absoluteFee ,
1421- noDustExpect ,
1426+ noDustExpect , false ,
14221427 )
14231428 })
14241429
@@ -1434,7 +1439,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
14341439 // event to advance the state machine.
14351440 closeHarness .expectHalfSignerIteration (
14361441 sendOfferEvent , balanceAfterClose , absoluteFee ,
1437- noDustExpect ,
1442+ noDustExpect , false ,
14381443 )
14391444
14401445 // We'll now craft the local sig received event, but this time
@@ -1489,7 +1494,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
14891494 // proper field is set.
14901495 closeHarness .expectHalfSignerIteration (
14911496 sendOfferEvent , balanceAfterClose , absoluteFee ,
1492- remoteDustExpect ,
1497+ remoteDustExpect , false ,
14931498 )
14941499 })
14951500
@@ -1516,7 +1521,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
15161521 dustBalance := btcutil .Amount (100 )
15171522 closeHarness .expectHalfSignerIteration (
15181523 sendOfferEvent , dustBalance , absoluteFee ,
1519- localDustExpect ,
1524+ localDustExpect , false ,
15201525 )
15211526 })
15221527
@@ -1581,7 +1586,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
15811586 // assuming we start in this negotiation state.
15821587 closeHarness .assertSingleRbfIteration (
15831588 sendOfferEvent , balanceAfterClose , absoluteFee ,
1584- noDustExpect ,
1589+ noDustExpect , false ,
15851590 )
15861591
15871592 // Next, we'll send in a new SendOfferEvent event which
@@ -1596,12 +1601,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
15961601 // initiate a new local sig).
15971602 closeHarness .assertSingleRbfIteration (
15981603 localOffer , balanceAfterClose , absoluteFee ,
1599- noDustExpect ,
1600- )
1601-
1602- // We should terminate in the negotiation state.
1603- closeHarness .assertStateTransitions (
1604- & ClosingNegotiation {},
1604+ noDustExpect , true ,
16051605 )
16061606 })
16071607
@@ -2004,7 +2004,7 @@ func TestRbfCloseErr(t *testing.T) {
20042004 // initiate a new local sig).
20052005 closeHarness .assertSingleRbfIteration (
20062006 localOffer , balanceAfterClose , absoluteFee ,
2007- noDustExpect ,
2007+ noDustExpect , false ,
20082008 )
20092009
20102010 // We should terminate in the negotiation state.
0 commit comments