Skip to content

Commit

Permalink
sweep: adjust TestNegativeInput after fee rate buckets integration
Browse files Browse the repository at this point in the history
With the introduction of the fee rate buckets, fee rates for sweeps are
no longer re-queried when scheduling new input requests/sweeps. Because
of this, we can no longer test the case where an input with a negative
yield is included in a transaction once fees have decreased.
  • Loading branch information
wpaulino committed May 8, 2019
1 parent 999779a commit 7d88d5f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions sweep/sweeper_test.go
Expand Up @@ -356,8 +356,7 @@ func TestNegativeInput(t *testing.T) {
// the HtlcAcceptedRemoteSuccess input type adds more in fees than its
// value at the current fee level.
negInput := createTestInput(2900, input.HtlcOfferedRemoteTimeout)
negInputResult, err := ctx.sweeper.SweepInput(&negInput, nil)
if err != nil {
if _, err := ctx.sweeper.SweepInput(&negInput, nil); err != nil {
t.Fatal(err)
}

Expand All @@ -373,7 +372,7 @@ func TestNegativeInput(t *testing.T) {

// We expect that a sweep tx is published now, but it should only
// contain the large input. The negative input should stay out of sweeps
// until fees come down to get a positive net yield.
// since it has a negative yield.
sweepTx1 := ctx.receiveTx()
assertTxSweepsInputs(t, &sweepTx1, &largeInput, &positiveInput)

Expand All @@ -382,10 +381,8 @@ func TestNegativeInput(t *testing.T) {
ctx.expectResult(largeInputResult, nil)
ctx.expectResult(positiveInputResult, nil)

// Lower fee rate so that the negative input is no longer negative.
ctx.estimator.updateFees(1000, 1000)

// Create another large input
// Sweeping another large input should result in the negative yield
// still not being swept.
secondLargeInput := createTestInput(100000, input.CommitmentNoDelay)
secondLargeInputResult, err := ctx.sweeper.SweepInput(
&secondLargeInput, nil,
Expand All @@ -402,9 +399,10 @@ func TestNegativeInput(t *testing.T) {
ctx.backend.mine()

ctx.expectResult(secondLargeInputResult, nil)
ctx.expectResult(negInputResult, nil)

ctx.finish(1)
// The negative input's waitForSpend goroutine should still be lingering
// since it hasn't been swept.
ctx.finish(2)
}

// TestChunks asserts that large sets of inputs are split into multiple txes.
Expand Down

0 comments on commit 7d88d5f

Please sign in to comment.