Skip to content

Commit

Permalink
lnwallet: fix logic in testCreateSimpleTx test case
Browse files Browse the repository at this point in the history
In this commit, we fix a logic flaw in the testCreateSimpleTx test case
which emerged once we the bug fix for dust outputs landed. Before this
commit, we would erroneously fail during valid test execution.
  • Loading branch information
Roasbeef committed Jun 19, 2019
1 parent ba89aa3 commit 9910807
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lnwallet/interface_test.go
Expand Up @@ -2279,7 +2279,7 @@ func testCreateSimpleTx(r *rpctest.Harness, w *lnwallet.LightningWallet,
},
}

for _, test := range testCases {
for i, test := range testCases {
feeRate := test.feeRate

// Grab some fresh addresses from the miner that we will send
Expand Down Expand Up @@ -2308,20 +2308,29 @@ func testCreateSimpleTx(r *rpctest.Harness, w *lnwallet.LightningWallet,
createTx, createErr := w.CreateSimpleTx(
outputs, feeRate, true,
)
if test.valid == (createErr != nil) {
switch {
case test.valid && createErr != nil:
fmt.Println(spew.Sdump(createTx.Tx))
t.Fatalf("got unexpected error when creating tx: %v",
createErr)

case !test.valid && createErr == nil:
t.Fatalf("test #%v should have failed on tx "+
"creation", i)
}

// Also send to these outputs. This should result in a tx
// _very_ similar to the one we just created being sent. The
// only difference is that the dry run tx is not signed, and
// that the change output position might be different.
tx, sendErr := w.SendOutputs(outputs, feeRate)
if test.valid == (sendErr != nil) {
switch {
case test.valid && sendErr != nil:
t.Fatalf("got unexpected error when sending tx: %v",
sendErr)

case !test.valid && sendErr == nil:
t.Fatalf("test #%v should fail for tx sending", i)
}

// We expected either both to not fail, or both to fail with
Expand Down

0 comments on commit 9910807

Please sign in to comment.