From fe2a565becf1aac7526d18c081fdda6d0d6e07f8 Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Wed, 10 Jul 2019 09:39:46 +0300 Subject: [PATCH] Add test for unmined transaction DestAddresses Co-authored-by: Christopher Coverdale --- lnwallet/interface_test.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index 0f9662639..ca7d9a279 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -1181,9 +1181,11 @@ func testListTransactionDetails(miner *rpctest.Harness, // Next create a transaction paying to an output which isn't under the // wallet's control. - b := txscript.NewScriptBuilder() - b.AddOp(txscript.OP_0) - outputScript, err := b.Script() + minerAddr, err := miner.NewAddress() + if err != nil { + t.Fatalf("unable to generate address: %v", err) + } + outputScript, err := txscript.PayToAddrScript(minerAddr) if err != nil { t.Fatalf("unable to make output script: %v", err) } @@ -1227,6 +1229,20 @@ func testListTransactionDetails(miner *rpctest.Harness, t.Fatalf("num confs incorrect, got %v expected %v", txDetail.NumConfirmations, 0) } + + // We test that each txDetail has destination addresses. This ensures + // that even when we have 0 confirmation transactions, the destination + // addresses are returned. + var match bool + for _, addr := range txDetail.DestAddresses { + if addr.String() == minerAddr.String() { + match = true + break + } + } + if !match { + t.Fatalf("minerAddr: %v should have been a dest addr", minerAddr) + } } if !mempoolTxFound { t.Fatalf("unable to find mempool tx in tx details!")